From c97fa5b5fe2f7467c17b7c6f836e7117d9246fca Mon Sep 17 00:00:00 2001 From: PythonSdkPipelines Date: Tue, 6 Sep 2022 09:13:09 +0000 Subject: [PATCH] code and test --- .../azure-mgmt-servicebus/CHANGELOG.md | 4 + .../azure-mgmt-servicebus/_meta.json | 10 +- .../azure/mgmt/servicebus/__init__.py | 4 + .../azure/mgmt/servicebus/_configuration.py | 12 +- .../azure/mgmt/servicebus/_serialization.py | 2006 ++++++++++++ .../_service_bus_management_client.py | 17 +- .../azure/mgmt/servicebus/_version.py | 2 +- .../mgmt/servicebus/aio/_configuration.py | 4 +- .../aio/_service_bus_management_client.py | 8 +- .../mgmt/servicebus/v2015_08_01/__init__.py | 3 +- .../servicebus/v2015_08_01/_configuration.py | 42 +- .../servicebus/v2015_08_01/_metadata.json | 18 +- .../mgmt/servicebus/v2015_08_01/_patch.py | 1 + .../_service_bus_management_client.py | 43 +- .../mgmt/servicebus/v2015_08_01/_vendor.py | 6 +- .../mgmt/servicebus/v2015_08_01/_version.py | 2 +- .../servicebus/v2015_08_01/aio/__init__.py | 3 +- .../v2015_08_01/aio/_configuration.py | 44 +- .../mgmt/servicebus/v2015_08_01/aio/_patch.py | 1 + .../aio/_service_bus_management_client.py | 43 +- .../v2015_08_01/aio/operations/__init__.py | 13 +- .../aio/operations/_namespaces_operations.py | 1005 +++--- .../v2015_08_01/aio/operations/_operations.py | 64 +- .../v2015_08_01/aio/operations/_patch.py | 1 + .../aio/operations/_queues_operations.py | 717 +++-- .../operations/_subscriptions_operations.py | 288 +- .../aio/operations/_topics_operations.py | 717 +++-- .../servicebus/v2015_08_01/models/__init__.py | 92 +- .../v2015_08_01/models/_models_py3.py | 971 +++--- .../servicebus/v2015_08_01/models/_patch.py | 1 + .../_service_bus_management_client_enums.py | 29 +- .../v2015_08_01/operations/__init__.py | 13 +- .../operations/_namespaces_operations.py | 1504 +++++---- .../v2015_08_01/operations/_operations.py | 91 +- .../v2015_08_01/operations/_patch.py | 1 + .../operations/_queues_operations.py | 1120 ++++--- .../operations/_subscriptions_operations.py | 427 +-- .../operations/_topics_operations.py | 1120 ++++--- .../mgmt/servicebus/v2017_04_01/__init__.py | 3 +- .../servicebus/v2017_04_01/_configuration.py | 42 +- .../servicebus/v2017_04_01/_metadata.json | 18 +- .../mgmt/servicebus/v2017_04_01/_patch.py | 1 + .../_service_bus_management_client.py | 69 +- .../mgmt/servicebus/v2017_04_01/_vendor.py | 6 +- .../mgmt/servicebus/v2017_04_01/_version.py | 2 +- .../servicebus/v2017_04_01/aio/__init__.py | 3 +- .../v2017_04_01/aio/_configuration.py | 44 +- .../mgmt/servicebus/v2017_04_01/aio/_patch.py | 1 + .../aio/_service_bus_management_client.py | 69 +- .../v2017_04_01/aio/operations/__init__.py | 25 +- .../_disaster_recovery_configs_operations.py | 601 ++-- .../aio/operations/_event_hubs_operations.py | 73 +- .../_migration_configs_operations.py | 385 ++- .../aio/operations/_namespaces_operations.py | 1316 +++++--- .../v2017_04_01/aio/operations/_operations.py | 64 +- .../v2017_04_01/aio/operations/_patch.py | 1 + .../_premium_messaging_regions_operations.py | 65 +- .../aio/operations/_queues_operations.py | 679 ++-- .../aio/operations/_regions_operations.py | 71 +- .../aio/operations/_rules_operations.py | 287 +- .../operations/_subscriptions_operations.py | 286 +- .../aio/operations/_topics_operations.py | 679 ++-- .../servicebus/v2017_04_01/models/__init__.py | 160 +- .../v2017_04_01/models/_models_py3.py | 1324 ++++---- .../servicebus/v2017_04_01/models/_patch.py | 1 + .../_service_bus_management_client_enums.py | 49 +- .../v2017_04_01/operations/__init__.py | 25 +- .../_disaster_recovery_configs_operations.py | 972 +++--- .../operations/_event_hubs_operations.py | 114 +- .../_migration_configs_operations.py | 582 ++-- .../operations/_namespaces_operations.py | 1988 ++++++------ .../v2017_04_01/operations/_operations.py | 91 +- .../v2017_04_01/operations/_patch.py | 1 + .../_premium_messaging_regions_operations.py | 98 +- .../operations/_queues_operations.py | 1058 +++--- .../operations/_regions_operations.py | 109 +- .../operations/_rules_operations.py | 436 +-- .../operations/_subscriptions_operations.py | 429 +-- .../operations/_topics_operations.py | 1058 +++--- .../v2018_01_01_preview/__init__.py | 3 +- .../v2018_01_01_preview/_configuration.py | 42 +- .../v2018_01_01_preview/_metadata.json | 18 +- .../servicebus/v2018_01_01_preview/_patch.py | 1 + .../_service_bus_management_client.py | 71 +- .../servicebus/v2018_01_01_preview/_vendor.py | 6 +- .../v2018_01_01_preview/_version.py | 2 +- .../v2018_01_01_preview/aio/__init__.py | 3 +- .../v2018_01_01_preview/aio/_configuration.py | 44 +- .../v2018_01_01_preview/aio/_patch.py | 1 + .../aio/_service_bus_management_client.py | 71 +- .../aio/operations/__init__.py | 29 +- .../_disaster_recovery_configs_operations.py | 676 ++-- .../aio/operations/_event_hubs_operations.py | 73 +- .../_migration_configs_operations.py | 386 ++- .../aio/operations/_namespaces_operations.py | 1817 +++++++---- .../aio/operations/_operations.py | 64 +- .../aio/operations/_patch.py | 1 + .../_premium_messaging_regions_operations.py | 65 +- ...private_endpoint_connections_operations.py | 327 +- .../_private_link_resources_operations.py | 49 +- .../aio/operations/_queues_operations.py | 680 ++-- .../aio/operations/_regions_operations.py | 71 +- .../aio/operations/_rules_operations.py | 286 +- .../operations/_subscriptions_operations.py | 286 +- .../aio/operations/_topics_operations.py | 680 ++-- .../v2018_01_01_preview/models/__init__.py | 200 +- .../v2018_01_01_preview/models/_models_py3.py | 1569 ++++----- .../v2018_01_01_preview/models/_patch.py | 1 + .../_service_bus_management_client_enums.py | 61 +- .../operations/__init__.py | 29 +- .../_disaster_recovery_configs_operations.py | 1056 +++--- .../operations/_event_hubs_operations.py | 113 +- .../_migration_configs_operations.py | 583 ++-- .../operations/_namespaces_operations.py | 2822 +++++++++-------- .../operations/_operations.py | 90 +- .../v2018_01_01_preview/operations/_patch.py | 1 + .../_premium_messaging_regions_operations.py | 98 +- ...private_endpoint_connections_operations.py | 474 +-- .../_private_link_resources_operations.py | 87 +- .../operations/_queues_operations.py | 1059 ++++--- .../operations/_regions_operations.py | 109 +- .../operations/_rules_operations.py | 437 +-- .../operations/_subscriptions_operations.py | 428 +-- .../operations/_topics_operations.py | 1059 ++++--- .../v2021_01_01_preview/__init__.py | 3 +- .../v2021_01_01_preview/_configuration.py | 42 +- .../v2021_01_01_preview/_metadata.json | 18 +- .../servicebus/v2021_01_01_preview/_patch.py | 1 + .../_service_bus_management_client.py | 60 +- .../servicebus/v2021_01_01_preview/_vendor.py | 6 +- .../v2021_01_01_preview/_version.py | 2 +- .../v2021_01_01_preview/aio/__init__.py | 3 +- .../v2021_01_01_preview/aio/_configuration.py | 44 +- .../v2021_01_01_preview/aio/_patch.py | 1 + .../aio/_service_bus_management_client.py | 60 +- .../aio/operations/__init__.py | 23 +- .../_disaster_recovery_configs_operations.py | 676 ++-- .../_migration_configs_operations.py | 386 ++- .../aio/operations/_namespaces_operations.py | 1214 ++++--- .../aio/operations/_operations.py | 64 +- .../aio/operations/_patch.py | 1 + ...private_endpoint_connections_operations.py | 327 +- .../_private_link_resources_operations.py | 49 +- .../aio/operations/_queues_operations.py | 680 ++-- .../aio/operations/_rules_operations.py | 286 +- .../operations/_subscriptions_operations.py | 286 +- .../aio/operations/_topics_operations.py | 680 ++-- .../v2021_01_01_preview/models/__init__.py | 178 +- .../v2021_01_01_preview/models/_models_py3.py | 1416 ++++----- .../v2021_01_01_preview/models/_patch.py | 1 + .../_service_bus_management_client_enums.py | 57 +- .../operations/__init__.py | 23 +- .../_disaster_recovery_configs_operations.py | 1056 +++--- .../_migration_configs_operations.py | 583 ++-- .../operations/_namespaces_operations.py | 1841 ++++++----- .../operations/_operations.py | 90 +- .../v2021_01_01_preview/operations/_patch.py | 1 + ...private_endpoint_connections_operations.py | 474 +-- .../_private_link_resources_operations.py | 87 +- .../operations/_queues_operations.py | 1059 ++++--- .../operations/_rules_operations.py | 437 +-- .../operations/_subscriptions_operations.py | 428 +-- .../operations/_topics_operations.py | 1059 ++++--- .../v2021_06_01_preview/__init__.py | 3 +- .../v2021_06_01_preview/_configuration.py | 42 +- .../v2021_06_01_preview/_metadata.json | 18 +- .../servicebus/v2021_06_01_preview/_patch.py | 1 + .../_service_bus_management_client.py | 60 +- .../servicebus/v2021_06_01_preview/_vendor.py | 6 +- .../v2021_06_01_preview/_version.py | 2 +- .../v2021_06_01_preview/aio/__init__.py | 3 +- .../v2021_06_01_preview/aio/_configuration.py | 44 +- .../v2021_06_01_preview/aio/_patch.py | 1 + .../aio/_service_bus_management_client.py | 60 +- .../aio/operations/__init__.py | 23 +- .../_disaster_recovery_configs_operations.py | 676 ++-- .../_migration_configs_operations.py | 386 ++- .../aio/operations/_namespaces_operations.py | 1214 ++++--- .../aio/operations/_operations.py | 64 +- .../aio/operations/_patch.py | 1 + ...private_endpoint_connections_operations.py | 327 +- .../_private_link_resources_operations.py | 49 +- .../aio/operations/_queues_operations.py | 680 ++-- .../aio/operations/_rules_operations.py | 286 +- .../operations/_subscriptions_operations.py | 286 +- .../aio/operations/_topics_operations.py | 680 ++-- .../v2021_06_01_preview/models/__init__.py | 184 +- .../v2021_06_01_preview/models/_models_py3.py | 1452 ++++----- .../v2021_06_01_preview/models/_patch.py | 1 + .../_service_bus_management_client_enums.py | 61 +- .../operations/__init__.py | 23 +- .../_disaster_recovery_configs_operations.py | 1056 +++--- .../_migration_configs_operations.py | 583 ++-- .../operations/_namespaces_operations.py | 1841 ++++++----- .../operations/_operations.py | 90 +- .../v2021_06_01_preview/operations/_patch.py | 1 + ...private_endpoint_connections_operations.py | 474 +-- .../_private_link_resources_operations.py | 87 +- .../operations/_queues_operations.py | 1059 ++++--- .../operations/_rules_operations.py | 437 +-- .../operations/_subscriptions_operations.py | 428 +-- .../operations/_topics_operations.py | 1059 ++++--- .../mgmt/servicebus/v2021_11_01/__init__.py | 3 +- .../servicebus/v2021_11_01/_configuration.py | 42 +- .../servicebus/v2021_11_01/_metadata.json | 18 +- .../mgmt/servicebus/v2021_11_01/_patch.py | 1 + .../_service_bus_management_client.py | 60 +- .../mgmt/servicebus/v2021_11_01/_vendor.py | 6 +- .../mgmt/servicebus/v2021_11_01/_version.py | 2 +- .../servicebus/v2021_11_01/aio/__init__.py | 3 +- .../v2021_11_01/aio/_configuration.py | 44 +- .../mgmt/servicebus/v2021_11_01/aio/_patch.py | 1 + .../aio/_service_bus_management_client.py | 60 +- .../v2021_11_01/aio/operations/__init__.py | 23 +- .../_disaster_recovery_configs_operations.py | 676 ++-- .../_migration_configs_operations.py | 385 ++- .../aio/operations/_namespaces_operations.py | 1214 ++++--- .../v2021_11_01/aio/operations/_operations.py | 64 +- .../v2021_11_01/aio/operations/_patch.py | 1 + ...private_endpoint_connections_operations.py | 328 +- .../_private_link_resources_operations.py | 49 +- .../aio/operations/_queues_operations.py | 679 ++-- .../aio/operations/_rules_operations.py | 287 +- .../operations/_subscriptions_operations.py | 286 +- .../aio/operations/_topics_operations.py | 679 ++-- .../servicebus/v2021_11_01/models/__init__.py | 186 +- .../v2021_11_01/models/_models_py3.py | 1539 +++++---- .../servicebus/v2021_11_01/models/_patch.py | 1 + .../_service_bus_management_client_enums.py | 61 +- .../v2021_11_01/operations/__init__.py | 23 +- .../_disaster_recovery_configs_operations.py | 1058 +++--- .../_migration_configs_operations.py | 582 ++-- .../operations/_namespaces_operations.py | 1842 ++++++----- .../v2021_11_01/operations/_operations.py | 91 +- .../v2021_11_01/operations/_patch.py | 1 + ...private_endpoint_connections_operations.py | 475 +-- .../_private_link_resources_operations.py | 87 +- .../operations/_queues_operations.py | 1058 +++--- .../operations/_rules_operations.py | 436 +-- .../operations/_subscriptions_operations.py | 429 +-- .../operations/_topics_operations.py | 1058 +++--- .../v2022_01_01_preview/__init__.py | 3 +- .../v2022_01_01_preview/_configuration.py | 42 +- .../v2022_01_01_preview/_metadata.json | 18 +- .../servicebus/v2022_01_01_preview/_patch.py | 1 + .../_service_bus_management_client.py | 60 +- .../servicebus/v2022_01_01_preview/_vendor.py | 6 +- .../v2022_01_01_preview/_version.py | 2 +- .../v2022_01_01_preview/aio/__init__.py | 3 +- .../v2022_01_01_preview/aio/_configuration.py | 44 +- .../v2022_01_01_preview/aio/_patch.py | 1 + .../aio/_service_bus_management_client.py | 60 +- .../aio/operations/__init__.py | 23 +- .../_disaster_recovery_configs_operations.py | 676 ++-- .../_migration_configs_operations.py | 386 ++- .../aio/operations/_namespaces_operations.py | 1214 ++++--- .../aio/operations/_operations.py | 64 +- .../aio/operations/_patch.py | 1 + ...private_endpoint_connections_operations.py | 329 +- .../_private_link_resources_operations.py | 49 +- .../aio/operations/_queues_operations.py | 680 ++-- .../aio/operations/_rules_operations.py | 286 +- .../operations/_subscriptions_operations.py | 286 +- .../aio/operations/_topics_operations.py | 680 ++-- .../v2022_01_01_preview/models/__init__.py | 198 +- .../v2022_01_01_preview/models/_models_py3.py | 1555 +++++---- .../v2022_01_01_preview/models/_patch.py | 1 + .../_service_bus_management_client_enums.py | 73 +- .../operations/__init__.py | 23 +- .../_disaster_recovery_configs_operations.py | 1058 +++--- .../_migration_configs_operations.py | 583 ++-- .../operations/_namespaces_operations.py | 1841 ++++++----- .../operations/_operations.py | 90 +- .../v2022_01_01_preview/operations/_patch.py | 1 + ...private_endpoint_connections_operations.py | 476 +-- .../_private_link_resources_operations.py | 87 +- .../operations/_queues_operations.py | 1059 ++++--- .../operations/_rules_operations.py | 437 +-- .../operations/_subscriptions_operations.py | 428 +-- .../operations/_topics_operations.py | 1059 ++++--- ..._queue.pyTestMgmtServiceBustest_queue.json | 156 +- ...tServiceBustest_subscrpition_and_rule.json | 225 +- ..._topic.pyTestMgmtServiceBustest_topic.json | 153 +- shared_requirements.txt | 4 +- 284 files changed, 53693 insertions(+), 41776 deletions(-) create mode 100644 sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/_serialization.py diff --git a/sdk/servicebus/azure-mgmt-servicebus/CHANGELOG.md b/sdk/servicebus/azure-mgmt-servicebus/CHANGELOG.md index e788c26f2fa7..906245feae2e 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/CHANGELOG.md +++ b/sdk/servicebus/azure-mgmt-servicebus/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History +## 0.0.0 (it should be stable) (2022-09-06) + + + ## 8.1.0 (2022-08-10) ### Features Added diff --git a/sdk/servicebus/azure-mgmt-servicebus/_meta.json b/sdk/servicebus/azure-mgmt-servicebus/_meta.json index 0ce811f5e239..4f31a94ba946 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/_meta.json +++ b/sdk/servicebus/azure-mgmt-servicebus/_meta.json @@ -1,11 +1,11 @@ { - "autorest": "3.7.2", + "autorest": "3.8.4", "use": [ - "@autorest/python@5.16.0", - "@autorest/modelerfour@4.19.3" + "@autorest/python@6.1.4", + "@autorest/modelerfour@4.23.5" ], - "commit": "124789ad0942fcafded1c1dbd6d2a703b23d10c7", + "commit": "f729f12bb95b4515b51ded20aab2f728551053b6", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/servicebus/resource-manager/readme.md --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --python3-only --use=@autorest/python@5.16.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", + "autorest_command": "autorest specification/servicebus/resource-manager/readme.md --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --use=@autorest/python@6.1.4 --use=@autorest/modelerfour@4.23.5 --version=3.8.4 --version-tolerant=False", "readme": "specification/servicebus/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/__init__.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/__init__.py index f640dac181bb..d3e8cda5f049 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/__init__.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/__init__.py @@ -14,3 +14,7 @@ patch_sdk() except ImportError: pass + +from ._version import VERSION + +__version__ = VERSION 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 a5b79adab717..fe4ce665a459 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/_configuration.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/_configuration.py @@ -8,7 +8,7 @@ # 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 @@ -18,8 +18,6 @@ if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential class ServiceBusManagementClientConfiguration(Configuration): @@ -28,16 +26,16 @@ class ServiceBusManagementClientConfiguration(Configuration): Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :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. Required. :type subscription_id: str """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str + credential: "TokenCredential", + subscription_id: str, **kwargs # type: Any ): # type: (...) -> None diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/_serialization.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/_serialization.py new file mode 100644 index 000000000000..240df16c57f3 --- /dev/null +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/_serialization.py @@ -0,0 +1,2006 @@ +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# pylint: skip-file + +from base64 import b64decode, b64encode +import calendar +import datetime +import decimal +import email +from enum import Enum +import json +import logging +import re +import sys +import codecs +try: + from urllib import quote # type: ignore +except ImportError: + from urllib.parse import quote # type: ignore +import xml.etree.ElementTree as ET + +import isodate + +from typing import Dict, Any, cast, TYPE_CHECKING + +from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback + +_BOM = codecs.BOM_UTF8.decode(encoding='utf-8') + +if TYPE_CHECKING: + from typing import Optional, Union, AnyStr, IO, Mapping + +class RawDeserializer: + + # Accept "text" because we're open minded people... + JSON_REGEXP = re.compile(r'^(application|text)/([a-z+.]+\+)?json$') + + # Name used in context + CONTEXT_NAME = "deserialized_data" + + @classmethod + def deserialize_from_text(cls, data, content_type=None): + # type: (Optional[Union[AnyStr, IO]], Optional[str]) -> Any + """Decode data according to content-type. + + Accept a stream of data as well, but will be load at once in memory for now. + + If no content-type, will return the string version (not bytes, not stream) + + :param data: Input, could be bytes or stream (will be decoded with UTF8) or text + :type data: str or bytes or IO + :param str content_type: The content type. + """ + if hasattr(data, 'read'): + # Assume a stream + data = cast(IO, data).read() + + if isinstance(data, bytes): + data_as_str = data.decode(encoding='utf-8-sig') + else: + # Explain to mypy the correct type. + data_as_str = cast(str, data) + + # Remove Byte Order Mark if present in string + data_as_str = data_as_str.lstrip(_BOM) + + if content_type is None: + return data + + if cls.JSON_REGEXP.match(content_type): + try: + return json.loads(data_as_str) + except ValueError as err: + raise DeserializationError("JSON is invalid: {}".format(err), err) + elif "xml" in (content_type or []): + try: + + try: + if isinstance(data, unicode): # type: ignore + # If I'm Python 2.7 and unicode XML will scream if I try a "fromstring" on unicode string + data_as_str = data_as_str.encode(encoding="utf-8") # type: ignore + except NameError: + pass + + return ET.fromstring(data_as_str) # nosec + except ET.ParseError: + # It might be because the server has an issue, and returned JSON with + # content-type XML.... + # So let's try a JSON load, and if it's still broken + # let's flow the initial exception + def _json_attemp(data): + try: + return True, json.loads(data) + except ValueError: + return False, None # Don't care about this one + success, json_result = _json_attemp(data) + if success: + return json_result + # If i'm here, it's not JSON, it's not XML, let's scream + # and raise the last context in this block (the XML exception) + # The function hack is because Py2.7 messes up with exception + # context otherwise. + _LOGGER.critical("Wasn't XML not JSON, failing") + raise_with_traceback(DeserializationError, "XML is invalid") + raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) + + @classmethod + def deserialize_from_http_generics(cls, body_bytes, headers): + # type: (Optional[Union[AnyStr, IO]], Mapping) -> Any + """Deserialize from HTTP response. + + Use bytes and headers to NOT use any requests/aiohttp or whatever + specific implementation. + Headers will tested for "content-type" + """ + # Try to use content-type from headers if available + content_type = None + if 'content-type' in headers: + content_type = headers['content-type'].split(";")[0].strip().lower() + # Ouch, this server did not declare what it sent... + # Let's guess it's JSON... + # Also, since Autorest was considering that an empty body was a valid JSON, + # need that test as well.... + else: + content_type = "application/json" + + if body_bytes: + return cls.deserialize_from_text(body_bytes, content_type) + return None + +try: + basestring # type: ignore + unicode_str = unicode # type: ignore +except NameError: + basestring = str # type: ignore + unicode_str = str # type: ignore + +_LOGGER = logging.getLogger(__name__) + +try: + _long_type = long # type: ignore +except NameError: + _long_type = int + +class UTC(datetime.tzinfo): + """Time Zone info for handling UTC""" + + def utcoffset(self, dt): + """UTF offset for UTC is 0.""" + return datetime.timedelta(0) + + def tzname(self, dt): + """Timestamp representation.""" + return "Z" + + def dst(self, dt): + """No daylight saving for UTC.""" + return datetime.timedelta(hours=1) + +try: + from datetime import timezone as _FixedOffset +except ImportError: # Python 2.7 + class _FixedOffset(datetime.tzinfo): # type: ignore + """Fixed offset in minutes east from UTC. + Copy/pasted from Python doc + :param datetime.timedelta offset: offset in timedelta format + """ + + def __init__(self, offset): + self.__offset = offset + + def utcoffset(self, dt): + return self.__offset + + def tzname(self, dt): + return str(self.__offset.total_seconds()/3600) + + def __repr__(self): + return "".format(self.tzname(None)) + + def dst(self, dt): + return datetime.timedelta(0) + + def __getinitargs__(self): + return (self.__offset,) + +try: + from datetime import timezone + TZ_UTC = timezone.utc # type: ignore +except ImportError: + TZ_UTC = UTC() # type: ignore + +_FLATTEN = re.compile(r"(? y, + "minimum": lambda x, y: x < y, + "maximum": lambda x, y: x > y, + "minimum_ex": lambda x, y: x <= y, + "maximum_ex": lambda x, y: x >= y, + "min_items": lambda x, y: len(x) < y, + "max_items": lambda x, y: len(x) > y, + "pattern": lambda x, y: not re.match(y, x, re.UNICODE), + "unique": lambda x, y: len(x) != len(set(x)), + "multiple": lambda x, y: x % y != 0 + } + + def __init__(self, classes=None): + self.serialize_type = { + 'iso-8601': Serializer.serialize_iso, + 'rfc-1123': Serializer.serialize_rfc, + 'unix-time': Serializer.serialize_unix, + 'duration': Serializer.serialize_duration, + 'date': Serializer.serialize_date, + 'time': Serializer.serialize_time, + 'decimal': Serializer.serialize_decimal, + 'long': Serializer.serialize_long, + 'bytearray': Serializer.serialize_bytearray, + 'base64': Serializer.serialize_base64, + 'object': self.serialize_object, + '[]': self.serialize_iter, + '{}': self.serialize_dict + } + self.dependencies = dict(classes) if classes else {} + self.key_transformer = full_restapi_key_transformer + self.client_side_validation = True + + def _serialize(self, target_obj, data_type=None, **kwargs): + """Serialize data into a string according to type. + + :param target_obj: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str, dict + :raises: SerializationError if serialization fails. + """ + key_transformer = kwargs.get("key_transformer", self.key_transformer) + keep_readonly = kwargs.get("keep_readonly", False) + if target_obj is None: + return None + + attr_name = None + class_name = target_obj.__class__.__name__ + + if data_type: + return self.serialize_data( + target_obj, data_type, **kwargs) + + if not hasattr(target_obj, "_attribute_map"): + data_type = type(target_obj).__name__ + if data_type in self.basic_types.values(): + return self.serialize_data( + target_obj, data_type, **kwargs) + + # Force "is_xml" kwargs if we detect a XML model + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + is_xml_model_serialization = kwargs.setdefault("is_xml", target_obj.is_xml_model()) + + serialized = {} + if is_xml_model_serialization: + serialized = target_obj._create_xml_node() + try: + attributes = target_obj._attribute_map + for attr, attr_desc in attributes.items(): + attr_name = attr + if not keep_readonly and target_obj._validation.get(attr_name, {}).get('readonly', False): + continue + + if attr_name == "additional_properties" and attr_desc["key"] == '': + if target_obj.additional_properties is not None: + serialized.update(target_obj.additional_properties) + continue + try: + + orig_attr = getattr(target_obj, attr) + if is_xml_model_serialization: + pass # Don't provide "transformer" for XML for now. Keep "orig_attr" + else: # JSON + keys, orig_attr = key_transformer(attr, attr_desc.copy(), orig_attr) + keys = keys if isinstance(keys, list) else [keys] + + + kwargs["serialization_ctxt"] = attr_desc + new_attr = self.serialize_data(orig_attr, attr_desc['type'], **kwargs) + + + if is_xml_model_serialization: + xml_desc = attr_desc.get('xml', {}) + xml_name = xml_desc.get('name', attr_desc['key']) + xml_prefix = xml_desc.get('prefix', None) + xml_ns = xml_desc.get('ns', None) + if xml_desc.get("attr", False): + if xml_ns: + ET.register_namespace(xml_prefix, xml_ns) + xml_name = "{}{}".format(xml_ns, xml_name) + serialized.set(xml_name, new_attr) + continue + if xml_desc.get("text", False): + serialized.text = new_attr + continue + if isinstance(new_attr, list): + serialized.extend(new_attr) + elif isinstance(new_attr, ET.Element): + # If the down XML has no XML/Name, we MUST replace the tag with the local tag. But keeping the namespaces. + if 'name' not in getattr(orig_attr, '_xml_map', {}): + splitted_tag = new_attr.tag.split("}") + if len(splitted_tag) == 2: # Namespace + new_attr.tag = "}".join([splitted_tag[0], xml_name]) + else: + new_attr.tag = xml_name + serialized.append(new_attr) + else: # That's a basic type + # Integrate namespace if necessary + local_node = _create_xml_node( + xml_name, + xml_prefix, + xml_ns + ) + local_node.text = unicode_str(new_attr) + serialized.append(local_node) + else: # JSON + for k in reversed(keys): + unflattened = {k: new_attr} + new_attr = unflattened + + _new_attr = new_attr + _serialized = serialized + for k in keys: + if k not in _serialized: + _serialized.update(_new_attr) + _new_attr = _new_attr[k] + _serialized = _serialized[k] + except ValueError: + continue + + except (AttributeError, KeyError, TypeError) as err: + msg = "Attribute {} in object {} cannot be serialized.\n{}".format( + attr_name, class_name, str(target_obj)) + raise_with_traceback(SerializationError, msg, err) + else: + return serialized + + def body(self, data, data_type, **kwargs): + """Serialize data intended for a request body. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: dict + :raises: SerializationError if serialization fails. + :raises: ValueError if data is None + """ + + # Just in case this is a dict + internal_data_type = data_type.strip('[]{}') + internal_data_type = self.dependencies.get(internal_data_type, None) + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + if internal_data_type and issubclass(internal_data_type, Model): + is_xml_model_serialization = kwargs.setdefault("is_xml", internal_data_type.is_xml_model()) + else: + is_xml_model_serialization = False + if internal_data_type and not isinstance(internal_data_type, Enum): + try: + deserializer = Deserializer(self.dependencies) + # Since it's on serialization, it's almost sure that format is not JSON REST + # We're not able to deal with additional properties for now. + deserializer.additional_properties_detection = False + if is_xml_model_serialization: + deserializer.key_extractors = [ + attribute_key_case_insensitive_extractor, + ] + else: + deserializer.key_extractors = [ + rest_key_case_insensitive_extractor, + attribute_key_case_insensitive_extractor, + last_rest_key_case_insensitive_extractor + ] + data = deserializer._deserialize(data_type, data) + except DeserializationError as err: + raise_with_traceback( + SerializationError, "Unable to build a model: "+str(err), err) + + return self._serialize(data, data_type, **kwargs) + + def url(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL path. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + output = self.serialize_data(data, data_type, **kwargs) + if data_type == 'bool': + output = json.dumps(output) + + if kwargs.get('skip_quote') is True: + output = str(output) + else: + output = quote(str(output), safe='') + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return output + + def query(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL query. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + # Treat the list aside, since we don't want to encode the div separator + if data_type.startswith("["): + internal_data_type = data_type[1:-1] + data = [ + self.serialize_data(d, internal_data_type, **kwargs) if d is not None else "" + for d + in data + ] + if not kwargs.get('skip_quote', False): + data = [ + quote(str(d), safe='') + for d + in data + ] + return str(self.serialize_iter(data, internal_data_type, **kwargs)) + + # Not a list, regular serialization + output = self.serialize_data(data, data_type, **kwargs) + if data_type == 'bool': + output = json.dumps(output) + if kwargs.get('skip_quote') is True: + output = str(output) + else: + output = quote(str(output), safe='') + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return str(output) + + def header(self, name, data, data_type, **kwargs): + """Serialize data intended for a request header. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + if data_type in ['[str]']: + data = ["" if d is None else d for d in data] + + output = self.serialize_data(data, data_type, **kwargs) + if data_type == 'bool': + output = json.dumps(output) + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return str(output) + + def serialize_data(self, data, data_type, **kwargs): + """Serialize generic data according to supplied data type. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :param bool required: Whether it's essential that the data not be + empty or None + :raises: AttributeError if required data is None. + :raises: ValueError if data is None + :raises: SerializationError if serialization fails. + """ + if data is None: + raise ValueError("No value for given attribute") + + try: + if data_type in self.basic_types.values(): + return self.serialize_basic(data, data_type, **kwargs) + + elif data_type in self.serialize_type: + return self.serialize_type[data_type](data, **kwargs) + + # If dependencies is empty, try with current data class + # It has to be a subclass of Enum anyway + enum_type = self.dependencies.get(data_type, data.__class__) + if issubclass(enum_type, Enum): + return Serializer.serialize_enum(data, enum_obj=enum_type) + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.serialize_type: + return self.serialize_type[iter_type]( + data, data_type[1:-1], **kwargs) + + except (ValueError, TypeError) as err: + msg = "Unable to serialize value: {!r} as type: {!r}." + raise_with_traceback( + SerializationError, msg.format(data, data_type), err) + else: + return self._serialize(data, **kwargs) + + @classmethod + def _get_custom_serializers(cls, data_type, **kwargs): + custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) + if custom_serializer: + return custom_serializer + if kwargs.get("is_xml", False): + return cls._xml_basic_types_serializers.get(data_type) + + @classmethod + def serialize_basic(cls, data, data_type, **kwargs): + """Serialize basic builting data type. + Serializes objects to str, int, float or bool. + + Possible kwargs: + - basic_types_serializers dict[str, callable] : If set, use the callable as serializer + - is_xml bool : If set, use xml_basic_types_serializers + + :param data: Object to be serialized. + :param str data_type: Type of object in the iterable. + """ + custom_serializer = cls._get_custom_serializers(data_type, **kwargs) + if custom_serializer: + return custom_serializer(data) + if data_type == 'str': + return cls.serialize_unicode(data) + return eval(data_type)(data) # nosec + + @classmethod + def serialize_unicode(cls, data): + """Special handling for serializing unicode strings in Py2. + Encode to UTF-8 if unicode, otherwise handle as a str. + + :param data: Object to be serialized. + :rtype: str + """ + try: # If I received an enum, return its value + return data.value + except AttributeError: + pass + + try: + if isinstance(data, unicode): + # Don't change it, JSON and XML ElementTree are totally able + # to serialize correctly u'' strings + return data + except NameError: + return str(data) + else: + return str(data) + + def serialize_iter(self, data, iter_type, div=None, **kwargs): + """Serialize iterable. + + Supported kwargs: + - serialization_ctxt dict : The current entry of _attribute_map, or same format. + serialization_ctxt['type'] should be same as data_type. + - is_xml bool : If set, serialize as XML + + :param list attr: Object to be serialized. + :param str iter_type: Type of object in the iterable. + :param bool required: Whether the objects in the iterable must + not be None or empty. + :param str div: If set, this str will be used to combine the elements + in the iterable into a combined string. Default is 'None'. + :rtype: list, str + """ + if isinstance(data, str): + raise SerializationError("Refuse str type as a valid iter type.") + + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + is_xml = kwargs.get("is_xml", False) + + serialized = [] + for d in data: + try: + serialized.append(self.serialize_data(d, iter_type, **kwargs)) + except ValueError: + serialized.append(None) + + if div: + serialized = ['' if s is None else str(s) for s in serialized] + serialized = div.join(serialized) + + if 'xml' in serialization_ctxt or is_xml: + # XML serialization is more complicated + xml_desc = serialization_ctxt.get('xml', {}) + xml_name = xml_desc.get('name') + if not xml_name: + xml_name = serialization_ctxt['key'] + + # Create a wrap node if necessary (use the fact that Element and list have "append") + is_wrapped = xml_desc.get("wrapped", False) + node_name = xml_desc.get("itemsName", xml_name) + if is_wrapped: + final_result = _create_xml_node( + xml_name, + xml_desc.get('prefix', None), + xml_desc.get('ns', None) + ) + else: + final_result = [] + # All list elements to "local_node" + for el in serialized: + if isinstance(el, ET.Element): + el_node = el + else: + el_node = _create_xml_node( + node_name, + xml_desc.get('prefix', None), + xml_desc.get('ns', None) + ) + if el is not None: # Otherwise it writes "None" :-p + el_node.text = str(el) + final_result.append(el_node) + return final_result + return serialized + + def serialize_dict(self, attr, dict_type, **kwargs): + """Serialize a dictionary of objects. + + :param dict attr: Object to be serialized. + :param str dict_type: Type of object in the dictionary. + :param bool required: Whether the objects in the dictionary must + not be None or empty. + :rtype: dict + """ + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_data( + value, dict_type, **kwargs) + except ValueError: + serialized[self.serialize_unicode(key)] = None + + if 'xml' in serialization_ctxt: + # XML serialization is more complicated + xml_desc = serialization_ctxt['xml'] + xml_name = xml_desc['name'] + + final_result = _create_xml_node( + xml_name, + xml_desc.get('prefix', None), + xml_desc.get('ns', None) + ) + for key, value in serialized.items(): + ET.SubElement(final_result, key).text = value + return final_result + + return serialized + + def serialize_object(self, attr, **kwargs): + """Serialize a generic object. + This will be handled as a dictionary. If object passed in is not + a basic type (str, int, float, dict, list) it will simply be + cast to str. + + :param dict attr: Object to be serialized. + :rtype: dict or str + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + return attr + obj_type = type(attr) + if obj_type in self.basic_types: + return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) + if obj_type is _long_type: + return self.serialize_long(attr) + if obj_type is unicode_str: + return self.serialize_unicode(attr) + if obj_type is datetime.datetime: + return self.serialize_iso(attr) + if obj_type is datetime.date: + return self.serialize_date(attr) + if obj_type is datetime.time: + return self.serialize_time(attr) + if obj_type is datetime.timedelta: + return self.serialize_duration(attr) + if obj_type is decimal.Decimal: + return self.serialize_decimal(attr) + + # If it's a model or I know this dependency, serialize as a Model + elif obj_type in self.dependencies.values() or isinstance(attr, Model): + return self._serialize(attr) + + if obj_type == dict: + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_object( + value, **kwargs) + except ValueError: + serialized[self.serialize_unicode(key)] = None + return serialized + + if obj_type == list: + serialized = [] + for obj in attr: + try: + serialized.append(self.serialize_object( + obj, **kwargs)) + except ValueError: + pass + return serialized + return str(attr) + + @staticmethod + def serialize_enum(attr, enum_obj=None): + try: + result = attr.value + except AttributeError: + result = attr + try: + enum_obj(result) + return result + except ValueError: + for enum_value in enum_obj: + if enum_value.value.lower() == str(attr).lower(): + return enum_value.value + error = "{!r} is not valid value for enum {!r}" + raise SerializationError(error.format(attr, enum_obj)) + + @staticmethod + def serialize_bytearray(attr, **kwargs): + """Serialize bytearray into base-64 string. + + :param attr: Object to be serialized. + :rtype: str + """ + return b64encode(attr).decode() + + @staticmethod + def serialize_base64(attr, **kwargs): + """Serialize str into base-64 string. + + :param attr: Object to be serialized. + :rtype: str + """ + encoded = b64encode(attr).decode('ascii') + return encoded.strip('=').replace('+', '-').replace('/', '_') + + @staticmethod + def serialize_decimal(attr, **kwargs): + """Serialize Decimal object to float. + + :param attr: Object to be serialized. + :rtype: float + """ + return float(attr) + + @staticmethod + def serialize_long(attr, **kwargs): + """Serialize long (Py2) or int (Py3). + + :param attr: Object to be serialized. + :rtype: int/long + """ + return _long_type(attr) + + @staticmethod + def serialize_date(attr, **kwargs): + """Serialize Date object into ISO-8601 formatted string. + + :param Date attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_date(attr) + t = "{:04}-{:02}-{:02}".format(attr.year, attr.month, attr.day) + return t + + @staticmethod + def serialize_time(attr, **kwargs): + """Serialize Time object into ISO-8601 formatted string. + + :param datetime.time attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_time(attr) + t = "{:02}:{:02}:{:02}".format(attr.hour, attr.minute, attr.second) + if attr.microsecond: + t += ".{:02}".format(attr.microsecond) + return t + + @staticmethod + def serialize_duration(attr, **kwargs): + """Serialize TimeDelta object into ISO-8601 formatted string. + + :param TimeDelta attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_duration(attr) + return isodate.duration_isoformat(attr) + + @staticmethod + def serialize_rfc(attr, **kwargs): + """Serialize Datetime object into RFC-1123 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises: TypeError if format invalid. + """ + try: + if not attr.tzinfo: + _LOGGER.warning( + "Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + except AttributeError: + raise TypeError("RFC1123 object must be valid Datetime object.") + + return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( + Serializer.days[utc.tm_wday], utc.tm_mday, + Serializer.months[utc.tm_mon], utc.tm_year, + utc.tm_hour, utc.tm_min, utc.tm_sec) + + @staticmethod + def serialize_iso(attr, **kwargs): + """Serialize Datetime object into ISO-8601 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises: SerializationError if format invalid. + """ + if isinstance(attr, str): + attr = isodate.parse_datetime(attr) + try: + if not attr.tzinfo: + _LOGGER.warning( + "Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + if utc.tm_year > 9999 or utc.tm_year < 1: + raise OverflowError("Hit max or min date") + + microseconds = str(attr.microsecond).rjust(6,'0').rstrip('0').ljust(3, '0') + if microseconds: + microseconds = '.'+microseconds + date = "{:04}-{:02}-{:02}T{:02}:{:02}:{:02}".format( + utc.tm_year, utc.tm_mon, utc.tm_mday, + utc.tm_hour, utc.tm_min, utc.tm_sec) + return date + microseconds + 'Z' + except (ValueError, OverflowError) as err: + msg = "Unable to serialize datetime object." + raise_with_traceback(SerializationError, msg, err) + except AttributeError as err: + msg = "ISO-8601 object must be valid Datetime object." + raise_with_traceback(TypeError, msg, err) + + @staticmethod + def serialize_unix(attr, **kwargs): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param Datetime attr: Object to be serialized. + :rtype: int + :raises: SerializationError if format invalid + """ + if isinstance(attr, int): + return attr + try: + if not attr.tzinfo: + _LOGGER.warning( + "Datetime with no tzinfo will be considered UTC.") + return int(calendar.timegm(attr.utctimetuple())) + except AttributeError: + raise TypeError("Unix time object must be valid Datetime object.") + +def rest_key_extractor(attr, attr_desc, data): + key = attr_desc['key'] + working_data = data + + while '.' in key: + dict_keys = _FLATTEN.split(key) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = working_data.get(working_key, data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + # https://github.com/Azure/msrest-for-python/issues/197 + return None + key = '.'.join(dict_keys[1:]) + + return working_data.get(key) + +def rest_key_case_insensitive_extractor(attr, attr_desc, data): + key = attr_desc['key'] + working_data = data + + while '.' in key: + dict_keys = _FLATTEN.split(key) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = attribute_key_case_insensitive_extractor(working_key, None, working_data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + # https://github.com/Azure/msrest-for-python/issues/197 + return None + key = '.'.join(dict_keys[1:]) + + if working_data: + return attribute_key_case_insensitive_extractor(key, None, working_data) + +def last_rest_key_extractor(attr, attr_desc, data): + """Extract the attribute in "data" based on the last part of the JSON path key. + """ + key = attr_desc['key'] + dict_keys = _FLATTEN.split(key) + return attribute_key_extractor(dict_keys[-1], None, data) + +def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): + """Extract the attribute in "data" based on the last part of the JSON path key. + + This is the case insensitive version of "last_rest_key_extractor" + """ + key = attr_desc['key'] + dict_keys = _FLATTEN.split(key) + return attribute_key_case_insensitive_extractor(dict_keys[-1], None, data) + +def attribute_key_extractor(attr, _, data): + return data.get(attr) + +def attribute_key_case_insensitive_extractor(attr, _, data): + found_key = None + lower_attr = attr.lower() + for key in data: + if lower_attr == key.lower(): + found_key = key + break + + return data.get(found_key) + +def _extract_name_from_internal_type(internal_type): + """Given an internal type XML description, extract correct XML name with namespace. + + :param dict internal_type: An model type + :rtype: tuple + :returns: A tuple XML name + namespace dict + """ + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + xml_name = internal_type_xml_map.get('name', internal_type.__name__) + xml_ns = internal_type_xml_map.get("ns", None) + if xml_ns: + xml_name = "{}{}".format(xml_ns, xml_name) + return xml_name + + +def xml_key_extractor(attr, attr_desc, data): + if isinstance(data, dict): + return None + + # Test if this model is XML ready first + if not isinstance(data, ET.Element): + return None + + xml_desc = attr_desc.get('xml', {}) + xml_name = xml_desc.get('name', attr_desc['key']) + + # Look for a children + is_iter_type = attr_desc['type'].startswith("[") + is_wrapped = xml_desc.get("wrapped", False) + internal_type = attr_desc.get("internalType", None) + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + + # Integrate namespace if necessary + xml_ns = xml_desc.get('ns', internal_type_xml_map.get("ns", None)) + if xml_ns: + xml_name = "{}{}".format(xml_ns, xml_name) + + # If it's an attribute, that's simple + if xml_desc.get("attr", False): + return data.get(xml_name) + + # If it's x-ms-text, that's simple too + if xml_desc.get("text", False): + return data.text + + # Scenario where I take the local name: + # - Wrapped node + # - Internal type is an enum (considered basic types) + # - Internal type has no XML/Name node + if is_wrapped or (internal_type and (issubclass(internal_type, Enum) or 'name' not in internal_type_xml_map)): + children = data.findall(xml_name) + # If internal type has a local name and it's not a list, I use that name + elif not is_iter_type and internal_type and 'name' in internal_type_xml_map: + xml_name = _extract_name_from_internal_type(internal_type) + children = data.findall(xml_name) + # That's an array + else: + if internal_type: # Complex type, ignore itemsName and use the complex type name + items_name = _extract_name_from_internal_type(internal_type) + else: + items_name = xml_desc.get("itemsName", xml_name) + children = data.findall(items_name) + + if len(children) == 0: + if is_iter_type: + if is_wrapped: + return None # is_wrapped no node, we want None + else: + return [] # not wrapped, assume empty list + return None # Assume it's not there, maybe an optional node. + + # If is_iter_type and not wrapped, return all found children + if is_iter_type: + if not is_wrapped: + return children + else: # Iter and wrapped, should have found one node only (the wrap one) + if len(children) != 1: + raise DeserializationError( + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( + xml_name + )) + return list(children[0]) # Might be empty list and that's ok. + + # Here it's not a itertype, we should have found one element only or empty + if len(children) > 1: + raise DeserializationError("Find several XML '{}' where it was not expected".format(xml_name)) + return children[0] + +class Deserializer(object): + """Response object model deserializer. + + :param dict classes: Class type dictionary for deserializing complex types. + :ivar list key_extractors: Ordered list of extractors to be used by this deserializer. + """ + + basic_types = {str: 'str', int: 'int', bool: 'bool', float: 'float'} + + valid_date = re.compile( + r'\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}' + r'\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?') + + def __init__(self, classes=None): + self.deserialize_type = { + 'iso-8601': Deserializer.deserialize_iso, + 'rfc-1123': Deserializer.deserialize_rfc, + 'unix-time': Deserializer.deserialize_unix, + 'duration': Deserializer.deserialize_duration, + 'date': Deserializer.deserialize_date, + 'time': Deserializer.deserialize_time, + 'decimal': Deserializer.deserialize_decimal, + 'long': Deserializer.deserialize_long, + 'bytearray': Deserializer.deserialize_bytearray, + 'base64': Deserializer.deserialize_base64, + 'object': self.deserialize_object, + '[]': self.deserialize_iter, + '{}': self.deserialize_dict + } + self.deserialize_expected_types = { + 'duration': (isodate.Duration, datetime.timedelta), + 'iso-8601': (datetime.datetime) + } + self.dependencies = dict(classes) if classes else {} + self.key_extractors = [ + rest_key_extractor, + xml_key_extractor + ] + # Additional properties only works if the "rest_key_extractor" is used to + # extract the keys. Making it to work whatever the key extractor is too much + # complicated, with no real scenario for now. + # So adding a flag to disable additional properties detection. This flag should be + # used if your expect the deserialization to NOT come from a JSON REST syntax. + # Otherwise, result are unexpected + self.additional_properties_detection = True + + def __call__(self, target_obj, response_data, content_type=None): + """Call the deserializer to process a REST response. + + :param str target_obj: Target data type to deserialize to. + :param requests.Response response_data: REST response object. + :param str content_type: Swagger "produces" if available. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + data = self._unpack_content(response_data, content_type) + return self._deserialize(target_obj, data) + + def _deserialize(self, target_obj, data): + """Call the deserializer on a model. + + Data needs to be already deserialized as JSON or XML ElementTree + + :param str target_obj: Target data type to deserialize to. + :param object data: Object to deserialize. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + # This is already a model, go recursive just in case + if hasattr(data, "_attribute_map"): + constants = [name for name, config in getattr(data, '_validation', {}).items() + if config.get('constant')] + try: + for attr, mapconfig in data._attribute_map.items(): + if attr in constants: + continue + value = getattr(data, attr) + if value is None: + continue + local_type = mapconfig['type'] + internal_data_type = local_type.strip('[]{}') + if internal_data_type not in self.dependencies or isinstance(internal_data_type, Enum): + continue + setattr( + data, + attr, + self._deserialize(local_type, value) + ) + return data + except AttributeError: + return + + response, class_name = self._classify_target(target_obj, data) + + if isinstance(response, basestring): + return self.deserialize_data(data, response) + elif isinstance(response, type) and issubclass(response, Enum): + return self.deserialize_enum(data, response) + + if data is None: + return data + try: + attributes = response._attribute_map + d_attrs = {} + for attr, attr_desc in attributes.items(): + # Check empty string. If it's not empty, someone has a real "additionalProperties"... + if attr == "additional_properties" and attr_desc["key"] == '': + continue + raw_value = None + # Enhance attr_desc with some dynamic data + attr_desc = attr_desc.copy() # Do a copy, do not change the real one + internal_data_type = attr_desc["type"].strip('[]{}') + if internal_data_type in self.dependencies: + attr_desc["internalType"] = self.dependencies[internal_data_type] + + for key_extractor in self.key_extractors: + found_value = key_extractor(attr, attr_desc, data) + if found_value is not None: + if raw_value is not None and raw_value != found_value: + msg = ("Ignoring extracted value '%s' from %s for key '%s'" + " (duplicate extraction, follow extractors order)" ) + _LOGGER.warning( + msg, + found_value, + key_extractor, + attr + ) + continue + raw_value = found_value + + value = self.deserialize_data(raw_value, attr_desc['type']) + d_attrs[attr] = value + except (AttributeError, TypeError, KeyError) as err: + msg = "Unable to deserialize to object: " + class_name + raise_with_traceback(DeserializationError, msg, err) + else: + additional_properties = self._build_additional_properties(attributes, data) + return self._instantiate_model(response, d_attrs, additional_properties) + + def _build_additional_properties(self, attribute_map, data): + if not self.additional_properties_detection: + return None + if "additional_properties" in attribute_map and attribute_map.get("additional_properties", {}).get("key") != '': + # Check empty string. If it's not empty, someone has a real "additionalProperties" + return None + if isinstance(data, ET.Element): + data = {el.tag: el.text for el in data} + + known_keys = {_decode_attribute_map_key(_FLATTEN.split(desc['key'])[0]) + for desc in attribute_map.values() if desc['key'] != ''} + present_keys = set(data.keys()) + missing_keys = present_keys - known_keys + return {key: data[key] for key in missing_keys} + + def _classify_target(self, target, data): + """Check to see whether the deserialization target object can + be classified into a subclass. + Once classification has been determined, initialize object. + + :param str target: The target object type to deserialize to. + :param str/dict data: The response data to deseralize. + """ + if target is None: + return None, None + + if isinstance(target, basestring): + try: + target = self.dependencies[target] + except KeyError: + return target, target + + try: + target = target._classify(data, self.dependencies) + except AttributeError: + pass # Target is not a Model, no classify + return target, target.__class__.__name__ + + def failsafe_deserialize(self, target_obj, data, content_type=None): + """Ignores any errors encountered in deserialization, + and falls back to not deserializing the object. Recommended + for use in error deserialization, as we want to return the + HttpResponseError to users, and not have them deal with + a deserialization error. + + :param str target_obj: The target object type to deserialize to. + :param str/dict data: The response data to deseralize. + :param str content_type: Swagger "produces" if available. + """ + try: + return self(target_obj, data, content_type=content_type) + except: + _LOGGER.debug( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", + exc_info=True + ) + return None + + @staticmethod + def _unpack_content(raw_data, content_type=None): + """Extract the correct structure for deserialization. + + If raw_data is a PipelineResponse, try to extract the result of RawDeserializer. + if we can't, raise. Your Pipeline should have a RawDeserializer. + + If not a pipeline response and raw_data is bytes or string, use content-type + to decode it. If no content-type, try JSON. + + If raw_data is something else, bypass all logic and return it directly. + + :param raw_data: Data to be processed. + :param content_type: How to parse if raw_data is a string/bytes. + :raises JSONDecodeError: If JSON is requested and parsing is impossible. + :raises UnicodeDecodeError: If bytes is not UTF8 + """ + # Assume this is enough to detect a Pipeline Response without importing it + context = getattr(raw_data, "context", {}) + if context: + if RawDeserializer.CONTEXT_NAME in context: + return context[RawDeserializer.CONTEXT_NAME] + raise ValueError("This pipeline didn't have the RawDeserializer policy; can't deserialize") + + #Assume this is enough to recognize universal_http.ClientResponse without importing it + if hasattr(raw_data, "body"): + return RawDeserializer.deserialize_from_http_generics( + raw_data.text(), + raw_data.headers + ) + + # Assume this enough to recognize requests.Response without importing it. + if hasattr(raw_data, '_content_consumed'): + return RawDeserializer.deserialize_from_http_generics( + raw_data.text, + raw_data.headers + ) + + if isinstance(raw_data, (basestring, bytes)) or hasattr(raw_data, 'read'): + return RawDeserializer.deserialize_from_text(raw_data, content_type) + return raw_data + + def _instantiate_model(self, response, attrs, additional_properties=None): + """Instantiate a response model passing in deserialized args. + + :param response: The response model class. + :param d_attrs: The deserialized response attributes. + """ + if callable(response): + subtype = getattr(response, '_subtype_map', {}) + try: + readonly = [k for k, v in response._validation.items() + if v.get('readonly')] + const = [k for k, v in response._validation.items() + if v.get('constant')] + kwargs = {k: v for k, v in attrs.items() + if k not in subtype and k not in readonly + const} + response_obj = response(**kwargs) + for attr in readonly: + setattr(response_obj, attr, attrs.get(attr)) + if additional_properties: + response_obj.additional_properties = additional_properties + return response_obj + except TypeError as err: + msg = "Unable to deserialize {} into model {}. ".format( + kwargs, response) + raise DeserializationError(msg + str(err)) + else: + try: + for attr, value in attrs.items(): + setattr(response, attr, value) + return response + except Exception as exp: + msg = "Unable to populate response model. " + msg += "Type: {}, Error: {}".format(type(response), exp) + raise DeserializationError(msg) + + def deserialize_data(self, data, data_type): + """Process data for deserialization according to data type. + + :param str data: The response string to be deserialized. + :param str data_type: The type to deserialize to. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + if data is None: + return data + + try: + if not data_type: + return data + if data_type in self.basic_types.values(): + return self.deserialize_basic(data, data_type) + if data_type in self.deserialize_type: + if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): + return data + + is_a_text_parsing_type = lambda x: x not in ["object", "[]", r"{}"] + if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: + return None + data_val = self.deserialize_type[data_type](data) + return data_val + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.deserialize_type: + return self.deserialize_type[iter_type](data, data_type[1:-1]) + + obj_type = self.dependencies[data_type] + if issubclass(obj_type, Enum): + if isinstance(data, ET.Element): + data = data.text + return self.deserialize_enum(data, obj_type) + + except (ValueError, TypeError, AttributeError) as err: + msg = "Unable to deserialize response data." + msg += " Data: {}, {}".format(data, data_type) + raise_with_traceback(DeserializationError, msg, err) + else: + return self._deserialize(obj_type, data) + + def deserialize_iter(self, attr, iter_type): + """Deserialize an iterable. + + :param list attr: Iterable to be deserialized. + :param str iter_type: The type of object in the iterable. + :rtype: list + """ + if attr is None: + return None + if isinstance(attr, ET.Element): # If I receive an element here, get the children + attr = list(attr) + if not isinstance(attr, (list, set)): + raise DeserializationError("Cannot deserialize as [{}] an object of type {}".format( + iter_type, + type(attr) + )) + return [self.deserialize_data(a, iter_type) for a in attr] + + def deserialize_dict(self, attr, dict_type): + """Deserialize a dictionary. + + :param dict/list attr: Dictionary to be deserialized. Also accepts + a list of key, value pairs. + :param str dict_type: The object type of the items in the dictionary. + :rtype: dict + """ + if isinstance(attr, list): + return {x['key']: self.deserialize_data(x['value'], dict_type) for x in attr} + + if isinstance(attr, ET.Element): + # Transform value into {"Key": "value"} + attr = {el.tag: el.text for el in attr} + return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} + + def deserialize_object(self, attr, **kwargs): + """Deserialize a generic object. + This will be handled as a dictionary. + + :param dict attr: Dictionary to be deserialized. + :rtype: dict + :raises: TypeError if non-builtin datatype encountered. + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + # Do no recurse on XML, just return the tree as-is + return attr + if isinstance(attr, basestring): + return self.deserialize_basic(attr, 'str') + obj_type = type(attr) + if obj_type in self.basic_types: + return self.deserialize_basic(attr, self.basic_types[obj_type]) + if obj_type is _long_type: + return self.deserialize_long(attr) + + if obj_type == dict: + deserialized = {} + for key, value in attr.items(): + try: + deserialized[key] = self.deserialize_object( + value, **kwargs) + except ValueError: + deserialized[key] = None + return deserialized + + if obj_type == list: + deserialized = [] + for obj in attr: + try: + deserialized.append(self.deserialize_object( + obj, **kwargs)) + except ValueError: + pass + return deserialized + + else: + error = "Cannot deserialize generic object with type: " + raise TypeError(error + str(obj_type)) + + def deserialize_basic(self, attr, data_type): + """Deserialize basic builtin data type from string. + Will attempt to convert to str, int, float and bool. + This function will also accept '1', '0', 'true' and 'false' as + valid bool values. + + :param str attr: response string to be deserialized. + :param str data_type: deserialization data type. + :rtype: str, int, float or bool + :raises: TypeError if string format is not valid. + """ + # If we're here, data is supposed to be a basic type. + # If it's still an XML node, take the text + if isinstance(attr, ET.Element): + attr = attr.text + if not attr: + if data_type == "str": + # None or '', node is empty string. + return '' + else: + # None or '', node with a strong type is None. + # Don't try to model "empty bool" or "empty int" + return None + + if data_type == 'bool': + if attr in [True, False, 1, 0]: + return bool(attr) + elif isinstance(attr, basestring): + if attr.lower() in ['true', '1']: + return True + elif attr.lower() in ['false', '0']: + return False + raise TypeError("Invalid boolean value: {}".format(attr)) + + if data_type == 'str': + return self.deserialize_unicode(attr) + return eval(data_type)(attr) # nosec + + @staticmethod + def deserialize_unicode(data): + """Preserve unicode objects in Python 2, otherwise return data + as a string. + + :param str data: response string to be deserialized. + :rtype: str or unicode + """ + # We might be here because we have an enum modeled as string, + # and we try to deserialize a partial dict with enum inside + if isinstance(data, Enum): + return data + + # Consider this is real string + try: + if isinstance(data, unicode): + return data + except NameError: + return str(data) + else: + return str(data) + + @staticmethod + def deserialize_enum(data, enum_obj): + """Deserialize string into enum object. + + If the string is not a valid enum value it will be returned as-is + and a warning will be logged. + + :param str data: Response string to be deserialized. If this value is + None or invalid it will be returned as-is. + :param Enum enum_obj: Enum object to deserialize to. + :rtype: Enum + """ + if isinstance(data, enum_obj) or data is None: + return data + if isinstance(data, Enum): + data = data.value + if isinstance(data, int): + # Workaround. We might consider remove it in the future. + # https://github.com/Azure/azure-rest-api-specs/issues/141 + try: + return list(enum_obj.__members__.values())[data] + except IndexError: + error = "{!r} is not a valid index for enum {!r}" + raise DeserializationError(error.format(data, enum_obj)) + try: + return enum_obj(str(data)) + except ValueError: + for enum_value in enum_obj: + if enum_value.value.lower() == str(data).lower(): + return enum_value + # We don't fail anymore for unknown value, we deserialize as a string + _LOGGER.warning("Deserializer is not able to find %s as valid enum in %s", data, enum_obj) + return Deserializer.deserialize_unicode(data) + + @staticmethod + def deserialize_bytearray(attr): + """Deserialize string into bytearray. + + :param str attr: response string to be deserialized. + :rtype: bytearray + :raises: TypeError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return bytearray(b64decode(attr)) + + @staticmethod + def deserialize_base64(attr): + """Deserialize base64 encoded string into string. + + :param str attr: response string to be deserialized. + :rtype: bytearray + :raises: TypeError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + padding = '=' * (3 - (len(attr) + 3) % 4) + attr = attr + padding + encoded = attr.replace('-', '+').replace('_', '/') + return b64decode(encoded) + + @staticmethod + def deserialize_decimal(attr): + """Deserialize string into Decimal object. + + :param str attr: response string to be deserialized. + :rtype: Decimal + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + return decimal.Decimal(attr) + except decimal.DecimalException as err: + msg = "Invalid decimal {}".format(attr) + raise_with_traceback(DeserializationError, msg, err) + + @staticmethod + def deserialize_long(attr): + """Deserialize string into long (Py2) or int (Py3). + + :param str attr: response string to be deserialized. + :rtype: long or int + :raises: ValueError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return _long_type(attr) + + @staticmethod + def deserialize_duration(attr): + """Deserialize ISO-8601 formatted string into TimeDelta object. + + :param str attr: response string to be deserialized. + :rtype: TimeDelta + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + duration = isodate.parse_duration(attr) + except(ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize duration object." + raise_with_traceback(DeserializationError, msg, err) + else: + return duration + + @staticmethod + def deserialize_date(attr): + """Deserialize ISO-8601 formatted string into Date object. + + :param str attr: response string to be deserialized. + :rtype: Date + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): + raise DeserializationError("Date must have only digits and -. Received: %s" % attr) + # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. + return isodate.parse_date(attr, defaultmonth=None, defaultday=None) + + @staticmethod + def deserialize_time(attr): + """Deserialize ISO-8601 formatted string into time object. + + :param str attr: response string to be deserialized. + :rtype: datetime.time + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): + raise DeserializationError("Date must have only digits and -. Received: %s" % attr) + return isodate.parse_time(attr) + + @staticmethod + def deserialize_rfc(attr): + """Deserialize RFC-1123 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: Datetime + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + parsed_date = email.utils.parsedate_tz(attr) + date_obj = datetime.datetime( + *parsed_date[:6], + tzinfo=_FixedOffset(datetime.timedelta(minutes=(parsed_date[9] or 0)/60)) + ) + if not date_obj.tzinfo: + date_obj = date_obj.astimezone(tz=TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to rfc datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj + + @staticmethod + def deserialize_iso(attr): + """Deserialize ISO-8601 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: Datetime + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + attr = attr.upper() + match = Deserializer.valid_date.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + check_decimal = attr.split('.') + if len(check_decimal) > 1: + decimal_str = "" + for digit in check_decimal[1]: + if digit.isdigit(): + decimal_str += digit + else: + break + if len(decimal_str) > 6: + attr = attr.replace(decimal_str, decimal_str[0:6]) + + date_obj = isodate.parse_datetime(attr) + test_utc = date_obj.utctimetuple() + if test_utc.tm_year > 9999 or test_utc.tm_year < 1: + raise OverflowError("Hit max or min date") + except(ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj + + @staticmethod + def deserialize_unix(attr): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param int attr: Object to be serialized. + :rtype: Datetime + :raises: DeserializationError if format invalid + """ + if isinstance(attr, ET.Element): + attr = int(attr.text) + try: + date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to unix datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj diff --git a/sdk/servicebus/azure-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 e19cd082a6e3..1f158fb00017 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 @@ -9,20 +9,17 @@ # regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING - -from msrest import Deserializer, Serializer +from typing import Any, Optional, TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin from ._configuration import ServiceBusManagementClientConfiguration +from ._serialization import Deserializer, Serializer if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - from azure.core.credentials import TokenCredential class _SDKClient(object): @@ -43,9 +40,9 @@ class ServiceBusManagementClient(MultiApiClientMixin, _SDKClient): The api-version parameter sets the default API version if the operation group is not described in the profile. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :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. Required. :type subscription_id: str :param api_version: API version to use if no profile is provided, or if missing in profile. :type api_version: str @@ -70,10 +67,10 @@ class ServiceBusManagementClient(MultiApiClientMixin, _SDKClient): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str + credential: "TokenCredential", + subscription_id: str, api_version=None, # type: Optional[str] - base_url="https://management.azure.com", # type: str + base_url: str = "https://management.azure.com", profile=KnownProfiles.default, # type: KnownProfiles **kwargs # type: Any ): diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/_version.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/_version.py index 920456322fa1..9f1dc6e309ba 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/_version.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "8.1.0" +VERSION = "0.0.0 (it should be stable)" 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 d5711226f3eb..76ce72719cc2 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 @@ -26,9 +26,9 @@ class ServiceBusManagementClientConfiguration(Configuration): Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :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. Required. :type subscription_id: str """ 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 36bf80f71f2e..4651c9553c54 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,17 +11,15 @@ from typing import Any, Optional, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.mgmt.core import AsyncARMPipelineClient from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin +from .._serialization 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): @@ -42,9 +40,9 @@ class ServiceBusManagementClient(MultiApiClientMixin, _SDKClient): The api-version parameter sets the default API version if the operation group is not described in the profile. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :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. Required. :type subscription_id: str :param api_version: API version to use if no profile is provided, or if missing in profile. :type api_version: str 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 221541a00fb6..2a82b6cb6f69 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 @@ -17,7 +17,8 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['ServiceBusManagementClient'] + +__all__ = ["ServiceBusManagementClient"] __all__.extend([p for p in _patch_all if p not in __all__]) _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 ad9251b95ca2..26aa08da5bb8 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 @@ -25,24 +25,19 @@ class ServiceBusManagementClientConfiguration(Configuration): # pylint: disable Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :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. + subscription. The subscription ID forms part of the URI for every service call. Required. :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: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(ServiceBusManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2015-08-01") # type: str + api_version = kwargs.pop("api_version", "2015-08-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -52,23 +47,24 @@ def __init__( self.credential = credential self.subscription_id = subscription_id 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.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-servicebus/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> None - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(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 fa76a032b89e..5bf62ff6c42d 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 @@ -10,20 +10,20 @@ "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\"], \"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\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ServiceBusManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ServiceBusManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", + "signature": "subscription_id: str,", + "description": "Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", + "description": "Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false 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 index 0ad201a8c586..f7dd32510333 100644 --- 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 @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. 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 5cf4dd237f60..bdccbda0b8cf 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 @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import ServiceBusManagementClientConfiguration from .operations import NamespacesOperations, Operations, QueuesOperations, SubscriptionsOperations, TopicsOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ServiceBusManagementClient: + +class ServiceBusManagementClient: # pylint: disable=client-accepts-api-version-keyword """Azure Service Bus client. :ivar operations: Operations operations @@ -35,10 +35,10 @@ class ServiceBusManagementClient: :vartype topics: azure.mgmt.servicebus.v2015_08_01.operations.TopicsOperations :ivar subscriptions: SubscriptionsOperations operations :vartype subscriptions: azure.mgmt.servicebus.v2015_08_01.operations.SubscriptionsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :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. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -56,35 +56,22 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ServiceBusManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + 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._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, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -93,7 +80,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest 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 index 138f663c53a4..9aad73fc743e 100644 --- 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 @@ -7,6 +7,7 @@ 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) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): 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 - ] + 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 920456322fa1..9f1dc6e309ba 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 = "8.1.0" +VERSION = "0.0.0 (it should be stable)" 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 e7dd87df1f93..ba757410f14a 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 @@ -14,7 +14,8 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['ServiceBusManagementClient'] + +__all__ = ["ServiceBusManagementClient"] __all__.extend([p for p in _patch_all if p not in __all__]) _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 ac7564916ab6..f24858ac6aa0 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 @@ -25,24 +25,19 @@ class ServiceBusManagementClientConfiguration(Configuration): # pylint: disable Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :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. + subscription. The subscription ID forms part of the URI for every service call. Required. :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: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(ServiceBusManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2015-08-01") # type: str + api_version = kwargs.pop("api_version", "2015-08-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -52,22 +47,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id 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.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-servicebus/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, - **kwargs: Any - ) -> None: - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(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 index 0ad201a8c586..f7dd32510333 100644 --- 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 @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. 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 d825e42c9329..e5a222a1c88a 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 @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import ServiceBusManagementClientConfiguration from .operations import NamespacesOperations, Operations, QueuesOperations, SubscriptionsOperations, TopicsOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ServiceBusManagementClient: + +class ServiceBusManagementClient: # pylint: disable=client-accepts-api-version-keyword """Azure Service Bus client. :ivar operations: Operations operations @@ -36,10 +36,10 @@ class ServiceBusManagementClient: :ivar subscriptions: SubscriptionsOperations operations :vartype subscriptions: azure.mgmt.servicebus.v2015_08_01.aio.operations.SubscriptionsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :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. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -57,35 +57,22 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ServiceBusManagementClientConfiguration(credential=credential, subscription_id=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._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, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -94,7 +81,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/operations/__init__.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/operations/__init__.py index b0ee9242d985..f1dc4a3596b4 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/operations/__init__.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/operations/__init__.py @@ -15,12 +15,13 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'NamespacesOperations', - 'QueuesOperations', - 'TopicsOperations', - 'SubscriptionsOperations', + "Operations", + "NamespacesOperations", + "QueuesOperations", + "TopicsOperations", + "SubscriptionsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() 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 60aa3a847eaa..d33c5701eaf6 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 @@ -6,10 +6,17 @@ # 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, Optional, TypeVar, Union, cast +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +29,26 @@ 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') +from ...operations._namespaces_operations import ( + build_check_name_availability_request, + 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_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]] + class NamespacesOperations: """ .. warning:: @@ -45,42 +68,82 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @overload + async def check_name_availability( + self, parameters: _models.CheckNameAvailability, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param parameters: Parameters to check availability of the given namespace name. Required. + :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.CheckNameAvailability + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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.v2015_08_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param parameters: Parameters to check availability of the given namespace name. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :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.v2015_08_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def check_name_availability( - self, - parameters: _models.CheckNameAvailability, - **kwargs: Any + self, parameters: Union[_models.CheckNameAvailability, IO], **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Check the give namespace name availability. - :param parameters: Parameters to check availability of the given namespace name. - :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.CheckNameAvailability + :param parameters: Parameters to check availability of the given namespace name. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.CheckNameAvailability or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameAvailabilityResult, or the result of cls(response) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResult] - _json = self._serialize.body(parameters, 'CheckNameAvailability') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _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'], + content=_content, + template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) @@ -88,56 +151,50 @@ async def check_name_availability( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + 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 - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> AsyncIterable[_models.NamespaceListResult]: + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.NamespaceResource"]: """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) + :return: An iterator like instance of either NamespaceResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.NamespaceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.NamespaceResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.NamespaceListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription.metadata['url'], + template_url=self.list_by_subscription.metadata["url"], headers=_headers, params=_params, ) @@ -145,14 +202,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -168,10 +222,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -181,46 +233,41 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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, - **kwargs: Any - ) -> AsyncIterable[_models.NamespaceListResult]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.NamespaceResource"]: """Gets the available namespaces within a resource group. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :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) + :return: An iterator like instance of either NamespaceResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.NamespaceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.NamespaceResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.NamespaceListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -228,15 +275,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -252,10 +295,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -265,41 +306,44 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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, resource_group_name: str, namespace_name: str, - parameters: _models.NamespaceCreateOrUpdateParameters, + parameters: Union[_models.NamespaceCreateOrUpdateParameters, IO], **kwargs: Any ) -> Optional[_models.NamespaceResource]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.NamespaceResource]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.NamespaceResource]] - _json = self._serialize.body(parameters, 'NamespaceCreateOrUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "NamespaceCreateOrUpdateParameters") - request = build_create_or_update_request_initial( + request = build_create_or_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._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) @@ -307,10 +351,9 @@ async def _create_or_update_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -319,36 +362,114 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('NamespaceResource', pipeline_response) + deserialized = self._deserialize("NamespaceResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('NamespaceResource', pipeline_response) + deserialized = self._deserialize("NamespaceResource", 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 + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + namespace_name: str, + parameters: _models.NamespaceCreateOrUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.NamespaceResource]: + """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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to create a namespace resource. Required. + :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.NamespaceCreateOrUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. + :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: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.NamespaceResource]: + """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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to create a namespace resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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: + """ @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, namespace_name: str, - parameters: _models.NamespaceCreateOrUpdateParameters, + parameters: Union[_models.NamespaceCreateOrUpdateParameters, IO], **kwargs: Any ) -> AsyncLROPoller[_models.NamespaceResource]: """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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters supplied to create a namespace resource. + :param parameters: Parameters supplied to create a namespace resource. Is either a model type + or a IO type. Required. :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.NamespaceCreateOrUpdateParameters + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -361,20 +482,17 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicebus.v2015_08_01.models.NamespaceResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.NamespaceResource] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.NamespaceResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + 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( # type: ignore resource_group_name=resource_group_name, @@ -382,64 +500,54 @@ async def begin_create_or_update( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('NamespaceResource', pipeline_response) + deserialized = self._deserialize("NamespaceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, 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 + deserialization_callback=get_long_running_output, ) 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 + 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, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_request_initial( + request = build_delete_request( 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'], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) @@ -447,10 +555,9 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -460,22 +567,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements 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 @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete(self, resource_group_name: str, namespace_name: str, **kwargs: Any) -> 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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. @@ -487,92 +588,77 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + 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( # type: ignore resource_group_name=resource_group_name, namespace_name=namespace_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, 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 + deserialization_callback=get_long_running_output, ) 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 + 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, - namespace_name: str, - **kwargs: Any - ) -> _models.NamespaceResource: + async def get(self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: NamespaceResource, or the result of cls(response) + :return: NamespaceResource or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.NamespaceResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.NamespaceResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.NamespaceResource] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -580,61 +666,123 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('NamespaceResource', pipeline_response) + deserialized = self._deserialize("NamespaceResource", 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 - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - @distributed_trace_async + @overload async def update( self, resource_group_name: str, namespace_name: str, parameters: _models.NamespaceUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> Optional[_models.NamespaceResource]: """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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters supplied to update a namespace resource. + :param parameters: Parameters supplied to update a namespace resource. Required. :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.NamespaceUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: NamespaceResource or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.NamespaceResource or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Optional[_models.NamespaceResource]: + """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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to update a namespace resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: NamespaceResource or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.NamespaceResource or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + namespace_name: str, + parameters: Union[_models.NamespaceUpdateParameters, IO], + **kwargs: Any + ) -> Optional[_models.NamespaceResource]: + """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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to update a namespace resource. Is either a model type + or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.NamespaceUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: NamespaceResource, or the result of cls(response) + :return: NamespaceResource or None or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.NamespaceResource or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.NamespaceResource]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.NamespaceResource]] - _json = self._serialize.body(parameters, 'NamespaceUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "NamespaceUpdateParameters") request = build_update_request( resource_group_name=resource_group_name, @@ -643,7 +791,8 @@ async def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -651,10 +800,9 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -663,58 +811,53 @@ async def update( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('NamespaceResource', pipeline_response) + deserialized = self._deserialize("NamespaceResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('NamespaceResource', pipeline_response) + deserialized = self._deserialize("NamespaceResource", 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 - + 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, - namespace_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.SharedAccessAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SharedAccessAuthorizationRuleResource"]: """Gets the authorization rules for a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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 + :return: An iterator like instance of either SharedAccessAuthorizationRuleResource 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 + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedAccessAuthorizationRuleListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) @@ -722,16 +865,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -747,10 +885,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -760,50 +896,118 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 + @overload async def create_or_update_authorization_rule( self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, parameters: _models.SharedAccessAuthorizationRuleCreateOrUpdateParameters, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleCreateOrUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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 + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SharedAccessAuthorizationRuleResource, or the result of cls(response) + :return: SharedAccessAuthorizationRuleResource or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace_async + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: Union[_models.SharedAccessAuthorizationRuleCreateOrUpdateParameters, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: + ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleCreateOrUpdateParameters + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :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 + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedAccessAuthorizationRuleResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessAuthorizationRuleResource] - _json = self._serialize.body(parameters, 'SharedAccessAuthorizationRuleCreateOrUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SharedAccessAuthorizationRuleCreateOrUpdateParameters") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -813,7 +1017,8 @@ async def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -821,66 +1026,57 @@ async def create_or_update_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SharedAccessAuthorizationRuleResource', pipeline_response) + deserialized = self._deserialize("SharedAccessAuthorizationRuleResource", 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 - + 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, - authorization_rule_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -888,10 +1084,9 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -901,49 +1096,41 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat 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, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SharedAccessAuthorizationRuleResource, or the result of cls(response) + :return: SharedAccessAuthorizationRuleResource or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedAccessAuthorizationRuleResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessAuthorizationRuleResource] - 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'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -951,66 +1138,57 @@ async def get_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SharedAccessAuthorizationRuleResource', pipeline_response) + deserialized = self._deserialize("SharedAccessAuthorizationRuleResource", 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 - + 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, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceListKeys, or the result of cls(response) + :return: ResourceListKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.ResourceListKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ResourceListKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListKeys] - 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'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1018,63 +1196,129 @@ async def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceListKeys', pipeline_response) + deserialized = self._deserialize("ResourceListKeys", 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 + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys"} # type: ignore - - @distributed_trace_async + @overload async def regenerate_keys( self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, parameters: _models.RegenerateKeysParameters, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.RegenerateKeysParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceListKeys, or the result of cls(response) + :return: ResourceListKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.ResourceListKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceListKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.ResourceListKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateKeysParameters, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.RegenerateKeysParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceListKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.ResourceListKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ResourceListKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListKeys] - _json = self._serialize.body(parameters, 'RegenerateKeysParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateKeysParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -1084,7 +1328,8 @@ async def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1092,22 +1337,20 @@ async def regenerate_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceListKeys', pipeline_response) + deserialized = self._deserialize("ResourceListKeys", 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 - + 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 94a1178bd32f..3dad5e4f038a 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 @@ -7,9 +7,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +27,11 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class Operations: """ .. warning:: @@ -42,36 +51,31 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.OperationListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """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) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -79,13 +83,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -101,10 +103,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -114,8 +114,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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/_patch.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/operations/_patch.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/aio/operations/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. 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 2d121cca8b22..3d868d8875d1 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 @@ -6,10 +6,17 @@ # 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, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +27,24 @@ 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') +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]] + class QueuesOperations: """ .. warning:: @@ -43,45 +64,40 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_all( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.QueueListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.QueueResource"]: """Gets the queues within a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: An iterator like instance of either QueueResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.QueueListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.QueueResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.QueueListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_all.metadata["url"], headers=_headers, params=_params, ) @@ -89,16 +105,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -114,10 +125,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -127,49 +136,115 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 + @overload async def create_or_update( self, resource_group_name: str, namespace_name: str, queue_name: str, parameters: _models.QueueCreateOrUpdateParameters, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param parameters: Parameters supplied to create or update a queue resource. + :param parameters: Parameters supplied to create or update a queue resource. Required. :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.QueueCreateOrUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: QueueResource or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.QueueResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param parameters: Parameters supplied to create or update a queue resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: QueueResource, or the result of cls(response) + :return: QueueResource or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.QueueResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + parameters: Union[_models.QueueCreateOrUpdateParameters, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param parameters: Parameters supplied to create or update a queue resource. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.QueueCreateOrUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: QueueResource or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.QueueResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.QueueResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.QueueResource] - _json = self._serialize.body(parameters, 'QueueCreateOrUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "QueueCreateOrUpdateParameters") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -179,7 +254,8 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -187,66 +263,57 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('QueueResource', pipeline_response) + deserialized = self._deserialize("QueueResource", 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 - + 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, - queue_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -254,10 +321,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -267,49 +333,41 @@ async def delete( # pylint: disable=inconsistent-return-statements 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, - namespace_name: str, - queue_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: QueueResource, or the result of cls(response) + :return: QueueResource or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.QueueResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.QueueResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.QueueResource] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -317,69 +375,62 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('QueueResource', pipeline_response) + deserialized = self._deserialize("QueueResource", 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 - + 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, - namespace_name: str, - queue_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.SharedAccessAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, queue_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SharedAccessAuthorizationRuleResource"]: """Gets all authorization rules for a queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :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 + :return: An iterator like instance of either SharedAccessAuthorizationRuleResource 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 + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedAccessAuthorizationRuleListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) @@ -387,17 +438,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -413,10 +458,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -426,13 +469,11 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 + @overload async def create_or_update_authorization_rule( self, resource_group_name: str, @@ -440,39 +481,115 @@ async def create_or_update_authorization_rule( queue_name: str, authorization_rule_name: str, parameters: _models.SharedAccessAuthorizationRuleCreateOrUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SharedAccessAuthorizationRuleResource: + """Creates an authorization rule for a queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type parameters: + ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleCreateOrUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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 + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SharedAccessAuthorizationRuleResource: + """Creates an authorization rule for a queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :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 + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: Union[_models.SharedAccessAuthorizationRuleCreateOrUpdateParameters, IO], **kwargs: Any ) -> _models.SharedAccessAuthorizationRuleResource: """Creates an authorization rule for a queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleCreateOrUpdateParameters + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SharedAccessAuthorizationRuleResource, or the result of cls(response) + :return: SharedAccessAuthorizationRuleResource or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedAccessAuthorizationRuleResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessAuthorizationRuleResource] - _json = self._serialize.body(parameters, 'SharedAccessAuthorizationRuleCreateOrUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SharedAccessAuthorizationRuleCreateOrUpdateParameters") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -483,7 +600,8 @@ async def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -491,25 +609,23 @@ async def create_or_update_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SharedAccessAuthorizationRuleResource', pipeline_response) + deserialized = self._deserialize("SharedAccessAuthorizationRuleResource", 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 - + 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( @@ -522,31 +638,28 @@ async def post_authorization_rule( ) -> _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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SharedAccessAuthorizationRuleResource, or the result of cls(response) + :return: SharedAccessAuthorizationRuleResource or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedAccessAuthorizationRuleResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessAuthorizationRuleResource] - request = build_post_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -554,7 +667,7 @@ async def post_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.post_authorization_rule.metadata['url'], + template_url=self.post_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -562,25 +675,23 @@ async def post_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SharedAccessAuthorizationRuleResource', pipeline_response) + deserialized = self._deserialize("SharedAccessAuthorizationRuleResource", pipeline_response) if cls: 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 - + 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 @@ -593,31 +704,28 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat ) -> None: """Deletes a queue authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -625,7 +733,7 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_authorization_rule.metadata['url'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -633,10 +741,9 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -646,8 +753,7 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat 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( @@ -660,31 +766,28 @@ async def get_authorization_rule( ) -> _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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SharedAccessAuthorizationRuleResource, or the result of cls(response) + :return: SharedAccessAuthorizationRuleResource or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedAccessAuthorizationRuleResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessAuthorizationRuleResource] - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -692,7 +795,7 @@ async def get_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -700,25 +803,23 @@ async def get_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SharedAccessAuthorizationRuleResource', pipeline_response) + deserialized = self._deserialize("SharedAccessAuthorizationRuleResource", 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 - + 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( @@ -731,31 +832,28 @@ async def list_keys( ) -> _models.ResourceListKeys: """Primary and secondary connection strings to the queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceListKeys, or the result of cls(response) + :return: ResourceListKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.ResourceListKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ResourceListKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListKeys] - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -763,7 +861,7 @@ async def list_keys( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -771,27 +869,25 @@ async def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceListKeys', pipeline_response) + deserialized = self._deserialize("ResourceListKeys", 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 - + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore - @distributed_trace_async + @overload async def regenerate_keys( self, resource_group_name: str, @@ -799,38 +895,112 @@ async def regenerate_keys( queue_name: str, authorization_rule_name: str, parameters: _models.RegenerateKeysParameters, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.RegenerateKeysParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceListKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.ResourceListKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceListKeys, or the result of cls(response) + :return: ResourceListKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.ResourceListKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace_async + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateKeysParameters, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.RegenerateKeysParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceListKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.ResourceListKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ResourceListKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListKeys] - _json = self._serialize.body(parameters, 'RegenerateKeysParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateKeysParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -841,7 +1011,8 @@ async def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) @@ -849,22 +1020,20 @@ async def regenerate_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceListKeys', pipeline_response) + deserialized = self._deserialize("ResourceListKeys", 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 - + 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 466a3e2d1a2d..1fce4ade8b44 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 @@ -6,10 +6,17 @@ # 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, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +27,17 @@ 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') +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]] + class SubscriptionsOperations: """ .. warning:: @@ -43,50 +57,44 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_all( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.SubscriptionListResult]: + self, resource_group_name: str, namespace_name: str, topic_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SubscriptionResource"]: """List all the subscriptions under a specified topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :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 + :return: An iterator like instance of either SubscriptionResource 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 + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.SubscriptionResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SubscriptionListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_all.metadata["url"], headers=_headers, params=_params, ) @@ -94,17 +102,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -120,10 +122,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -133,13 +133,11 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 + @overload async def create_or_update( self, resource_group_name: str, @@ -147,39 +145,114 @@ async def create_or_update( topic_name: str, subscription_name: str, parameters: _models.SubscriptionCreateOrUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SubscriptionResource: """Creates a topic subscription. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param parameters: Parameters supplied to create a subscription resource. + :param parameters: Parameters supplied to create a subscription resource. Required. :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.SubscriptionCreateOrUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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 + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SubscriptionResource: + """Creates a topic subscription. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param parameters: Parameters supplied to create a subscription resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SubscriptionResource, or the result of cls(response) + :return: SubscriptionResource or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.SubscriptionResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + parameters: Union[_models.SubscriptionCreateOrUpdateParameters, IO], + **kwargs: Any + ) -> _models.SubscriptionResource: + """Creates a topic subscription. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param parameters: Parameters supplied to create a subscription resource. Is either a model + type or a IO type. Required. + :type parameters: + ~azure.mgmt.servicebus.v2015_08_01.models.SubscriptionCreateOrUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :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 + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SubscriptionResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SubscriptionResource] - _json = self._serialize.body(parameters, 'SubscriptionCreateOrUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SubscriptionCreateOrUpdateParameters") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -190,7 +263,8 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -198,62 +272,52 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SubscriptionResource', pipeline_response) + deserialized = self._deserialize("SubscriptionResource", 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 - + 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, - topic_name: str, - subscription_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -261,7 +325,7 @@ async def delete( # pylint: disable=inconsistent-return-statements subscription_name=subscription_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -269,10 +333,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -282,45 +345,36 @@ async def delete( # pylint: disable=inconsistent-return-statements 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, - namespace_name: str, - topic_name: str, - subscription_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SubscriptionResource, or the result of cls(response) + :return: SubscriptionResource or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.SubscriptionResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SubscriptionResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SubscriptionResource] - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -328,7 +382,7 @@ async def get( subscription_name=subscription_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -336,22 +390,20 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SubscriptionResource', pipeline_response) + deserialized = self._deserialize("SubscriptionResource", 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 - + 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 13690278409c..bc42d3e92895 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 @@ -6,10 +6,17 @@ # 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, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +27,24 @@ 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') +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]] + class TopicsOperations: """ .. warning:: @@ -43,45 +64,40 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_all( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.TopicListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.TopicResource"]: """Gets all the topics in a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: An iterator like instance of either TopicResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.TopicListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.TopicResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.TopicListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_all.metadata["url"], headers=_headers, params=_params, ) @@ -89,16 +105,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -114,10 +125,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -127,49 +136,115 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 + @overload async def create_or_update( self, resource_group_name: str, namespace_name: str, topic_name: str, parameters: _models.TopicCreateOrUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.TopicResource: """Creates a topic in the specified namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param parameters: Parameters supplied to create a topic resource. + :param parameters: Parameters supplied to create a topic resource. Required. :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.TopicCreateOrUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TopicResource or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.TopicResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TopicResource: + """Creates a topic in the specified namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param parameters: Parameters supplied to create a topic resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TopicResource, or the result of cls(response) + :return: TopicResource or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.TopicResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + parameters: Union[_models.TopicCreateOrUpdateParameters, IO], + **kwargs: Any + ) -> _models.TopicResource: + """Creates a topic in the specified namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param parameters: Parameters supplied to create a topic resource. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.TopicCreateOrUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TopicResource or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.TopicResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.TopicResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TopicResource] - _json = self._serialize.body(parameters, 'TopicCreateOrUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TopicCreateOrUpdateParameters") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -179,7 +254,8 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -187,66 +263,57 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TopicResource', pipeline_response) + deserialized = self._deserialize("TopicResource", 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 - + 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, - topic_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -254,10 +321,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -267,49 +333,41 @@ async def delete( # pylint: disable=inconsistent-return-statements 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, - namespace_name: str, - topic_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TopicResource, or the result of cls(response) + :return: TopicResource or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.TopicResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.TopicResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TopicResource] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -317,69 +375,62 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TopicResource', pipeline_response) + deserialized = self._deserialize("TopicResource", 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 - + 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, - namespace_name: str, - topic_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.SharedAccessAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, topic_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SharedAccessAuthorizationRuleResource"]: """Gets authorization rules for a topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :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 + :return: An iterator like instance of either SharedAccessAuthorizationRuleResource 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 + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedAccessAuthorizationRuleListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) @@ -387,17 +438,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -413,10 +458,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -426,13 +469,11 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 + @overload async def create_or_update_authorization_rule( self, resource_group_name: str, @@ -440,39 +481,115 @@ async def create_or_update_authorization_rule( topic_name: str, authorization_rule_name: str, parameters: _models.SharedAccessAuthorizationRuleCreateOrUpdateParameters, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type parameters: + ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleCreateOrUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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 + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :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 + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: Union[_models.SharedAccessAuthorizationRuleCreateOrUpdateParameters, IO], **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleCreateOrUpdateParameters + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SharedAccessAuthorizationRuleResource, or the result of cls(response) + :return: SharedAccessAuthorizationRuleResource or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedAccessAuthorizationRuleResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessAuthorizationRuleResource] - _json = self._serialize.body(parameters, 'SharedAccessAuthorizationRuleCreateOrUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SharedAccessAuthorizationRuleCreateOrUpdateParameters") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -483,7 +600,8 @@ async def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -491,25 +609,23 @@ async def create_or_update_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SharedAccessAuthorizationRuleResource', pipeline_response) + deserialized = self._deserialize("SharedAccessAuthorizationRuleResource", 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 - + 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( @@ -522,31 +638,28 @@ async def post_authorization_rule( ) -> _models.SharedAccessAuthorizationRuleResource: """Returns the specified authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SharedAccessAuthorizationRuleResource, or the result of cls(response) + :return: SharedAccessAuthorizationRuleResource or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedAccessAuthorizationRuleResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessAuthorizationRuleResource] - request = build_post_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -554,7 +667,7 @@ async def post_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.post_authorization_rule.metadata['url'], + template_url=self.post_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -562,25 +675,23 @@ async def post_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SharedAccessAuthorizationRuleResource', pipeline_response) + deserialized = self._deserialize("SharedAccessAuthorizationRuleResource", pipeline_response) if cls: 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( @@ -593,31 +704,28 @@ async def get_authorization_rule( ) -> _models.SharedAccessAuthorizationRuleResource: """Returns the specified authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SharedAccessAuthorizationRuleResource, or the result of cls(response) + :return: SharedAccessAuthorizationRuleResource or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedAccessAuthorizationRuleResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessAuthorizationRuleResource] - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -625,7 +733,7 @@ async def get_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -633,25 +741,23 @@ async def get_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SharedAccessAuthorizationRuleResource', pipeline_response) + deserialized = self._deserialize("SharedAccessAuthorizationRuleResource", 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 - + 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 @@ -664,31 +770,28 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat ) -> None: """Deletes a topic authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -696,7 +799,7 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_authorization_rule.metadata['url'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -704,10 +807,9 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -717,8 +819,7 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat 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( @@ -731,31 +832,28 @@ async def list_keys( ) -> _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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceListKeys, or the result of cls(response) + :return: ResourceListKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.ResourceListKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ResourceListKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListKeys] - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -763,7 +861,7 @@ async def list_keys( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -771,27 +869,25 @@ async def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceListKeys', pipeline_response) + deserialized = self._deserialize("ResourceListKeys", 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 - + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore - @distributed_trace_async + @overload async def regenerate_keys( self, resource_group_name: str, @@ -799,38 +895,112 @@ async def regenerate_keys( topic_name: str, authorization_rule_name: str, parameters: _models.RegenerateKeysParameters, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.RegenerateKeysParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceListKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.ResourceListKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceListKeys, or the result of cls(response) + :return: ResourceListKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.ResourceListKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace_async + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateKeysParameters, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.RegenerateKeysParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceListKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.ResourceListKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ResourceListKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListKeys] - _json = self._serialize.body(parameters, 'RegenerateKeysParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateKeysParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -841,7 +1011,8 @@ async def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) @@ -849,22 +1020,20 @@ async def regenerate_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceListKeys', pipeline_response) + deserialized = self._deserialize("ResourceListKeys", 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 - + 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 c44dce4e28b6..c195b7ba8a0b 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 @@ -34,56 +34,54 @@ from ._models_py3 import TopicResource from ._models_py3 import TrackedResource - -from ._service_bus_management_client_enums import ( - AccessRights, - EntityAvailabilityStatus, - EntityStatus, - NamespaceState, - Policykey, - SkuName, - SkuTier, - UnavailableReason, -) +from ._service_bus_management_client_enums import AccessRights +from ._service_bus_management_client_enums import EntityAvailabilityStatus +from ._service_bus_management_client_enums import EntityStatus +from ._service_bus_management_client_enums import NamespaceState +from ._service_bus_management_client_enums import Policykey +from ._service_bus_management_client_enums import SkuName +from ._service_bus_management_client_enums import SkuTier +from ._service_bus_management_client_enums import UnavailableReason from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'CheckNameAvailability', - 'CheckNameAvailabilityResult', - 'MessageCountDetails', - 'NamespaceCreateOrUpdateParameters', - 'NamespaceListResult', - 'NamespaceResource', - 'NamespaceUpdateParameters', - 'Operation', - 'OperationDisplay', - 'OperationListResult', - 'QueueCreateOrUpdateParameters', - 'QueueListResult', - 'QueueResource', - 'RegenerateKeysParameters', - 'Resource', - 'ResourceListKeys', - 'SharedAccessAuthorizationRuleCreateOrUpdateParameters', - 'SharedAccessAuthorizationRuleListResult', - 'SharedAccessAuthorizationRuleResource', - 'Sku', - 'SubscriptionCreateOrUpdateParameters', - 'SubscriptionListResult', - 'SubscriptionResource', - 'TopicCreateOrUpdateParameters', - 'TopicListResult', - 'TopicResource', - 'TrackedResource', - 'AccessRights', - 'EntityAvailabilityStatus', - 'EntityStatus', - 'NamespaceState', - 'Policykey', - 'SkuName', - 'SkuTier', - 'UnavailableReason', + "CheckNameAvailability", + "CheckNameAvailabilityResult", + "MessageCountDetails", + "NamespaceCreateOrUpdateParameters", + "NamespaceListResult", + "NamespaceResource", + "NamespaceUpdateParameters", + "Operation", + "OperationDisplay", + "OperationListResult", + "QueueCreateOrUpdateParameters", + "QueueListResult", + "QueueResource", + "RegenerateKeysParameters", + "Resource", + "ResourceListKeys", + "SharedAccessAuthorizationRuleCreateOrUpdateParameters", + "SharedAccessAuthorizationRuleListResult", + "SharedAccessAuthorizationRuleResource", + "Sku", + "SubscriptionCreateOrUpdateParameters", + "SubscriptionListResult", + "SubscriptionResource", + "TopicCreateOrUpdateParameters", + "TopicListResult", + "TopicResource", + "TrackedResource", + "AccessRights", + "EntityAvailabilityStatus", + "EntityStatus", + "NamespaceState", + "Policykey", + "SkuName", + "SkuTier", + "UnavailableReason", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() 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 c418f4487af8..02f6c10354a3 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 @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -8,49 +9,44 @@ from typing import Dict, List, Optional, TYPE_CHECKING, Union -import msrest.serialization +from ... import _serialization if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - import __init__ as _models + from .. import models as _models -class CheckNameAvailability(msrest.serialization.Model): +class CheckNameAvailability(_serialization.Model): """Description of a Check Name availability request properties. All required parameters must be populated in order to send to Azure. - :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. + :ivar name: 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. Required. :vartype name: str """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - name: str, - **kwargs - ): + def __init__(self, *, 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. + :keyword name: 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. Required. :paramtype name: str """ - super(CheckNameAvailability, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class CheckNameAvailabilityResult(msrest.serialization.Model): +class CheckNameAvailabilityResult(_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. @@ -59,7 +55,7 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): available; otherwise, false. :vartype name_available: bool :ivar reason: The reason for unavailability of a namespace. Known values are: "None", - "InvalidName", "SubscriptionIsDisabled", "NameInUse", "NameInLockdown", + "InvalidName", "SubscriptionIsDisabled", "NameInUse", "NameInLockdown", and "TooManyNamespaceInCurrentSubscription". :vartype reason: str or ~azure.mgmt.servicebus.v2015_08_01.models.UnavailableReason :ivar message: The detailed info regarding the reason associated with the namespace. @@ -67,13 +63,13 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): """ _validation = { - 'message': {'readonly': True}, + "message": {"readonly": True}, } _attribute_map = { - 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, - 'reason': {'key': 'reason', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "name_available": {"key": "nameAvailable", "type": "bool"}, + "reason": {"key": "reason", "type": "str"}, + "message": {"key": "message", "type": "str"}, } def __init__( @@ -88,57 +84,53 @@ def __init__( available; otherwise, false. :paramtype name_available: bool :keyword reason: The reason for unavailability of a namespace. Known values are: "None", - "InvalidName", "SubscriptionIsDisabled", "NameInUse", "NameInLockdown", + "InvalidName", "SubscriptionIsDisabled", "NameInUse", "NameInLockdown", and "TooManyNamespaceInCurrentSubscription". :paramtype reason: str or ~azure.mgmt.servicebus.v2015_08_01.models.UnavailableReason """ - super(CheckNameAvailabilityResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.name_available = name_available self.reason = reason self.message = None -class MessageCountDetails(msrest.serialization.Model): +class MessageCountDetails(_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 + :vartype active_message_count: int :ivar dead_letter_message_count: Number of messages that are dead lettered. - :vartype dead_letter_message_count: long + :vartype dead_letter_message_count: int :ivar scheduled_message_count: Number of scheduled messages. - :vartype scheduled_message_count: long + :vartype scheduled_message_count: int :ivar transfer_dead_letter_message_count: Number of messages transferred into dead letters. - :vartype transfer_dead_letter_message_count: long + :vartype transfer_dead_letter_message_count: int :ivar transfer_message_count: Number of messages transferred to another queue, topic, or subscription. - :vartype transfer_message_count: long + :vartype transfer_message_count: int """ _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}, + "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'}, + "active_message_count": {"key": "activeMessageCount", "type": "int"}, + "dead_letter_message_count": {"key": "deadLetterMessageCount", "type": "int"}, + "scheduled_message_count": {"key": "scheduledMessageCount", "type": "int"}, + "transfer_dead_letter_message_count": {"key": "transferDeadLetterMessageCount", "type": "int"}, + "transfer_message_count": {"key": "transferMessageCount", "type": "int"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(MessageCountDetails, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.active_message_count = None self.dead_letter_message_count = None self.scheduled_message_count = None @@ -146,24 +138,24 @@ def __init__( self.transfer_message_count = None -class NamespaceCreateOrUpdateParameters(msrest.serialization.Model): +class NamespaceCreateOrUpdateParameters(_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. - :ivar location: Required. Namespace location. + :ivar location: Namespace location. Required. :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. + :ivar tags: Namespace tags. :vartype tags: dict[str, str] :ivar provisioning_state: Provisioning state of the namespace. :vartype provisioning_state: str :ivar status: State of the namespace. Known values are: "Unknown", "Creating", "Created", "Activating", "Enabling", "Active", "Disabling", "Disabled", "SoftDeleting", "SoftDeleted", - "Removing", "Removed", "Failed". + "Removing", "Removed", and "Failed". :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 @@ -178,24 +170,24 @@ class NamespaceCreateOrUpdateParameters(msrest.serialization.Model): """ _validation = { - 'location': {'required': True}, - 'provisioning_state': {'readonly': True}, - 'created_at': {'readonly': True}, - 'updated_at': {'readonly': True}, - 'service_bus_endpoint': {'readonly': True}, + "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'}, + "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__( @@ -210,22 +202,22 @@ def __init__( **kwargs ): """ - :keyword location: Required. Namespace location. + :keyword location: Namespace location. Required. :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. + :keyword tags: Namespace tags. :paramtype tags: dict[str, str] :keyword status: State of the namespace. Known values are: "Unknown", "Creating", "Created", "Activating", "Enabling", "Active", "Disabling", "Disabled", "SoftDeleting", "SoftDeleted", - "Removing", "Removed", "Failed". + "Removing", "Removed", and "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) + super().__init__(**kwargs) self.location = location self.sku = sku self.tags = tags @@ -238,7 +230,7 @@ def __init__( self.enabled = enabled -class NamespaceListResult(msrest.serialization.Model): +class NamespaceListResult(_serialization.Model): """The response of the List Namespace operation. :ivar value: Result of the List Namespace operation. @@ -249,16 +241,12 @@ class NamespaceListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[NamespaceResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[NamespaceResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.NamespaceResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.NamespaceResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Result of the List Namespace operation. @@ -267,12 +255,12 @@ def __init__( list of Namespaces. :paramtype next_link: str """ - super(NamespaceListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """The Resource definition for other than namespace. Variables are only populated by the server, and will be ignored when sending a request. @@ -288,29 +276,24 @@ class Resource(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "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'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - *, - location: Optional[str] = None, - **kwargs - ): + def __init__(self, *, location: Optional[str] = None, **kwargs): """ :keyword location: Resource location. :paramtype location: str """ - super(Resource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.location = location @@ -330,42 +313,36 @@ class TrackedResource(Resource): :vartype location: str :ivar type: Resource type. :vartype type: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "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}'}, + "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, - *, - location: Optional[str] = None, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs): """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(TrackedResource, self).__init__(location=location, **kwargs) + super().__init__(location=location, **kwargs) self.tags = tags -class NamespaceResource(TrackedResource): +class NamespaceResource(TrackedResource): # pylint: disable=too-many-instance-attributes """Description of a namespace resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -378,7 +355,7 @@ class NamespaceResource(TrackedResource): :vartype location: str :ivar type: Resource type. :vartype type: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar sku: SKU of the namespace. :vartype sku: ~azure.mgmt.servicebus.v2015_08_01.models.Sku @@ -386,7 +363,7 @@ class NamespaceResource(TrackedResource): :vartype provisioning_state: str :ivar status: State of the namespace. Known values are: "Unknown", "Creating", "Created", "Activating", "Enabling", "Active", "Disabling", "Disabled", "SoftDeleting", "SoftDeleted", - "Removing", "Removed", "Failed". + "Removing", "Removed", and "Failed". :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 @@ -401,29 +378,29 @@ class NamespaceResource(TrackedResource): """ _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}, + "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'}, + "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__( @@ -440,20 +417,20 @@ def __init__( """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword 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. Known values are: "Unknown", "Creating", "Created", "Activating", "Enabling", "Active", "Disabling", "Disabled", "SoftDeleting", "SoftDeleted", - "Removing", "Removed", "Failed". + "Removing", "Removed", and "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) + super().__init__(location=location, tags=tags, **kwargs) self.sku = sku self.provisioning_state = None self.status = status @@ -464,39 +441,33 @@ def __init__( self.enabled = enabled -class NamespaceUpdateParameters(msrest.serialization.Model): +class NamespaceUpdateParameters(_serialization.Model): """Parameters supplied to the Patch Namespace operation. - :ivar tags: A set of tags. Resource tags. + :ivar 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 = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, + "tags": {"key": "tags", "type": "{str}"}, + "sku": {"key": "sku", "type": "Sku"}, } - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.Sku"] = None, - **kwargs - ): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, sku: Optional["_models.Sku"] = None, **kwargs): """ - :keyword tags: A set of tags. Resource tags. + :keyword 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) + super().__init__(**kwargs) self.tags = tags self.sku = sku -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """A ServiceBus REST API operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -508,30 +479,25 @@ class Operation(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, + "name": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, } - def __init__( - self, - *, - display: Optional["_models.OperationDisplay"] = None, - **kwargs - ): + def __init__(self, *, display: Optional["_models.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) + super().__init__(**kwargs) self.name = None self.display = display -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """The object that represents the operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -545,30 +511,26 @@ class OperationDisplay(msrest.serialization.Model): """ _validation = { - 'provider': {'readonly': True}, - 'resource': {'readonly': True}, - 'operation': {'readonly': True}, + "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'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(OperationDisplay, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.provider = None self.resource = None self.operation = None -class OperationListResult(msrest.serialization.Model): +class OperationListResult(_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. @@ -581,27 +543,23 @@ class OperationListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(OperationListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class QueueCreateOrUpdateParameters(msrest.serialization.Model): +class QueueCreateOrUpdateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """Parameters supplied to the Create Or Update Queue operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -610,7 +568,7 @@ class QueueCreateOrUpdateParameters(msrest.serialization.Model): :ivar name: Queue name. :vartype name: str - :ivar location: Required. location of the resource. + :ivar location: location of the resource. Required. :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 @@ -623,7 +581,7 @@ class QueueCreateOrUpdateParameters(msrest.serialization.Model): deleted. The minimum duration is 5 minutes. :vartype auto_delete_on_idle: str :ivar entity_availability_status: Entity availability status for the queue. Known values are: - "Available", "Limited", "Renaming", "Restoring", "Unknown". + "Available", "Limited", "Renaming", "Restoring", and "Unknown". :vartype entity_availability_status: str or ~azure.mgmt.servicebus.v2015_08_01.models.EntityAvailabilityStatus :ivar created_at: The exact time the message was created. @@ -655,9 +613,9 @@ class QueueCreateOrUpdateParameters(msrest.serialization.Model): :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. - :vartype max_size_in_megabytes: long + :vartype max_size_in_megabytes: int :ivar message_count: The number of messages in the queue. - :vartype message_count: long + :vartype message_count: int :ivar count_details: Message Count Details. :vartype count_details: ~azure.mgmt.servicebus.v2015_08_01.models.MessageCountDetails :ivar requires_duplicate_detection: A value indicating if this queue requires duplicate @@ -667,10 +625,10 @@ class QueueCreateOrUpdateParameters(msrest.serialization.Model): sessions. :vartype requires_session: bool :ivar size_in_bytes: The size of the queue, in bytes. - :vartype size_in_bytes: long + :vartype size_in_bytes: int :ivar status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Creating", "Deleting", "Disabled", "ReceiveDisabled", "Renaming", "Restoring", - "SendDisabled", "Unknown". + "SendDisabled", and "Unknown". :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 @@ -679,43 +637,46 @@ class QueueCreateOrUpdateParameters(msrest.serialization.Model): """ _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}, + "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'}, + "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": "int"}, + "message_count": {"key": "properties.messageCount", "type": "int"}, + "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": "int"}, + "status": {"key": "properties.status", "type": "str"}, + "support_ordering": {"key": "properties.supportOrdering", "type": "bool"}, + "updated_at": {"key": "properties.updatedAt", "type": "iso-8601"}, } - def __init__( + def __init__( # pylint: disable=too-many-locals self, *, location: str, @@ -741,7 +702,7 @@ def __init__( """ :keyword name: Queue name. :paramtype name: str - :keyword location: Required. location of the resource. + :keyword location: location of the resource. Required. :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 @@ -751,7 +712,7 @@ def __init__( deleted. The minimum duration is 5 minutes. :paramtype auto_delete_on_idle: str :keyword entity_availability_status: Entity availability status for the queue. Known values - are: "Available", "Limited", "Renaming", "Restoring", "Unknown". + are: "Available", "Limited", "Renaming", "Restoring", and "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 @@ -781,7 +742,7 @@ def __init__( :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 + :paramtype max_size_in_megabytes: int :keyword requires_duplicate_detection: A value indicating if this queue requires duplicate detection. :paramtype requires_duplicate_detection: bool @@ -790,12 +751,12 @@ def __init__( :paramtype requires_session: bool :keyword status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Creating", "Deleting", "Disabled", "ReceiveDisabled", "Renaming", - "Restoring", "SendDisabled", "Unknown". + "Restoring", "SendDisabled", and "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) + super().__init__(**kwargs) self.name = name self.location = location self.lock_duration = lock_duration @@ -822,7 +783,7 @@ def __init__( self.updated_at = None -class QueueListResult(msrest.serialization.Model): +class QueueListResult(_serialization.Model): """The response to the List Queues operation. :ivar value: Result of the List Queues operation. @@ -833,16 +794,12 @@ class QueueListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[QueueResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[QueueResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.QueueResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.QueueResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Result of the List Queues operation. @@ -851,12 +808,12 @@ def __init__( list of queues. :paramtype next_link: str """ - super(QueueListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class QueueResource(Resource): +class QueueResource(Resource): # pylint: disable=too-many-instance-attributes """Description of queue Resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -880,7 +837,7 @@ class QueueResource(Resource): deleted. The minimum duration is 5 minutes. :vartype auto_delete_on_idle: str :ivar entity_availability_status: Entity availability status for the queue. Known values are: - "Available", "Limited", "Renaming", "Restoring", "Unknown". + "Available", "Limited", "Renaming", "Restoring", and "Unknown". :vartype entity_availability_status: str or ~azure.mgmt.servicebus.v2015_08_01.models.EntityAvailabilityStatus :ivar created_at: The exact time the message was created. @@ -912,9 +869,9 @@ class QueueResource(Resource): :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. - :vartype max_size_in_megabytes: long + :vartype max_size_in_megabytes: int :ivar message_count: The number of messages in the queue. - :vartype message_count: long + :vartype message_count: int :ivar count_details: Message Count Details. :vartype count_details: ~azure.mgmt.servicebus.v2015_08_01.models.MessageCountDetails :ivar requires_duplicate_detection: A value indicating if this queue requires duplicate @@ -924,10 +881,10 @@ class QueueResource(Resource): sessions. :vartype requires_session: bool :ivar size_in_bytes: The size of the queue, in bytes. - :vartype size_in_bytes: long + :vartype size_in_bytes: int :ivar status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Creating", "Deleting", "Disabled", "ReceiveDisabled", "Renaming", "Restoring", - "SendDisabled", "Unknown". + "SendDisabled", and "Unknown". :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 @@ -936,47 +893,50 @@ class QueueResource(Resource): """ _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}, + "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'}, + "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": "int"}, + "message_count": {"key": "properties.messageCount", "type": "int"}, + "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": "int"}, + "status": {"key": "properties.status", "type": "str"}, + "support_ordering": {"key": "properties.supportOrdering", "type": "bool"}, + "updated_at": {"key": "properties.updatedAt", "type": "iso-8601"}, } - def __init__( + def __init__( # pylint: disable=too-many-locals self, *, location: Optional[str] = None, @@ -1009,7 +969,7 @@ def __init__( deleted. The minimum duration is 5 minutes. :paramtype auto_delete_on_idle: str :keyword entity_availability_status: Entity availability status for the queue. Known values - are: "Available", "Limited", "Renaming", "Restoring", "Unknown". + are: "Available", "Limited", "Renaming", "Restoring", and "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 @@ -1039,7 +999,7 @@ def __init__( :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 + :paramtype max_size_in_megabytes: int :keyword requires_duplicate_detection: A value indicating if this queue requires duplicate detection. :paramtype requires_duplicate_detection: bool @@ -1048,12 +1008,12 @@ def __init__( :paramtype requires_session: bool :keyword status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Creating", "Deleting", "Disabled", "ReceiveDisabled", "Renaming", - "Restoring", "SendDisabled", "Unknown". + "Restoring", "SendDisabled", and "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) + super().__init__(location=location, **kwargs) self.lock_duration = lock_duration self.accessed_at = None self.auto_delete_on_idle = auto_delete_on_idle @@ -1078,34 +1038,29 @@ def __init__( self.updated_at = None -class RegenerateKeysParameters(msrest.serialization.Model): +class RegenerateKeysParameters(_serialization.Model): """Parameters supplied to the Regenerate Authorization Rule operation. - :ivar policykey: Key that needs to be regenerated. Known values are: "PrimaryKey", + :ivar policykey: Key that needs to be regenerated. Known values are: "PrimaryKey" and "SecondaryKey". :vartype policykey: str or ~azure.mgmt.servicebus.v2015_08_01.models.Policykey """ _attribute_map = { - 'policykey': {'key': 'Policykey', 'type': 'str'}, + "policykey": {"key": "Policykey", "type": "str"}, } - def __init__( - self, - *, - policykey: Optional[Union[str, "_models.Policykey"]] = None, - **kwargs - ): + def __init__(self, *, policykey: Optional[Union[str, "_models.Policykey"]] = None, **kwargs): """ - :keyword policykey: Key that needs to be regenerated. Known values are: "PrimaryKey", + :keyword policykey: Key that needs to be regenerated. Known values are: "PrimaryKey" and "SecondaryKey". :paramtype policykey: str or ~azure.mgmt.servicebus.v2015_08_01.models.Policykey """ - super(RegenerateKeysParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.policykey = policykey -class ResourceListKeys(msrest.serialization.Model): +class ResourceListKeys(_serialization.Model): """Namespace/ServiceBus Connection String. :ivar primary_connection_string: Primary connection string of the created namespace @@ -1125,11 +1080,11 @@ class ResourceListKeys(msrest.serialization.Model): """ _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'}, + "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__( @@ -1158,7 +1113,7 @@ def __init__( :keyword key_name: A string that describes the authorization rule. :paramtype key_name: str """ - super(ResourceListKeys, self).__init__(**kwargs) + super().__init__(**kwargs) self.primary_connection_string = primary_connection_string self.secondary_connection_string = secondary_connection_string self.primary_key = primary_key @@ -1166,7 +1121,7 @@ def __init__( self.key_name = key_name -class SharedAccessAuthorizationRuleCreateOrUpdateParameters(msrest.serialization.Model): +class SharedAccessAuthorizationRuleCreateOrUpdateParameters(_serialization.Model): """Parameters supplied to the Create Or Update Authorization Rules operation. :ivar location: data center location. @@ -1178,9 +1133,9 @@ class SharedAccessAuthorizationRuleCreateOrUpdateParameters(msrest.serialization """ _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'rights': {'key': 'properties.rights', 'type': '[str]'}, + "location": {"key": "location", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "rights": {"key": "properties.rights", "type": "[str]"}, } def __init__( @@ -1199,13 +1154,13 @@ def __init__( :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) + super().__init__(**kwargs) self.location = location self.name = name self.rights = rights -class SharedAccessAuthorizationRuleListResult(msrest.serialization.Model): +class SharedAccessAuthorizationRuleListResult(_serialization.Model): """The response to the List Namespace operation. :ivar value: Result of the List Authorization Rules operation. @@ -1217,8 +1172,8 @@ class SharedAccessAuthorizationRuleListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SharedAccessAuthorizationRuleResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SharedAccessAuthorizationRuleResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( @@ -1236,7 +1191,7 @@ def __init__( list of Authorization Rules. :paramtype next_link: str """ - super(SharedAccessAuthorizationRuleListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link @@ -1259,17 +1214,17 @@ class SharedAccessAuthorizationRuleResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "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]'}, + "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__( @@ -1285,32 +1240,32 @@ def __init__( :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) + super().__init__(location=location, **kwargs) self.rights = rights -class Sku(msrest.serialization.Model): +class Sku(_serialization.Model): """SKU of the namespace. All required parameters must be populated in order to send to Azure. - :ivar name: Name of this SKU. Known values are: "Basic", "Standard", "Premium". + :ivar name: Name of this SKU. Known values are: "Basic", "Standard", and "Premium". :vartype name: str or ~azure.mgmt.servicebus.v2015_08_01.models.SkuName - :ivar tier: Required. The billing tier of this particular SKU. Known values are: "Basic", - "Standard", "Premium". + :ivar tier: The billing tier of this particular SKU. Required. Known values are: "Basic", + "Standard", and "Premium". :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 = { - 'tier': {'required': True}, + "tier": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'int'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "capacity": {"key": "capacity", "type": "int"}, } def __init__( @@ -1322,28 +1277,28 @@ def __init__( **kwargs ): """ - :keyword name: Name of this SKU. Known values are: "Basic", "Standard", "Premium". + :keyword name: Name of this SKU. Known values are: "Basic", "Standard", and "Premium". :paramtype name: str or ~azure.mgmt.servicebus.v2015_08_01.models.SkuName - :keyword tier: Required. The billing tier of this particular SKU. Known values are: "Basic", - "Standard", "Premium". + :keyword tier: The billing tier of this particular SKU. Required. Known values are: "Basic", + "Standard", and "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) + super().__init__(**kwargs) self.name = name self.tier = tier self.capacity = capacity -class SubscriptionCreateOrUpdateParameters(msrest.serialization.Model): +class SubscriptionCreateOrUpdateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """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. - :ivar location: Required. Subscription data center location. + :ivar location: Subscription data center location. Required. :vartype location: str :ivar type: Resource manager type of the resource. :vartype type: str @@ -1370,7 +1325,7 @@ class SubscriptionCreateOrUpdateParameters(msrest.serialization.Model): are enabled. :vartype enable_batched_operations: bool :ivar entity_availability_status: Entity availability status for the topic. Known values are: - "Available", "Limited", "Renaming", "Restoring", "Unknown". + "Available", "Limited", "Renaming", "Restoring", and "Unknown". :vartype entity_availability_status: str or ~azure.mgmt.servicebus.v2015_08_01.models.EntityAvailabilityStatus :ivar is_read_only: Value that indicates whether the entity description is read-only. @@ -1380,45 +1335,48 @@ class SubscriptionCreateOrUpdateParameters(msrest.serialization.Model): :ivar max_delivery_count: Number of maximum deliveries. :vartype max_delivery_count: int :ivar message_count: Number of messages. - :vartype message_count: long + :vartype message_count: int :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. Known values are: "Active", "Creating", "Deleting", "Disabled", "ReceiveDisabled", "Renaming", "Restoring", - "SendDisabled", "Unknown". + "SendDisabled", and "Unknown". :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 """ _validation = { - 'location': {'required': True}, - 'accessed_at': {'readonly': True}, - 'count_details': {'readonly': True}, - 'created_at': {'readonly': True}, - 'message_count': {'readonly': True}, - 'updated_at': {'readonly': True}, + "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'}, + "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": "int"}, + "requires_session": {"key": "properties.requiresSession", "type": "bool"}, + "status": {"key": "properties.status", "type": "str"}, + "updated_at": {"key": "properties.updatedAt", "type": "iso-8601"}, } def __init__( @@ -1440,7 +1398,7 @@ def __init__( **kwargs ): """ - :keyword location: Required. Subscription data center location. + :keyword location: Subscription data center location. Required. :paramtype location: str :keyword type: Resource manager type of the resource. :paramtype type: str @@ -1461,7 +1419,7 @@ def __init__( are enabled. :paramtype enable_batched_operations: bool :keyword entity_availability_status: Entity availability status for the topic. Known values - are: "Available", "Limited", "Renaming", "Restoring", "Unknown". + are: "Available", "Limited", "Renaming", "Restoring", and "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. @@ -1474,10 +1432,10 @@ def __init__( :paramtype requires_session: bool :keyword status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Creating", "Deleting", "Disabled", "ReceiveDisabled", "Renaming", - "Restoring", "SendDisabled", "Unknown". + "Restoring", "SendDisabled", and "Unknown". :paramtype status: str or ~azure.mgmt.servicebus.v2015_08_01.models.EntityStatus """ - super(SubscriptionCreateOrUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.type = type self.accessed_at = None @@ -1498,7 +1456,7 @@ def __init__( self.updated_at = None -class SubscriptionListResult(msrest.serialization.Model): +class SubscriptionListResult(_serialization.Model): """The response to the List Subscriptions operation. :ivar value: Result of the List Subscriptions operation. @@ -1509,16 +1467,12 @@ class SubscriptionListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SubscriptionResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SubscriptionResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.SubscriptionResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.SubscriptionResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Result of the List Subscriptions operation. @@ -1527,12 +1481,12 @@ def __init__( list of subscriptions. :paramtype next_link: str """ - super(SubscriptionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SubscriptionResource(Resource): +class SubscriptionResource(Resource): # pylint: disable=too-many-instance-attributes """Description of subscription resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -1568,7 +1522,7 @@ class SubscriptionResource(Resource): are enabled. :vartype enable_batched_operations: bool :ivar entity_availability_status: Entity availability status for the topic. Known values are: - "Available", "Limited", "Renaming", "Restoring", "Unknown". + "Available", "Limited", "Renaming", "Restoring", and "Unknown". :vartype entity_availability_status: str or ~azure.mgmt.servicebus.v2015_08_01.models.EntityAvailabilityStatus :ivar is_read_only: Value that indicates whether the entity description is read-only. @@ -1578,49 +1532,52 @@ class SubscriptionResource(Resource): :ivar max_delivery_count: Number of maximum deliveries. :vartype max_delivery_count: int :ivar message_count: Number of messages. - :vartype message_count: long + :vartype message_count: int :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. Known values are: "Active", "Creating", "Deleting", "Disabled", "ReceiveDisabled", "Renaming", "Restoring", - "SendDisabled", "Unknown". + "SendDisabled", and "Unknown". :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 """ _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}, + "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'}, + "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": "int"}, + "requires_session": {"key": "properties.requiresSession", "type": "bool"}, + "status": {"key": "properties.status", "type": "str"}, + "updated_at": {"key": "properties.updatedAt", "type": "iso-8601"}, } def __init__( @@ -1660,7 +1617,7 @@ def __init__( are enabled. :paramtype enable_batched_operations: bool :keyword entity_availability_status: Entity availability status for the topic. Known values - are: "Available", "Limited", "Renaming", "Restoring", "Unknown". + are: "Available", "Limited", "Renaming", "Restoring", and "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. @@ -1673,10 +1630,10 @@ def __init__( :paramtype requires_session: bool :keyword status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Creating", "Deleting", "Disabled", "ReceiveDisabled", "Renaming", - "Restoring", "SendDisabled", "Unknown". + "Restoring", "SendDisabled", and "Unknown". :paramtype status: str or ~azure.mgmt.servicebus.v2015_08_01.models.EntityStatus """ - super(SubscriptionResource, self).__init__(location=location, **kwargs) + super().__init__(location=location, **kwargs) self.accessed_at = None self.auto_delete_on_idle = auto_delete_on_idle self.count_details = None @@ -1695,7 +1652,7 @@ def __init__( self.updated_at = None -class TopicCreateOrUpdateParameters(msrest.serialization.Model): +class TopicCreateOrUpdateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """Parameters supplied to the Create Or Update Topic operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -1704,7 +1661,7 @@ class TopicCreateOrUpdateParameters(msrest.serialization.Model): :ivar name: Topic name. :vartype name: str - :ivar location: Required. Location of the resource. + :ivar location: Location of the resource. Required. :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 @@ -1712,7 +1669,7 @@ class TopicCreateOrUpdateParameters(msrest.serialization.Model): deleted. The minimum duration is 5 minutes. :vartype auto_delete_on_idle: str :ivar entity_availability_status: Entity availability status for the topic. Known values are: - "Available", "Limited", "Renaming", "Restoring", "Unknown". + "Available", "Limited", "Renaming", "Restoring", and "Unknown". :vartype entity_availability_status: str or ~azure.mgmt.servicebus.v2015_08_01.models.EntityAvailabilityStatus :ivar created_at: Exact time the message was created. @@ -1745,15 +1702,15 @@ class TopicCreateOrUpdateParameters(msrest.serialization.Model): :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. - :vartype max_size_in_megabytes: long + :vartype max_size_in_megabytes: int :ivar requires_duplicate_detection: Value indicating if this topic requires duplicate detection. :vartype requires_duplicate_detection: bool :ivar size_in_bytes: Size of the topic, in bytes. - :vartype size_in_bytes: long + :vartype size_in_bytes: int :ivar status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Creating", "Deleting", "Disabled", "ReceiveDisabled", "Renaming", "Restoring", - "SendDisabled", "Unknown". + "SendDisabled", and "Unknown". :vartype status: str or ~azure.mgmt.servicebus.v2015_08_01.models.EntityStatus :ivar subscription_count: Number of subscriptions. :vartype subscription_count: int @@ -1764,38 +1721,41 @@ class TopicCreateOrUpdateParameters(msrest.serialization.Model): """ _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}, + "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'}, + "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": "int"}, + "requires_duplicate_detection": {"key": "properties.requiresDuplicateDetection", "type": "bool"}, + "size_in_bytes": {"key": "properties.sizeInBytes", "type": "int"}, + "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__( @@ -1822,13 +1782,13 @@ def __init__( """ :keyword name: Topic name. :paramtype name: str - :keyword location: Required. Location of the resource. + :keyword location: Location of the resource. Required. :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. Known values - are: "Available", "Limited", "Renaming", "Restoring", "Unknown". + are: "Available", "Limited", "Renaming", "Restoring", and "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 @@ -1857,18 +1817,18 @@ def __init__( :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 + :paramtype max_size_in_megabytes: int :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. Known values are: "Active", "Creating", "Deleting", "Disabled", "ReceiveDisabled", "Renaming", - "Restoring", "SendDisabled", "Unknown". + "Restoring", "SendDisabled", and "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) + super().__init__(**kwargs) self.name = name self.location = location self.accessed_at = None @@ -1893,7 +1853,7 @@ def __init__( self.updated_at = None -class TopicListResult(msrest.serialization.Model): +class TopicListResult(_serialization.Model): """The response to the List Topics operation. :ivar value: Result of the List Topics operation. @@ -1904,16 +1864,12 @@ class TopicListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[TopicResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[TopicResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.TopicResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.TopicResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Result of the List Topics operation. @@ -1922,12 +1878,12 @@ def __init__( list of topics. :paramtype next_link: str """ - super(TopicListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class TopicResource(Resource): +class TopicResource(Resource): # pylint: disable=too-many-instance-attributes """Description of topic resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -1946,7 +1902,7 @@ class TopicResource(Resource): deleted. The minimum duration is 5 minutes. :vartype auto_delete_on_idle: str :ivar entity_availability_status: Entity availability status for the topic. Known values are: - "Available", "Limited", "Renaming", "Restoring", "Unknown". + "Available", "Limited", "Renaming", "Restoring", and "Unknown". :vartype entity_availability_status: str or ~azure.mgmt.servicebus.v2015_08_01.models.EntityAvailabilityStatus :ivar created_at: Exact time the message was created. @@ -1979,15 +1935,15 @@ class TopicResource(Resource): :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. - :vartype max_size_in_megabytes: long + :vartype max_size_in_megabytes: int :ivar requires_duplicate_detection: Value indicating if this topic requires duplicate detection. :vartype requires_duplicate_detection: bool :ivar size_in_bytes: Size of the topic, in bytes. - :vartype size_in_bytes: long + :vartype size_in_bytes: int :ivar status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Creating", "Deleting", "Disabled", "ReceiveDisabled", "Renaming", "Restoring", - "SendDisabled", "Unknown". + "SendDisabled", and "Unknown". :vartype status: str or ~azure.mgmt.servicebus.v2015_08_01.models.EntityStatus :ivar subscription_count: Number of subscriptions. :vartype subscription_count: int @@ -1998,45 +1954,48 @@ class TopicResource(Resource): """ _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}, + "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'}, + "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": "int"}, + "requires_duplicate_detection": {"key": "properties.requiresDuplicateDetection", "type": "bool"}, + "size_in_bytes": {"key": "properties.sizeInBytes", "type": "int"}, + "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__( + def __init__( # pylint: disable=too-many-locals self, *, location: Optional[str] = None, @@ -2063,7 +2022,7 @@ def __init__( deleted. The minimum duration is 5 minutes. :paramtype auto_delete_on_idle: str :keyword entity_availability_status: Entity availability status for the topic. Known values - are: "Available", "Limited", "Renaming", "Restoring", "Unknown". + are: "Available", "Limited", "Renaming", "Restoring", and "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 @@ -2092,18 +2051,18 @@ def __init__( :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 + :paramtype max_size_in_megabytes: int :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. Known values are: "Active", "Creating", "Deleting", "Disabled", "ReceiveDisabled", "Renaming", - "Restoring", "SendDisabled", "Unknown". + "Restoring", "SendDisabled", and "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) + super().__init__(location=location, **kwargs) self.accessed_at = None self.auto_delete_on_idle = auto_delete_on_idle self.entity_availability_status = entity_availability_status diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/models/_patch.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/models/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/models/_patch.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/models/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. 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 c594d57bdc64..cbd05dcaf049 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 @@ -11,14 +11,15 @@ class AccessRights(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """AccessRights.""" MANAGE = "Manage" SEND = "Send" LISTEN = "Listen" + class EntityAvailabilityStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Entity availability status. - """ + """Entity availability status.""" AVAILABLE = "Available" LIMITED = "Limited" @@ -26,9 +27,9 @@ class EntityAvailabilityStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): RESTORING = "Restoring" UNKNOWN = "Unknown" + class EntityStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Entity status. - """ + """Entity status.""" ACTIVE = "Active" CREATING = "Creating" @@ -40,9 +41,9 @@ class EntityStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): SEND_DISABLED = "SendDisabled" UNKNOWN = "Unknown" + class NamespaceState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """State of the namespace. - """ + """State of the namespace.""" UNKNOWN = "Unknown" CREATING = "Creating" @@ -58,32 +59,32 @@ class NamespaceState(str, Enum, metaclass=CaseInsensitiveEnumMeta): REMOVED = "Removed" FAILED = "Failed" + class Policykey(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Key that needs to be regenerated. - """ + """Key that needs to be regenerated.""" PRIMARY_KEY = "PrimaryKey" SECONDARY_KEY = "SecondaryKey" + class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Name of this SKU. - """ + """Name of this SKU.""" BASIC = "Basic" STANDARD = "Standard" PREMIUM = "Premium" + class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The billing tier of this particular SKU. - """ + """The billing tier of this particular SKU.""" BASIC = "Basic" STANDARD = "Standard" PREMIUM = "Premium" + class UnavailableReason(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the reason for the unavailability of the service. - """ + """Specifies the reason for the unavailability of the service.""" NONE = "None" INVALID_NAME = "InvalidName" diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/operations/__init__.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/operations/__init__.py index b0ee9242d985..f1dc4a3596b4 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/operations/__init__.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/operations/__init__.py @@ -15,12 +15,13 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'NamespacesOperations', - 'QueuesOperations', - 'TopicsOperations', - 'SubscriptionsOperations', + "Operations", + "NamespacesOperations", + "QueuesOperations", + "TopicsOperations", + "SubscriptionsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() 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 dede4df2a374..9167bdb0a46d 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 @@ -6,11 +6,16 @@ # 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, Iterable, Optional, TypeVar, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -22,518 +27,443 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") 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: Optional[_models.CheckNameAvailability] = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: + +def build_check_name_availability_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_subscription_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + accept = _headers.pop("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'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_resource_group_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces") # pylint: disable=line-too-long + _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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request_initial( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - *, - json: Optional[_models.NamespaceCreateOrUpdateParameters] = None, - content: Any = None, - **kwargs: Any + +def build_create_or_update_request( + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long + _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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + +def build_delete_request( + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str + api_version = kwargs.pop("api_version", _params.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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_get_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - *, - json: Optional[_models.NamespaceUpdateParameters] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_list_authorization_rules_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_authorization_rule_request( - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - subscription_id: str, - *, - json: Optional[_models.SharedAccessAuthorizationRuleCreateOrUpdateParameters] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, authorization_rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_authorization_rule_request( - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, authorization_rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str + api_version = kwargs.pop("api_version", _params.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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_get_authorization_rule_request( - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, authorization_rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, authorization_rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_regenerate_keys_request( - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - subscription_id: str, - *, - json: Optional[_models.RegenerateKeysParameters] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, authorization_rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + class NamespacesOperations: """ @@ -554,42 +484,82 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @overload + def check_name_availability( + self, parameters: _models.CheckNameAvailability, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param parameters: Parameters to check availability of the given namespace name. Required. + :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.CheckNameAvailability + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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.v2015_08_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param parameters: Parameters to check availability of the given namespace name. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :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.v2015_08_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def check_name_availability( - self, - parameters: _models.CheckNameAvailability, - **kwargs: Any + self, parameters: Union[_models.CheckNameAvailability, IO], **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Check the give namespace name availability. - :param parameters: Parameters to check availability of the given namespace name. - :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.CheckNameAvailability + :param parameters: Parameters to check availability of the given namespace name. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.CheckNameAvailability or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameAvailabilityResult, or the result of cls(response) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResult] - _json = self._serialize.body(parameters, 'CheckNameAvailability') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _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'], + content=_content, + template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) @@ -597,56 +567,50 @@ def check_name_availability( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + 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 - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> Iterable[_models.NamespaceListResult]: + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.NamespaceResource"]: """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) + :return: An iterator like instance of either NamespaceResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.NamespaceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.NamespaceResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.NamespaceListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription.metadata['url'], + template_url=self.list_by_subscription.metadata["url"], headers=_headers, params=_params, ) @@ -654,14 +618,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -677,10 +638,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -690,46 +649,39 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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: str, - **kwargs: Any - ) -> Iterable[_models.NamespaceListResult]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.NamespaceResource"]: """Gets the available namespaces within a resource group. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :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) + :return: An iterator like instance of either NamespaceResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.NamespaceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.NamespaceResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.NamespaceListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -737,15 +689,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -761,10 +709,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -774,41 +720,44 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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: str, namespace_name: str, - parameters: _models.NamespaceCreateOrUpdateParameters, + parameters: Union[_models.NamespaceCreateOrUpdateParameters, IO], **kwargs: Any ) -> Optional[_models.NamespaceResource]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.NamespaceResource]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.NamespaceResource]] - _json = self._serialize.body(parameters, 'NamespaceCreateOrUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "NamespaceCreateOrUpdateParameters") - request = build_create_or_update_request_initial( + request = build_create_or_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._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) @@ -816,10 +765,9 @@ def _create_or_update_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -828,36 +776,114 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('NamespaceResource', pipeline_response) + deserialized = self._deserialize("NamespaceResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('NamespaceResource', pipeline_response) + deserialized = self._deserialize("NamespaceResource", 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 + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + @overload + def begin_create_or_update( + self, + resource_group_name: str, + namespace_name: str, + parameters: _models.NamespaceCreateOrUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.NamespaceResource]: + """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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to create a namespace resource. Required. + :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.NamespaceCreateOrUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. + :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: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.NamespaceResource]: + """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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to create a namespace resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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: + """ @distributed_trace def begin_create_or_update( self, resource_group_name: str, namespace_name: str, - parameters: _models.NamespaceCreateOrUpdateParameters, + parameters: Union[_models.NamespaceCreateOrUpdateParameters, IO], **kwargs: Any ) -> LROPoller[_models.NamespaceResource]: """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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters supplied to create a namespace resource. + :param parameters: Parameters supplied to create a namespace resource. Is either a model type + or a IO type. Required. :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.NamespaceCreateOrUpdateParameters + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -870,20 +896,17 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.servicebus.v2015_08_01.models.NamespaceResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.NamespaceResource] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.NamespaceResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + 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 = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, @@ -891,64 +914,54 @@ def begin_create_or_update( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('NamespaceResource', pipeline_response) + deserialized = self._deserialize("NamespaceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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: str, - namespace_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_request_initial( + request = build_delete_request( 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'], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) @@ -956,10 +969,9 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -969,22 +981,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements 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 @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, 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. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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. @@ -996,92 +1002,77 @@ def begin_delete( # pylint: disable=inconsistent-return-statements 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + 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 = self._delete_initial( # type: ignore resource_group_name=resource_group_name, namespace_name=namespace_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> _models.NamespaceResource: + def get(self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: NamespaceResource, or the result of cls(response) + :return: NamespaceResource or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.NamespaceResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.NamespaceResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.NamespaceResource] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -1089,61 +1080,123 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('NamespaceResource', pipeline_response) + deserialized = self._deserialize("NamespaceResource", 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 + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - - @distributed_trace + @overload def update( self, resource_group_name: str, namespace_name: str, parameters: _models.NamespaceUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> Optional[_models.NamespaceResource]: """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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters supplied to update a namespace resource. + :param parameters: Parameters supplied to update a namespace resource. Required. :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.NamespaceUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: NamespaceResource or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.NamespaceResource or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Optional[_models.NamespaceResource]: + """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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to update a namespace resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: NamespaceResource or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.NamespaceResource or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + namespace_name: str, + parameters: Union[_models.NamespaceUpdateParameters, IO], + **kwargs: Any + ) -> Optional[_models.NamespaceResource]: + """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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to update a namespace resource. Is either a model type + or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.NamespaceUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: NamespaceResource, or the result of cls(response) + :return: NamespaceResource or None or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.NamespaceResource or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.NamespaceResource]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.NamespaceResource]] - _json = self._serialize.body(parameters, 'NamespaceUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "NamespaceUpdateParameters") request = build_update_request( resource_group_name=resource_group_name, @@ -1152,7 +1205,8 @@ def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -1160,10 +1214,9 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -1172,58 +1225,53 @@ def update( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('NamespaceResource', pipeline_response) + deserialized = self._deserialize("NamespaceResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('NamespaceResource', pipeline_response) + deserialized = self._deserialize("NamespaceResource", 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 - + 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, - namespace_name: str, - **kwargs: Any - ) -> Iterable[_models.SharedAccessAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> Iterable["_models.SharedAccessAuthorizationRuleResource"]: """Gets the authorization rules for a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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 + :return: An iterator like instance of either SharedAccessAuthorizationRuleResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedAccessAuthorizationRuleListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) @@ -1231,16 +1279,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -1256,10 +1299,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1269,50 +1310,118 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 + @overload def create_or_update_authorization_rule( self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, parameters: _models.SharedAccessAuthorizationRuleCreateOrUpdateParameters, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleCreateOrUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SharedAccessAuthorizationRuleResource, or the result of cls(response) + :return: SharedAccessAuthorizationRuleResource or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :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 + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: Union[_models.SharedAccessAuthorizationRuleCreateOrUpdateParameters, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: + ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleCreateOrUpdateParameters + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :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 + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedAccessAuthorizationRuleResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessAuthorizationRuleResource] - _json = self._serialize.body(parameters, 'SharedAccessAuthorizationRuleCreateOrUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SharedAccessAuthorizationRuleCreateOrUpdateParameters") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -1322,7 +1431,8 @@ def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -1330,66 +1440,57 @@ def create_or_update_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SharedAccessAuthorizationRuleResource', pipeline_response) + deserialized = self._deserialize("SharedAccessAuthorizationRuleResource", 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 - + 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: str, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -1397,10 +1498,9 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1410,49 +1510,41 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements 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: str, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SharedAccessAuthorizationRuleResource, or the result of cls(response) + :return: SharedAccessAuthorizationRuleResource or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedAccessAuthorizationRuleResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessAuthorizationRuleResource] - 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'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -1460,66 +1552,57 @@ def get_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SharedAccessAuthorizationRuleResource', pipeline_response) + deserialized = self._deserialize("SharedAccessAuthorizationRuleResource", 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 - + 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: str, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceListKeys, or the result of cls(response) + :return: ResourceListKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.ResourceListKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ResourceListKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListKeys] - 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'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1527,63 +1610,129 @@ def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceListKeys', pipeline_response) + deserialized = self._deserialize("ResourceListKeys", 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 + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys"} # type: ignore - - @distributed_trace + @overload def regenerate_keys( self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, parameters: _models.RegenerateKeysParameters, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.RegenerateKeysParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceListKeys, or the result of cls(response) + :return: ResourceListKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.ResourceListKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceListKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.ResourceListKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateKeysParameters, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.RegenerateKeysParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceListKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.ResourceListKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ResourceListKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListKeys] - _json = self._serialize.body(parameters, 'RegenerateKeysParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateKeysParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -1593,7 +1742,8 @@ def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1601,22 +1751,20 @@ def regenerate_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceListKeys', pipeline_response) + deserialized = self._deserialize("ResourceListKeys", 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 - + 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 2eb93e39c63f..c69955fa53d0 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 @@ -7,10 +7,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- 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 urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -20,38 +25,34 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +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: + +def build_list_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.ServiceBus/operations") # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class Operations: """ @@ -72,36 +73,30 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.OperationListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """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] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -109,13 +104,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -131,10 +124,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -144,8 +135,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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/_patch.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/operations/_patch.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2015_08_01/operations/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. 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 a7935179f693..2b7d93bf939a 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 @@ -6,11 +6,16 @@ # 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, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -20,205 +25,180 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") 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 + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - resource_group_name: str, - namespace_name: str, - queue_name: str, - subscription_id: str, - *, - json: Optional[_models.QueueCreateOrUpdateParameters] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, queue_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - namespace_name: str, - queue_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, queue_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str + api_version = kwargs.pop("api_version", _params.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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_get_request( - resource_group_name: str, - namespace_name: str, - queue_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, queue_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_authorization_rules_request( - resource_group_name: str, - namespace_name: str, - queue_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, queue_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_authorization_rule_request( @@ -227,47 +207,43 @@ def build_create_or_update_authorization_rule_request( queue_name: str, authorization_rule_name: str, subscription_id: str, - *, - json: Optional[_models.SharedAccessAuthorizationRuleCreateOrUpdateParameters] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_post_authorization_rule_request( @@ -281,34 +257,35 @@ def build_post_authorization_rule_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_authorization_rule_request( @@ -321,28 +298,30 @@ def build_delete_authorization_rule_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str + api_version = kwargs.pop("api_version", _params.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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_get_authorization_rule_request( @@ -356,34 +335,35 @@ def build_get_authorization_rule_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( @@ -397,34 +377,35 @@ def build_list_keys_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_regenerate_keys_request( @@ -433,47 +414,44 @@ def build_regenerate_keys_request( queue_name: str, authorization_rule_name: str, subscription_id: str, - *, - json: Optional[_models.RegenerateKeysParameters] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + class QueuesOperations: """ @@ -494,44 +472,39 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_all( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> Iterable[_models.QueueListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> Iterable["_models.QueueResource"]: """Gets the queues within a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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.paging.ItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.QueueListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either QueueResource or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.QueueResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.QueueListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_all.metadata["url"], headers=_headers, params=_params, ) @@ -539,16 +512,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -564,10 +532,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -577,49 +543,115 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 + @overload def create_or_update( self, resource_group_name: str, namespace_name: str, queue_name: str, parameters: _models.QueueCreateOrUpdateParameters, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param parameters: Parameters supplied to create or update a queue resource. + :param parameters: Parameters supplied to create or update a queue resource. Required. :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.QueueCreateOrUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: QueueResource or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.QueueResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param parameters: Parameters supplied to create or update a queue resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: QueueResource, or the result of cls(response) + :return: QueueResource or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.QueueResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + parameters: Union[_models.QueueCreateOrUpdateParameters, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param parameters: Parameters supplied to create or update a queue resource. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.QueueCreateOrUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: QueueResource or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.QueueResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.QueueResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.QueueResource] - _json = self._serialize.body(parameters, 'QueueCreateOrUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "QueueCreateOrUpdateParameters") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -629,7 +661,8 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -637,66 +670,57 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('QueueResource', pipeline_response) + deserialized = self._deserialize("QueueResource", 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 - + 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: str, - namespace_name: str, - queue_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -704,10 +728,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -717,49 +740,41 @@ def delete( # pylint: disable=inconsistent-return-statements 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: str, - namespace_name: str, - queue_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: QueueResource, or the result of cls(response) + :return: QueueResource or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.QueueResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.QueueResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.QueueResource] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -767,69 +782,62 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('QueueResource', pipeline_response) + deserialized = self._deserialize("QueueResource", 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 - + 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, - namespace_name: str, - queue_name: str, - **kwargs: Any - ) -> Iterable[_models.SharedAccessAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, queue_name: str, **kwargs: Any + ) -> Iterable["_models.SharedAccessAuthorizationRuleResource"]: """Gets all authorization rules for a queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :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 + :return: An iterator like instance of either SharedAccessAuthorizationRuleResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedAccessAuthorizationRuleListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) @@ -837,17 +845,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -863,10 +865,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -876,13 +876,11 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 + @overload def create_or_update_authorization_rule( self, resource_group_name: str, @@ -890,39 +888,115 @@ def create_or_update_authorization_rule( queue_name: str, authorization_rule_name: str, parameters: _models.SharedAccessAuthorizationRuleCreateOrUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SharedAccessAuthorizationRuleResource: + """Creates an authorization rule for a queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type parameters: + ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleCreateOrUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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 + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SharedAccessAuthorizationRuleResource: + """Creates an authorization rule for a queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :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 + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: Union[_models.SharedAccessAuthorizationRuleCreateOrUpdateParameters, IO], **kwargs: Any ) -> _models.SharedAccessAuthorizationRuleResource: """Creates an authorization rule for a queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleCreateOrUpdateParameters + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SharedAccessAuthorizationRuleResource, or the result of cls(response) + :return: SharedAccessAuthorizationRuleResource or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedAccessAuthorizationRuleResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessAuthorizationRuleResource] - _json = self._serialize.body(parameters, 'SharedAccessAuthorizationRuleCreateOrUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SharedAccessAuthorizationRuleCreateOrUpdateParameters") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -933,7 +1007,8 @@ def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -941,25 +1016,23 @@ def create_or_update_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SharedAccessAuthorizationRuleResource', pipeline_response) + deserialized = self._deserialize("SharedAccessAuthorizationRuleResource", 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 - + 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( @@ -972,31 +1045,28 @@ def post_authorization_rule( ) -> _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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SharedAccessAuthorizationRuleResource, or the result of cls(response) + :return: SharedAccessAuthorizationRuleResource or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedAccessAuthorizationRuleResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessAuthorizationRuleResource] - request = build_post_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -1004,7 +1074,7 @@ def post_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.post_authorization_rule.metadata['url'], + template_url=self.post_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -1012,25 +1082,23 @@ def post_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SharedAccessAuthorizationRuleResource', pipeline_response) + deserialized = self._deserialize("SharedAccessAuthorizationRuleResource", pipeline_response) if cls: 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 - + 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 @@ -1043,31 +1111,28 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes a queue authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -1075,7 +1140,7 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_authorization_rule.metadata['url'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -1083,10 +1148,9 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1096,8 +1160,7 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements 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( @@ -1110,31 +1173,28 @@ def get_authorization_rule( ) -> _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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SharedAccessAuthorizationRuleResource, or the result of cls(response) + :return: SharedAccessAuthorizationRuleResource or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedAccessAuthorizationRuleResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessAuthorizationRuleResource] - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -1142,7 +1202,7 @@ def get_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -1150,25 +1210,23 @@ def get_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SharedAccessAuthorizationRuleResource', pipeline_response) + deserialized = self._deserialize("SharedAccessAuthorizationRuleResource", 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 - + 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( @@ -1181,31 +1239,28 @@ def list_keys( ) -> _models.ResourceListKeys: """Primary and secondary connection strings to the queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceListKeys, or the result of cls(response) + :return: ResourceListKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.ResourceListKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ResourceListKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListKeys] - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -1213,7 +1268,7 @@ def list_keys( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1221,27 +1276,25 @@ def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceListKeys', pipeline_response) + deserialized = self._deserialize("ResourceListKeys", 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 - + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore - @distributed_trace + @overload def regenerate_keys( self, resource_group_name: str, @@ -1249,38 +1302,112 @@ def regenerate_keys( queue_name: str, authorization_rule_name: str, parameters: _models.RegenerateKeysParameters, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.RegenerateKeysParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceListKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.ResourceListKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceListKeys, or the result of cls(response) + :return: ResourceListKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.ResourceListKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateKeysParameters, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.RegenerateKeysParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceListKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.ResourceListKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ResourceListKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListKeys] - _json = self._serialize.body(parameters, 'RegenerateKeysParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateKeysParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -1291,7 +1418,8 @@ def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1299,22 +1427,20 @@ def regenerate_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceListKeys', pipeline_response) + deserialized = self._deserialize("ResourceListKeys", 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 - + 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 d4663e9a9beb..070c30305ae8 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 @@ -6,11 +6,16 @@ # 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, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -20,50 +25,48 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") 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 + resource_group_name: str, namespace_name: str, topic_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( @@ -72,47 +75,41 @@ def build_create_or_update_request( topic_name: str, subscription_name: str, subscription_id: str, - *, - json: Optional[_models.SubscriptionCreateOrUpdateParameters] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( @@ -125,28 +122,28 @@ def build_delete_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str + api_version = kwargs.pop("api_version", _params.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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_get_request( @@ -160,34 +157,34 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class SubscriptionsOperations: """ @@ -208,50 +205,44 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_all( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - **kwargs: Any - ) -> Iterable[_models.SubscriptionListResult]: + self, resource_group_name: str, namespace_name: str, topic_name: str, **kwargs: Any + ) -> Iterable["_models.SubscriptionResource"]: """List all the subscriptions under a specified topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :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 + :return: An iterator like instance of either SubscriptionResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.SubscriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.SubscriptionResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SubscriptionListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_all.metadata["url"], headers=_headers, params=_params, ) @@ -259,17 +250,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -285,10 +270,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -298,13 +281,11 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 + @overload def create_or_update( self, resource_group_name: str, @@ -312,39 +293,114 @@ def create_or_update( topic_name: str, subscription_name: str, parameters: _models.SubscriptionCreateOrUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SubscriptionResource: """Creates a topic subscription. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param parameters: Parameters supplied to create a subscription resource. + :param parameters: Parameters supplied to create a subscription resource. Required. :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.SubscriptionCreateOrUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SubscriptionResource, or the result of cls(response) + :return: SubscriptionResource or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.SubscriptionResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SubscriptionResource: + """Creates a topic subscription. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param parameters: Parameters supplied to create a subscription resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :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 + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + parameters: Union[_models.SubscriptionCreateOrUpdateParameters, IO], + **kwargs: Any + ) -> _models.SubscriptionResource: + """Creates a topic subscription. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param parameters: Parameters supplied to create a subscription resource. Is either a model + type or a IO type. Required. + :type parameters: + ~azure.mgmt.servicebus.v2015_08_01.models.SubscriptionCreateOrUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :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 + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SubscriptionResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SubscriptionResource] - _json = self._serialize.body(parameters, 'SubscriptionCreateOrUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SubscriptionCreateOrUpdateParameters") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -355,7 +411,8 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -363,62 +420,52 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SubscriptionResource', pipeline_response) + deserialized = self._deserialize("SubscriptionResource", 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 - + 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: str, - namespace_name: str, - topic_name: str, - subscription_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -426,7 +473,7 @@ def delete( # pylint: disable=inconsistent-return-statements subscription_name=subscription_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -434,10 +481,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -447,45 +493,36 @@ def delete( # pylint: disable=inconsistent-return-statements 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: str, - namespace_name: str, - topic_name: str, - subscription_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SubscriptionResource, or the result of cls(response) + :return: SubscriptionResource or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.SubscriptionResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SubscriptionResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SubscriptionResource] - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -493,7 +530,7 @@ def get( subscription_name=subscription_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -501,22 +538,20 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SubscriptionResource', pipeline_response) + deserialized = self._deserialize("SubscriptionResource", 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 - + 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 12313316a6e4..c7a7a853fbb0 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 @@ -6,11 +6,16 @@ # 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, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -20,205 +25,180 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") 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 + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_id: str, - *, - json: Optional[_models.TopicCreateOrUpdateParameters] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, topic_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, topic_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str + api_version = kwargs.pop("api_version", _params.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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_get_request( - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, topic_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_authorization_rules_request( - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, topic_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_authorization_rule_request( @@ -227,47 +207,43 @@ def build_create_or_update_authorization_rule_request( topic_name: str, authorization_rule_name: str, subscription_id: str, - *, - json: Optional[_models.SharedAccessAuthorizationRuleCreateOrUpdateParameters] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_post_authorization_rule_request( @@ -281,34 +257,35 @@ def build_post_authorization_rule_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_get_authorization_rule_request( @@ -322,34 +299,35 @@ def build_get_authorization_rule_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_authorization_rule_request( @@ -362,28 +340,30 @@ def build_delete_authorization_rule_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str + api_version = kwargs.pop("api_version", _params.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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_list_keys_request( @@ -397,34 +377,35 @@ def build_list_keys_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_regenerate_keys_request( @@ -433,47 +414,44 @@ def build_regenerate_keys_request( topic_name: str, authorization_rule_name: str, subscription_id: str, - *, - json: Optional[_models.RegenerateKeysParameters] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + class TopicsOperations: """ @@ -494,44 +472,39 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_all( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> Iterable[_models.TopicListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> Iterable["_models.TopicResource"]: """Gets all the topics in a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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.paging.ItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.TopicListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either TopicResource or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.TopicResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.TopicListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_all.metadata["url"], headers=_headers, params=_params, ) @@ -539,16 +512,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -564,10 +532,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -577,49 +543,115 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 + @overload def create_or_update( self, resource_group_name: str, namespace_name: str, topic_name: str, parameters: _models.TopicCreateOrUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.TopicResource: """Creates a topic in the specified namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param parameters: Parameters supplied to create a topic resource. + :param parameters: Parameters supplied to create a topic resource. Required. :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.TopicCreateOrUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TopicResource or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.TopicResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TopicResource: + """Creates a topic in the specified namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param parameters: Parameters supplied to create a topic resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TopicResource, or the result of cls(response) + :return: TopicResource or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.TopicResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + parameters: Union[_models.TopicCreateOrUpdateParameters, IO], + **kwargs: Any + ) -> _models.TopicResource: + """Creates a topic in the specified namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param parameters: Parameters supplied to create a topic resource. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.TopicCreateOrUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TopicResource or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.TopicResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.TopicResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TopicResource] - _json = self._serialize.body(parameters, 'TopicCreateOrUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TopicCreateOrUpdateParameters") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -629,7 +661,8 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -637,66 +670,57 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TopicResource', pipeline_response) + deserialized = self._deserialize("TopicResource", 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 - + 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: str, - namespace_name: str, - topic_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -704,10 +728,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -717,49 +740,41 @@ def delete( # pylint: disable=inconsistent-return-statements 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: str, - namespace_name: str, - topic_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TopicResource, or the result of cls(response) + :return: TopicResource or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.TopicResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.TopicResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TopicResource] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -767,69 +782,62 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TopicResource', pipeline_response) + deserialized = self._deserialize("TopicResource", 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 - + 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, - namespace_name: str, - topic_name: str, - **kwargs: Any - ) -> Iterable[_models.SharedAccessAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, topic_name: str, **kwargs: Any + ) -> Iterable["_models.SharedAccessAuthorizationRuleResource"]: """Gets authorization rules for a topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :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 + :return: An iterator like instance of either SharedAccessAuthorizationRuleResource or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedAccessAuthorizationRuleListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) @@ -837,17 +845,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -863,10 +865,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -876,13 +876,11 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 + @overload def create_or_update_authorization_rule( self, resource_group_name: str, @@ -890,39 +888,115 @@ def create_or_update_authorization_rule( topic_name: str, authorization_rule_name: str, parameters: _models.SharedAccessAuthorizationRuleCreateOrUpdateParameters, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type parameters: + ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleCreateOrUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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 + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :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 + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: Union[_models.SharedAccessAuthorizationRuleCreateOrUpdateParameters, IO], **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleCreateOrUpdateParameters + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SharedAccessAuthorizationRuleResource, or the result of cls(response) + :return: SharedAccessAuthorizationRuleResource or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedAccessAuthorizationRuleResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessAuthorizationRuleResource] - _json = self._serialize.body(parameters, 'SharedAccessAuthorizationRuleCreateOrUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SharedAccessAuthorizationRuleCreateOrUpdateParameters") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -933,7 +1007,8 @@ def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -941,25 +1016,23 @@ def create_or_update_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SharedAccessAuthorizationRuleResource', pipeline_response) + deserialized = self._deserialize("SharedAccessAuthorizationRuleResource", 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 - + 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( @@ -972,31 +1045,28 @@ def post_authorization_rule( ) -> _models.SharedAccessAuthorizationRuleResource: """Returns the specified authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SharedAccessAuthorizationRuleResource, or the result of cls(response) + :return: SharedAccessAuthorizationRuleResource or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedAccessAuthorizationRuleResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessAuthorizationRuleResource] - request = build_post_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -1004,7 +1074,7 @@ def post_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.post_authorization_rule.metadata['url'], + template_url=self.post_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -1012,25 +1082,23 @@ def post_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SharedAccessAuthorizationRuleResource', pipeline_response) + deserialized = self._deserialize("SharedAccessAuthorizationRuleResource", pipeline_response) if cls: 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( @@ -1043,31 +1111,28 @@ def get_authorization_rule( ) -> _models.SharedAccessAuthorizationRuleResource: """Returns the specified authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SharedAccessAuthorizationRuleResource, or the result of cls(response) + :return: SharedAccessAuthorizationRuleResource or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.SharedAccessAuthorizationRuleResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedAccessAuthorizationRuleResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessAuthorizationRuleResource] - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -1075,7 +1140,7 @@ def get_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -1083,25 +1148,23 @@ def get_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SharedAccessAuthorizationRuleResource', pipeline_response) + deserialized = self._deserialize("SharedAccessAuthorizationRuleResource", 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 - + 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 @@ -1114,31 +1177,28 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes a topic authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -1146,7 +1206,7 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_authorization_rule.metadata['url'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -1154,10 +1214,9 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1167,8 +1226,7 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements 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( @@ -1181,31 +1239,28 @@ def list_keys( ) -> _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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceListKeys, or the result of cls(response) + :return: ResourceListKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.ResourceListKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ResourceListKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListKeys] - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -1213,7 +1268,7 @@ def list_keys( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1221,27 +1276,25 @@ def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceListKeys', pipeline_response) + deserialized = self._deserialize("ResourceListKeys", 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 - + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore - @distributed_trace + @overload def regenerate_keys( self, resource_group_name: str, @@ -1249,38 +1302,112 @@ def regenerate_keys( topic_name: str, authorization_rule_name: str, parameters: _models.RegenerateKeysParameters, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.RegenerateKeysParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceListKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.ResourceListKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceListKeys, or the result of cls(response) + :return: ResourceListKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.ResourceListKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateKeysParameters, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2015_08_01.models.RegenerateKeysParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceListKeys or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2015_08_01.models.ResourceListKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ResourceListKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-08-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListKeys] - _json = self._serialize.body(parameters, 'RegenerateKeysParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateKeysParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -1291,7 +1418,8 @@ def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1299,22 +1427,20 @@ def regenerate_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ResourceListKeys', pipeline_response) + deserialized = self._deserialize("ResourceListKeys", 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 - + 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 221541a00fb6..2a82b6cb6f69 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 @@ -17,7 +17,8 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['ServiceBusManagementClient'] + +__all__ = ["ServiceBusManagementClient"] __all__.extend([p for p in _patch_all if p not in __all__]) _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 9d9d0c72d087..6019ff6aeef8 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 @@ -25,24 +25,19 @@ class ServiceBusManagementClientConfiguration(Configuration): # pylint: disable Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :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. + subscription. The subscription ID forms part of the URI for every service call. Required. :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: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(ServiceBusManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2017-04-01") # type: str + api_version = kwargs.pop("api_version", "2017-04-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -52,23 +47,24 @@ def __init__( self.credential = credential self.subscription_id = subscription_id 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.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-servicebus/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> None - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(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 d03a673a307f..cbb3f18c11c2 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 @@ -10,20 +10,20 @@ "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\"], \"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\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ServiceBusManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ServiceBusManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", + "signature": "subscription_id: str,", + "description": "Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", + "description": "Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false 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 index 0ad201a8c586..f7dd32510333 100644 --- 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 @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. 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 249f40ddf467..82d83edebb51 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 @@ -9,20 +9,32 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import ServiceBusManagementClientConfiguration -from .operations import DisasterRecoveryConfigsOperations, EventHubsOperations, MigrationConfigsOperations, NamespacesOperations, Operations, PremiumMessagingRegionsOperations, QueuesOperations, RegionsOperations, RulesOperations, SubscriptionsOperations, TopicsOperations +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: # pylint: disable=too-many-instance-attributes + +class ServiceBusManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Azure Service Bus client. :ivar namespaces: NamespacesOperations operations @@ -50,10 +62,10 @@ class ServiceBusManagementClient: # pylint: disable=too-many-instance-attribu :vartype regions: azure.mgmt.servicebus.v2017_04_01.operations.RegionsOperations :ivar subscriptions: SubscriptionsOperations operations :vartype subscriptions: azure.mgmt.servicebus.v2017_04_01.operations.SubscriptionsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :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. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -71,53 +83,34 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ServiceBusManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + 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._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.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.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.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.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: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -126,7 +119,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest 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 index 138f663c53a4..9aad73fc743e 100644 --- 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 @@ -7,6 +7,7 @@ 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) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): 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 - ] + 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 920456322fa1..9f1dc6e309ba 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 = "8.1.0" +VERSION = "0.0.0 (it should be stable)" 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 e7dd87df1f93..ba757410f14a 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 @@ -14,7 +14,8 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['ServiceBusManagementClient'] + +__all__ = ["ServiceBusManagementClient"] __all__.extend([p for p in _patch_all if p not in __all__]) _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 866336bb0959..b60b541c6f51 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 @@ -25,24 +25,19 @@ class ServiceBusManagementClientConfiguration(Configuration): # pylint: disable Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :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. + subscription. The subscription ID forms part of the URI for every service call. Required. :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: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(ServiceBusManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2017-04-01") # type: str + api_version = kwargs.pop("api_version", "2017-04-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -52,22 +47,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id 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.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-servicebus/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, - **kwargs: Any - ) -> None: - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(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 index 0ad201a8c586..f7dd32510333 100644 --- 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 @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. 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 749cedf823ea..0e1e58403c9a 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 @@ -9,20 +9,32 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import ServiceBusManagementClientConfiguration -from .operations import DisasterRecoveryConfigsOperations, EventHubsOperations, MigrationConfigsOperations, NamespacesOperations, Operations, PremiumMessagingRegionsOperations, QueuesOperations, RegionsOperations, RulesOperations, SubscriptionsOperations, TopicsOperations +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: # pylint: disable=too-many-instance-attributes + +class ServiceBusManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Azure Service Bus client. :ivar namespaces: NamespacesOperations operations @@ -51,10 +63,10 @@ class ServiceBusManagementClient: # pylint: disable=too-many-instance-attribu :ivar subscriptions: SubscriptionsOperations operations :vartype subscriptions: azure.mgmt.servicebus.v2017_04_01.aio.operations.SubscriptionsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :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. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -72,53 +84,34 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ServiceBusManagementClientConfiguration(credential=credential, subscription_id=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._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.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.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.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.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 - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -127,7 +120,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/__init__.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/__init__.py index 02badefef72e..3dac39fcba9c 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/__init__.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/__init__.py @@ -21,18 +21,19 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'NamespacesOperations', - 'QueuesOperations', - 'TopicsOperations', - 'DisasterRecoveryConfigsOperations', - 'EventHubsOperations', - 'MigrationConfigsOperations', - 'Operations', - 'PremiumMessagingRegionsOperations', - 'RulesOperations', - 'RegionsOperations', - 'SubscriptionsOperations', + "NamespacesOperations", + "QueuesOperations", + "TopicsOperations", + "DisasterRecoveryConfigsOperations", + "EventHubsOperations", + "MigrationConfigsOperations", + "Operations", + "PremiumMessagingRegionsOperations", + "RulesOperations", + "RegionsOperations", + "SubscriptionsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() 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 743016e9ff7d..d90b20e367da 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 @@ -6,10 +6,17 @@ # 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, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +27,23 @@ 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') +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]] + class DisasterRecoveryConfigsOperations: """ .. warning:: @@ -43,41 +63,102 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async + @overload async def check_name_availability( self, resource_group_name: str, namespace_name: str, parameters: _models.CheckNameAvailability, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Check the give namespace name availability. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters to check availability of the given namespace name. + :param parameters: Parameters to check availability of the given namespace name. Required. :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.CheckNameAvailability + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameAvailabilityResult, or the result of cls(response) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + async def check_name_availability( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters to check availability of the given namespace name. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :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.v2017_04_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, + resource_group_name: str, + namespace_name: str, + parameters: Union[_models.CheckNameAvailability, IO], + **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters to check availability of the given namespace name. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.CheckNameAvailability or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :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.v2017_04_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResult] - _json = self._serialize.body(parameters, 'CheckNameAvailability') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CheckNameAvailability") request = build_check_name_availability_request( resource_group_name=resource_group_name, @@ -86,7 +167,8 @@ async def check_name_availability( api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) @@ -94,10 +176,9 @@ async def check_name_availability( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -105,55 +186,49 @@ async def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + 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 - + 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, - namespace_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.ArmDisasterRecoveryListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ArmDisasterRecovery"]: """Gets all Alias(Disaster Recovery configurations). - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: An iterator like instance of either ArmDisasterRecovery 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 + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.ArmDisasterRecovery] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ArmDisasterRecoveryListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -161,16 +236,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -186,10 +256,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -200,49 +268,117 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 + @overload async def create_or_update( self, resource_group_name: str, namespace_name: str, alias: str, parameters: _models.ArmDisasterRecovery, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Required. :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.ArmDisasterRecovery + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ArmDisasterRecovery or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.ArmDisasterRecovery or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ArmDisasterRecovery, or the result of cls(response) + :return: ArmDisasterRecovery or None or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.ArmDisasterRecovery or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: Union[_models.ArmDisasterRecovery, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). Is + either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.ArmDisasterRecovery or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ArmDisasterRecovery or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.ArmDisasterRecovery or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ArmDisasterRecovery]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ArmDisasterRecovery]] - _json = self._serialize.body(parameters, 'ArmDisasterRecovery') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ArmDisasterRecovery") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -252,7 +388,8 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -260,10 +397,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -273,56 +409,48 @@ async def create_or_update( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ArmDisasterRecovery', pipeline_response) + 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 - + 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, - alias: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -330,10 +458,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -344,49 +471,41 @@ async def delete( # pylint: disable=inconsistent-return-statements 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, - namespace_name: str, - alias: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :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) + :return: ArmDisasterRecovery or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.ArmDisasterRecovery - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ArmDisasterRecovery] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ArmDisasterRecovery] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -394,10 +513,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -405,57 +523,49 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ArmDisasterRecovery', pipeline_response) + 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 - + 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, - alias: str, - **kwargs: Any + self, 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. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.break_pairing.metadata["url"], headers=_headers, params=_params, ) @@ -463,10 +573,9 @@ async def break_pairing( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -477,49 +586,41 @@ async def break_pairing( # pylint: disable=inconsistent-return-statements 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 @distributed_trace_async async def fail_over( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - alias: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.fail_over.metadata['url'], + template_url=self.fail_over.metadata["url"], headers=_headers, params=_params, ) @@ -527,10 +628,9 @@ async def fail_over( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -541,52 +641,45 @@ async def fail_over( # pylint: disable=inconsistent-return-statements 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, - namespace_name: str, - alias: str, - **kwargs: Any - ) -> AsyncIterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, alias: str, **kwargs: Any + ) -> AsyncIterable["_models.SBAuthorizationRule"]: """Gets the authorization rules for a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :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) + :return: An iterator like instance of either SBAuthorizationRule 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 + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) @@ -594,17 +687,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -620,10 +707,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -634,48 +719,38 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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, - namespace_name: str, - alias: str, - authorization_rule_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -683,7 +758,7 @@ async def get_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -691,10 +766,9 @@ async def get_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -702,52 +776,43 @@ async def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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, - namespace_name: str, - alias: str, - authorization_rule_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -755,7 +820,7 @@ async def list_keys( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -763,10 +828,9 @@ async def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -774,12 +838,11 @@ async def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 - + 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 07825d2e1437..16a0e70d7013 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 @@ -7,9 +7,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +27,11 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._event_hubs_operations import build_list_by_namespace_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class EventHubsOperations: """ .. warning:: @@ -42,45 +51,40 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_by_namespace( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.EventHubListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Eventhub"]: """Gets all the Event Hubs in a service bus Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: An iterator like instance of either Eventhub or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.EventHubListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.Eventhub] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.EventHubListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_by_namespace.metadata["url"], headers=_headers, params=_params, ) @@ -88,16 +92,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -113,10 +112,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -127,8 +124,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 83016da8a6d6..92876cd4c1de 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 @@ -6,10 +6,17 @@ # 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, Optional, TypeVar, Union, cast +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +29,19 @@ 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') +from ...operations._migration_configs_operations import ( + build_complete_migration_request, + build_create_and_start_migration_request, + 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]] + class MigrationConfigsOperations: """ .. warning:: @@ -45,46 +61,41 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.MigrationConfigListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.MigrationConfigProperties"]: """Gets all migrationConfigurations. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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 + :return: An iterator like instance of either MigrationConfigProperties 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 + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.MigrationConfigProperties] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MigrationConfigListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -92,16 +103,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -117,10 +123,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -131,35 +135,37 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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, resource_group_name: str, namespace_name: str, config_name: Union[str, "_models.MigrationConfigurationName"], - parameters: _models.MigrationConfigProperties, + parameters: Union[_models.MigrationConfigProperties, IO], **kwargs: Any ) -> Optional[_models.MigrationConfigProperties]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.MigrationConfigProperties]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.MigrationConfigProperties]] - _json = self._serialize.body(parameters, 'MigrationConfigProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "MigrationConfigProperties") - request = build_create_and_start_migration_request_initial( + request = build_create_and_start_migration_request( resource_group_name=resource_group_name, namespace_name=namespace_name, config_name=config_name, @@ -167,7 +173,8 @@ async def _create_and_start_migration_initial( api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_and_start_migration_initial.metadata['url'], + content=_content, + template_url=self._create_and_start_migration_initial.metadata["url"], headers=_headers, params=_params, ) @@ -175,48 +182,92 @@ async def _create_and_start_migration_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) + 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 - + _create_and_start_migration_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore - @distributed_trace_async + @overload async def begin_create_and_start_migration( self, resource_group_name: str, namespace_name: str, config_name: Union[str, "_models.MigrationConfigurationName"], parameters: _models.MigrationConfigProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2017_04_01.models.MigrationConfigurationName - :param parameters: Parameters required to create Migration Configuration. + :param parameters: Parameters required to create Migration Configuration. Required. :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.MigrationConfigProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. + :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: + """ + + @overload + async def begin_create_and_start_migration( + self, + resource_group_name: str, + namespace_name: str, + config_name: Union[str, "_models.MigrationConfigurationName"], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> 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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param config_name: The configuration name. Should always be "$default". "$default" Required. + :type config_name: str or ~azure.mgmt.servicebus.v2017_04_01.models.MigrationConfigurationName + :param parameters: Parameters required to create Migration Configuration. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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 @@ -229,20 +280,56 @@ async def begin_create_and_start_migration( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicebus.v2017_04_01.models.MigrationConfigProperties] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_and_start_migration( + self, + resource_group_name: str, + namespace_name: str, + config_name: Union[str, "_models.MigrationConfigurationName"], + parameters: Union[_models.MigrationConfigProperties, IO], + **kwargs: Any + ) -> 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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param config_name: The configuration name. Should always be "$default". "$default" Required. + :type config_name: str or ~azure.mgmt.servicebus.v2017_04_01.models.MigrationConfigurationName + :param parameters: Parameters required to create Migration Configuration. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.MigrationConfigProperties or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.MigrationConfigProperties] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MigrationConfigProperties] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + 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( # type: ignore resource_group_name=resource_group_name, @@ -251,39 +338,35 @@ async def begin_create_and_start_migration( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) + deserialized = self._deserialize("MigrationConfigProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, 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 + deserialization_callback=get_long_running_output, ) 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 + begin_create_and_start_migration.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -295,36 +378,33 @@ async def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes a MigrationConfiguration. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2017_04_01.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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -332,10 +412,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -346,8 +425,7 @@ async def delete( # pylint: disable=inconsistent-return-statements 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( @@ -359,36 +437,33 @@ async def get( ) -> _models.MigrationConfigProperties: """Retrieves Migration Config. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2017_04_01.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) + :return: MigrationConfigProperties or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.MigrationConfigProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MigrationConfigProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MigrationConfigProperties] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -396,10 +471,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -407,15 +481,14 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) + 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 - + 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 @@ -429,36 +502,33 @@ async def complete_migration( # pylint: disable=inconsistent-return-statements 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2017_04_01.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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.complete_migration.metadata["url"], headers=_headers, params=_params, ) @@ -466,10 +536,9 @@ async def complete_migration( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -480,8 +549,7 @@ async def complete_migration( # pylint: disable=inconsistent-return-statements 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 @distributed_trace_async async def revert( # pylint: disable=inconsistent-return-statements @@ -493,36 +561,33 @@ async def revert( # pylint: disable=inconsistent-return-statements ) -> None: """This operation reverts Migration. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2017_04_01.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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.revert.metadata["url"], headers=_headers, params=_params, ) @@ -530,10 +595,9 @@ async def revert( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -544,5 +608,4 @@ async def revert( # pylint: disable=inconsistent-return-statements 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 bb8e82ba64c7..eb067803f10e 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 @@ -6,10 +6,17 @@ # 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, Optional, TypeVar, Union, cast +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +29,30 @@ 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') +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, + build_delete_authorization_rule_request, + build_delete_request, + 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]] + class NamespacesOperations: """ .. warning:: @@ -45,46 +72,40 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SBAuthorizationRule"]: """Gets the authorization rules for a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: An iterator like instance of either SBAuthorizationRule 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 + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) @@ -92,16 +113,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -117,10 +133,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -131,49 +145,115 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 + @overload async def create_or_update_authorization_rule( self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, parameters: _models.SBAuthorizationRule, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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.v2017_04_01.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace_async + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: Union[_models.SBAuthorizationRule, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2017_04_01.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - _json = self._serialize.body(parameters, 'SBAuthorizationRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBAuthorizationRule") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -183,7 +263,8 @@ async def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -191,10 +272,9 @@ async def create_or_update_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -202,56 +282,48 @@ async def create_or_update_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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, - authorization_rule_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -259,10 +331,9 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -273,49 +344,41 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat 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, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - 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'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -323,10 +386,9 @@ async def get_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -334,56 +396,48 @@ async def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - 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'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -391,10 +445,9 @@ async def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -402,53 +455,120 @@ async def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys"} # type: ignore - - @distributed_trace_async + @overload async def regenerate_keys( self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, parameters: _models.RegenerateAccessKeyParameters, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.RegenerateAccessKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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.v2017_04_01.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace_async + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateAccessKeyParameters, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.RegenerateAccessKeyParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2017_04_01.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateAccessKeyParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -458,7 +578,8 @@ async def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) @@ -466,10 +587,9 @@ async def regenerate_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -477,51 +597,91 @@ async def regenerate_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 + regenerate_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore + + @overload + async def check_name_availability( + self, parameters: _models.CheckNameAvailability, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param parameters: Parameters to check availability of the given namespace name. Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.CheckNameAvailability + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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.v2017_04_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def check_name_availability( + self, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param parameters: Parameters to check availability of the given namespace name. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :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.v2017_04_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def check_name_availability( - self, - parameters: _models.CheckNameAvailability, - **kwargs: Any + self, parameters: Union[_models.CheckNameAvailability, IO], **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Check the give namespace name availability. - :param parameters: Parameters to check availability of the given namespace name. - :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.CheckNameAvailability + :param parameters: Parameters to check availability of the given namespace name. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.CheckNameAvailability or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameAvailabilityResult, or the result of cls(response) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResult] - _json = self._serialize.body(parameters, 'CheckNameAvailability') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _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'], + content=_content, + template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) @@ -529,10 +689,9 @@ async def check_name_availability( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -540,50 +699,111 @@ async def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + 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 - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability"} # type: ignore - @distributed_trace_async + @overload async def migrate( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, parameters: _models.SBNamespaceMigrate, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters supplied to migrate namespace type. + :param parameters: Parameters supplied to migrate namespace type. Required. :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.SBNamespaceMigrate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + async def migrate( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to migrate namespace type. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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: + """ + + @distributed_trace_async + async def migrate( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + namespace_name: str, + parameters: Union[_models.SBNamespaceMigrate, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to migrate namespace type. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.SBNamespaceMigrate or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(parameters, 'SBNamespaceMigrate') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBNamespaceMigrate") request = build_migrate_request( resource_group_name=resource_group_name, @@ -592,7 +812,8 @@ async def migrate( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, json=_json, - template_url=self.migrate.metadata['url'], + content=_content, + template_url=self.migrate.metadata["url"], headers=_headers, params=_params, ) @@ -600,10 +821,9 @@ async def migrate( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -614,40 +834,34 @@ async def migrate( # pylint: disable=inconsistent-return-statements 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 - ) -> AsyncIterable[_models.SBNamespaceListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.SBNamespace"]: """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) + :return: An iterator like instance of either SBNamespace 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 + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBNamespace] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespaceListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -655,14 +869,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -678,10 +889,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -692,47 +901,39 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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, - **kwargs: Any - ) -> AsyncIterable[_models.SBNamespaceListResult]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.SBNamespace"]: """Gets the available namespaces within a resource group. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :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) + :return: An iterator like instance of either SBNamespace 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 + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBNamespace] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespaceListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -740,15 +941,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -764,10 +961,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -778,41 +973,40 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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, - resource_group_name: str, - namespace_name: str, - parameters: _models.SBNamespace, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, parameters: Union[_models.SBNamespace, IO], **kwargs: Any ) -> Optional[_models.SBNamespace]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.SBNamespace]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.SBNamespace]] - _json = self._serialize.body(parameters, 'SBNamespace') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBNamespace") - request = build_create_or_update_request_initial( + request = build_create_or_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._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) @@ -820,48 +1014,89 @@ async def _create_or_update_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SBNamespace', pipeline_response) + 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 + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - - @distributed_trace_async + @overload async def begin_create_or_update( self, resource_group_name: str, namespace_name: str, parameters: _models.SBNamespace, + *, + content_type: str = "application/json", **kwargs: Any ) -> 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters supplied to create a namespace resource. + :param parameters: Parameters supplied to create a namespace resource. Required. :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.SBNamespace + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. + :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: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> 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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to create a namespace resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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 @@ -874,20 +1109,49 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicebus.v2017_04_01.models.SBNamespace] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, resource_group_name: str, namespace_name: str, parameters: Union[_models.SBNamespace, IO], **kwargs: Any + ) -> 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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to create a namespace resource. Is either a model type + or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.SBNamespace or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespace] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBNamespace] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + 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( # type: ignore resource_group_name=resource_group_name, @@ -895,64 +1159,54 @@ async def begin_create_or_update( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, 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 + deserialization_callback=get_long_running_output, ) 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 + 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, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_request_initial( + request = build_delete_request( 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'], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) @@ -960,35 +1214,29 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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_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 @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete(self, resource_group_name: str, namespace_name: str, **kwargs: Any) -> 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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. @@ -1000,92 +1248,77 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + 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( # type: ignore resource_group_name=resource_group_name, namespace_name=namespace_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, 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 + deserialization_callback=get_long_running_output, ) 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 + 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, - namespace_name: str, - **kwargs: Any - ) -> _models.SBNamespace: + async def get(self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: SBNamespace or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBNamespace - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespace] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBNamespace] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -1093,10 +1326,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1104,51 +1336,114 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBNamespace', pipeline_response) + 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 + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - - @distributed_trace_async + @overload async def update( self, resource_group_name: str, namespace_name: str, parameters: _models.SBNamespaceUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters supplied to update a namespace resource. + :param parameters: Parameters supplied to update a namespace resource. Required. :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.SBNamespaceUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBNamespace, or the result of cls(response) + :return: SBNamespace or None or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBNamespace or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + async def update( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> 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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to update a namespace resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBNamespace or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBNamespace or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + namespace_name: str, + parameters: Union[_models.SBNamespaceUpdateParameters, IO], + **kwargs: Any + ) -> 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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to update a namespace resource. Is either a model type + or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.SBNamespaceUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBNamespace or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBNamespace or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.SBNamespace]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.SBNamespace]] - _json = self._serialize.body(parameters, 'SBNamespaceUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBNamespaceUpdateParameters") request = build_update_request( resource_group_name=resource_group_name, @@ -1157,7 +1452,8 @@ async def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -1165,10 +1461,9 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -1178,53 +1473,113 @@ async def update( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SBNamespace', pipeline_response) + 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 + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - - @distributed_trace_async + @overload async def create_or_update_network_rule_set( self, resource_group_name: str, namespace_name: str, parameters: _models.NetworkRuleSet, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.NetworkRuleSet: """Create or update NetworkRuleSet for a Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: The Namespace IpFilterRule. + :param parameters: The Namespace IpFilterRule. Required. :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.NetworkRuleSet + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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.v2017_04_01.models.NetworkRuleSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_network_rule_set( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NetworkRuleSet: + """Create or update NetworkRuleSet for a Namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: The Namespace IpFilterRule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: NetworkRuleSet, or the result of cls(response) + :return: NetworkRuleSet or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.NetworkRuleSet - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace_async + async def create_or_update_network_rule_set( + self, + resource_group_name: str, + namespace_name: str, + parameters: Union[_models.NetworkRuleSet, IO], + **kwargs: Any + ) -> _models.NetworkRuleSet: + """Create or update NetworkRuleSet for a Namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: The Namespace IpFilterRule. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.NetworkRuleSet or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2017_04_01.models.NetworkRuleSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkRuleSet] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.NetworkRuleSet] - _json = self._serialize.body(parameters, 'NetworkRuleSet') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "NetworkRuleSet") request = build_create_or_update_network_rule_set_request( resource_group_name=resource_group_name, @@ -1233,7 +1588,8 @@ async def create_or_update_network_rule_set( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_network_rule_set.metadata['url'], + content=_content, + template_url=self.create_or_update_network_rule_set.metadata["url"], headers=_headers, params=_params, ) @@ -1241,10 +1597,9 @@ async def create_or_update_network_rule_set( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1252,52 +1607,45 @@ async def create_or_update_network_rule_set( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('NetworkRuleSet', pipeline_response) + 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 - + 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, - namespace_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: NetworkRuleSet or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.NetworkRuleSet - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkRuleSet] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.NetworkRuleSet] - 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'], + template_url=self.get_network_rule_set.metadata["url"], headers=_headers, params=_params, ) @@ -1305,10 +1653,9 @@ async def get_network_rule_set( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1316,55 +1663,49 @@ async def get_network_rule_set( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('NetworkRuleSet', pipeline_response) + 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 - + 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, - namespace_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.NetworkRuleSetListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.NetworkRuleSet"]: """Gets list of NetworkRuleSet for a Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: An iterator like instance of either NetworkRuleSet 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 + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.NetworkRuleSet] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkRuleSetListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_network_rule_sets.metadata["url"], headers=_headers, params=_params, ) @@ -1372,16 +1713,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -1397,10 +1733,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1411,8 +1745,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 956ee24cfe1b..376e6731309d 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 @@ -7,9 +7,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +27,11 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class Operations: """ .. warning:: @@ -42,36 +51,31 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.OperationListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """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) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -79,13 +83,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -101,10 +103,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -115,8 +115,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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/_patch.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_patch.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/aio/operations/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. 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 a9cf8690163e..1fb5b75ae481 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 @@ -7,9 +7,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +27,11 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._premium_messaging_regions_operations import build_list_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class PremiumMessagingRegionsOperations: """ .. warning:: @@ -42,38 +51,33 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.PremiumMessagingRegionsListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.PremiumMessagingRegions"]: """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 + :return: An iterator like instance of either PremiumMessagingRegions 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 + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.PremiumMessagingRegions] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PremiumMessagingRegionsListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -81,14 +85,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -104,10 +105,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -118,8 +117,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 5fbdc0c15c43..4dd36260859e 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 @@ -6,10 +6,17 @@ # 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, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +27,23 @@ 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') +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]] + class QueuesOperations: """ .. warning:: @@ -43,50 +63,43 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, queue_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SBAuthorizationRule"]: """Gets all authorization rules for a queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :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) + :return: An iterator like instance of either SBAuthorizationRule 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 + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) @@ -94,17 +107,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -120,10 +127,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -134,13 +139,11 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 + @overload async def create_or_update_authorization_rule( self, resource_group_name: str, @@ -148,38 +151,112 @@ async def create_or_update_authorization_rule( queue_name: str, authorization_rule_name: str, parameters: _models.SBAuthorizationRule, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBAuthorizationRule: """Creates an authorization rule for a queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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.v2017_04_01.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for a queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace_async + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: Union[_models.SBAuthorizationRule, IO], + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for a queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2017_04_01.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - _json = self._serialize.body(parameters, 'SBAuthorizationRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBAuthorizationRule") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -190,7 +267,8 @@ async def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -198,10 +276,9 @@ async def create_or_update_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -209,15 +286,14 @@ async def create_or_update_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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 @@ -230,31 +306,28 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat ) -> None: """Deletes a queue authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -262,7 +335,7 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_authorization_rule.metadata['url'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -270,10 +343,9 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -284,8 +356,7 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat 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( @@ -298,31 +369,28 @@ async def get_authorization_rule( ) -> _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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -330,7 +398,7 @@ async def get_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -338,10 +406,9 @@ async def get_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -349,15 +416,14 @@ async def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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( @@ -370,31 +436,28 @@ async def list_keys( ) -> _models.AccessKeys: """Primary and secondary connection strings to the queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -402,7 +465,7 @@ async def list_keys( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -410,10 +473,9 @@ async def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -421,17 +483,16 @@ async def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 - + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore - @distributed_trace_async + @overload async def regenerate_keys( self, resource_group_name: str, @@ -439,38 +500,112 @@ async def regenerate_keys( queue_name: str, authorization_rule_name: str, parameters: _models.RegenerateAccessKeyParameters, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.RegenerateAccessKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2017_04_01.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateAccessKeyParameters, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.RegenerateAccessKeyParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2017_04_01.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateAccessKeyParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -481,7 +616,8 @@ async def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) @@ -489,10 +625,9 @@ async def regenerate_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -500,15 +635,14 @@ async def regenerate_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 - + 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( @@ -518,12 +652,12 @@ def list_by_namespace( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable[_models.SBQueueListResult]: + ) -> AsyncIterable["_models.SBQueue"]: """Gets the queues within a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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 @@ -533,32 +667,31 @@ def list_by_namespace( 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) + :return: An iterator like instance of either SBQueue or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBQueueListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBQueue] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBQueueListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + api_version=api_version, + template_url=self.list_by_namespace.metadata["url"], headers=_headers, params=_params, ) @@ -566,18 +699,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -593,10 +719,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -607,49 +731,115 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 + @overload async def create_or_update( self, resource_group_name: str, namespace_name: str, queue_name: str, parameters: _models.SBQueue, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param parameters: Parameters supplied to create or update a queue resource. + :param parameters: Parameters supplied to create or update a queue resource. Required. :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.SBQueue + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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.v2017_04_01.models.SBQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param parameters: Parameters supplied to create or update a queue resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBQueue, or the result of cls(response) + :return: SBQueue or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + parameters: Union[_models.SBQueue, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param parameters: Parameters supplied to create or update a queue resource. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.SBQueue or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2017_04_01.models.SBQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBQueue] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBQueue] - _json = self._serialize.body(parameters, 'SBQueue') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBQueue") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -659,7 +849,8 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -667,10 +858,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -678,56 +868,48 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBQueue', pipeline_response) + 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 - + 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, - queue_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -735,10 +917,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -749,49 +930,41 @@ async def delete( # pylint: disable=inconsistent-return-statements 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, - namespace_name: str, - queue_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :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) + :return: SBQueue or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBQueue] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBQueue] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -799,10 +972,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -810,12 +982,11 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBQueue', pipeline_response) + 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 - + 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 67a69b7ed6c5..bbb9cedf104b 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 @@ -7,9 +7,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +27,11 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._regions_operations import build_list_by_sku_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class RegionsOperations: """ .. warning:: @@ -42,42 +51,36 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list_by_sku( - self, - sku: str, - **kwargs: Any - ) -> AsyncIterable[_models.PremiumMessagingRegionsListResult]: + def list_by_sku(self, sku: str, **kwargs: Any) -> AsyncIterable["_models.PremiumMessagingRegions"]: """Gets the available Regions for a given sku. - :param sku: The sku type. + :param sku: The sku type. Required. :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 + :return: An iterator like instance of either PremiumMessagingRegions 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 + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.PremiumMessagingRegions] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PremiumMessagingRegionsListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_sku_request( - subscription_id=self._config.subscription_id, sku=sku, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_sku.metadata['url'], + template_url=self.list_by_sku.metadata["url"], headers=_headers, params=_params, ) @@ -85,15 +88,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_sku_request( - subscription_id=self._config.subscription_id, - sku=sku, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -109,10 +108,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -123,8 +120,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 9ca2cb43ddca..4aa021b6aa5c 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 @@ -6,10 +6,17 @@ # 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, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +27,17 @@ 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') +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]] + class RulesOperations: """ .. warning:: @@ -43,7 +57,6 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_by_subscriptions( self, @@ -54,16 +67,16 @@ def list_by_subscriptions( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable[_models.RuleListResult]: + ) -> AsyncIterable["_models.Rule"]: """List all the rules within given topic-subscription. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :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 @@ -73,34 +86,32 @@ def list_by_subscriptions( 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] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Rule or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.Rule] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.RuleListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + api_version=api_version, + template_url=self.list_by_subscriptions.metadata["url"], headers=_headers, params=_params, ) @@ -108,20 +119,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -137,10 +139,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -151,13 +151,11 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 + @overload async def create_or_update( self, resource_group_name: str, @@ -166,40 +164,120 @@ async def create_or_update( subscription_name: str, rule_name: str, parameters: _models.Rule, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param rule_name: The rule name. + :param rule_name: The rule name. Required. :type rule_name: str - :param parameters: Parameters supplied to create a rule. + :param parameters: Parameters supplied to create a rule. Required. :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.Rule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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.v2017_04_01.models.Rule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param rule_name: The rule name. Required. + :type rule_name: str + :param parameters: Parameters supplied to create a rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2017_04_01.models.Rule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + parameters: Union[_models.Rule, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param rule_name: The rule name. Required. + :type rule_name: str + :param parameters: Parameters supplied to create a rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.Rule or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Rule, or the result of cls(response) + :return: Rule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.Rule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Rule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Rule] - _json = self._serialize.body(parameters, 'Rule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Rule") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -211,7 +289,8 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -219,10 +298,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -230,15 +308,14 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Rule', pipeline_response) + 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 - + 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 @@ -252,33 +329,30 @@ async def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes an existing rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param rule_name: The rule name. + :param rule_name: The rule name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -287,7 +361,7 @@ async def delete( # pylint: disable=inconsistent-return-statements rule_name=rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -295,10 +369,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -309,8 +382,7 @@ async def delete( # pylint: disable=inconsistent-return-statements 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( @@ -324,33 +396,30 @@ async def get( ) -> _models.Rule: """Retrieves the description for the specified rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param rule_name: The rule name. + :param rule_name: The rule name. Required. :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) + :return: Rule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.Rule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Rule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Rule] - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -359,7 +428,7 @@ async def get( rule_name=rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -367,10 +436,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -378,12 +446,11 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Rule', pipeline_response) + 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 - + 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 861b32e683c2..0f66481dcafa 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 @@ -6,10 +6,17 @@ # 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, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +27,17 @@ 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') +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]] + class SubscriptionsOperations: """ .. warning:: @@ -43,7 +57,6 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_by_topic( self, @@ -53,14 +66,14 @@ def list_by_topic( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable[_models.SBSubscriptionListResult]: + ) -> AsyncIterable["_models.SBSubscription"]: """List all the subscriptions under a specified topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :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 @@ -70,34 +83,32 @@ def list_by_topic( 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) + :return: An iterator like instance of either SBSubscription 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 + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBSubscription] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBSubscriptionListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + api_version=api_version, + template_url=self.list_by_topic.metadata["url"], headers=_headers, params=_params, ) @@ -105,19 +116,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -133,10 +136,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -147,13 +148,11 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 + @overload async def create_or_update( self, resource_group_name: str, @@ -161,38 +160,112 @@ async def create_or_update( topic_name: str, subscription_name: str, parameters: _models.SBSubscription, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBSubscription: """Creates a topic subscription. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param parameters: Parameters supplied to create a subscription resource. + :param parameters: Parameters supplied to create a subscription resource. Required. :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.SBSubscription + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBSubscription, or the result of cls(response) + :return: SBSubscription or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBSubscription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBSubscription: + """Creates a topic subscription. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param parameters: Parameters supplied to create a subscription resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2017_04_01.models.SBSubscription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + parameters: Union[_models.SBSubscription, IO], + **kwargs: Any + ) -> _models.SBSubscription: + """Creates a topic subscription. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param parameters: Parameters supplied to create a subscription resource. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.SBSubscription or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2017_04_01.models.SBSubscription + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBSubscription] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBSubscription] - _json = self._serialize.body(parameters, 'SBSubscription') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBSubscription") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -203,7 +276,8 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -211,10 +285,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -222,52 +295,43 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBSubscription', pipeline_response) + 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 - + 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, - topic_name: str, - subscription_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -275,7 +339,7 @@ async def delete( # pylint: disable=inconsistent-return-statements subscription_name=subscription_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -283,10 +347,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -297,45 +360,36 @@ async def delete( # pylint: disable=inconsistent-return-statements 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, - namespace_name: str, - topic_name: str, - subscription_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :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) + :return: SBSubscription or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBSubscription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBSubscription] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBSubscription] - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -343,7 +397,7 @@ async def get( subscription_name=subscription_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -351,10 +405,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -362,12 +415,11 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBSubscription', pipeline_response) + 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 - + 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 4814085f44a2..90ae86349a72 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 @@ -6,10 +6,17 @@ # 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, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +27,23 @@ 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') +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]] + class TopicsOperations: """ .. warning:: @@ -43,50 +63,43 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, topic_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SBAuthorizationRule"]: """Gets authorization rules for a topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :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) + :return: An iterator like instance of either SBAuthorizationRule 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 + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) @@ -94,17 +107,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -120,10 +127,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -134,13 +139,11 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 + @overload async def create_or_update_authorization_rule( self, resource_group_name: str, @@ -148,38 +151,112 @@ async def create_or_update_authorization_rule( topic_name: str, authorization_rule_name: str, parameters: _models.SBAuthorizationRule, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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.v2017_04_01.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace_async + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: Union[_models.SBAuthorizationRule, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2017_04_01.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - _json = self._serialize.body(parameters, 'SBAuthorizationRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBAuthorizationRule") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -190,7 +267,8 @@ async def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -198,10 +276,9 @@ async def create_or_update_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -209,15 +286,14 @@ async def create_or_update_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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( @@ -230,31 +306,28 @@ async def get_authorization_rule( ) -> _models.SBAuthorizationRule: """Returns the specified authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -262,7 +335,7 @@ async def get_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -270,10 +343,9 @@ async def get_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -281,15 +353,14 @@ async def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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 @@ -302,31 +373,28 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat ) -> None: """Deletes a topic authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -334,7 +402,7 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_authorization_rule.metadata['url'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -342,10 +410,9 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -356,8 +423,7 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat 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( @@ -370,31 +436,28 @@ async def list_keys( ) -> _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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -402,7 +465,7 @@ async def list_keys( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -410,10 +473,9 @@ async def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -421,17 +483,16 @@ async def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 - + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore - @distributed_trace_async + @overload async def regenerate_keys( self, resource_group_name: str, @@ -439,38 +500,112 @@ async def regenerate_keys( topic_name: str, authorization_rule_name: str, parameters: _models.RegenerateAccessKeyParameters, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.RegenerateAccessKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2017_04_01.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateAccessKeyParameters, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.RegenerateAccessKeyParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2017_04_01.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateAccessKeyParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -481,7 +616,8 @@ async def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) @@ -489,10 +625,9 @@ async def regenerate_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -500,15 +635,14 @@ async def regenerate_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 - + 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( @@ -518,12 +652,12 @@ def list_by_namespace( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable[_models.SBTopicListResult]: + ) -> AsyncIterable["_models.SBTopic"]: """Gets all the topics in a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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 @@ -533,32 +667,31 @@ def list_by_namespace( 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) + :return: An iterator like instance of either SBTopic or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBTopicListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBTopic] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBTopicListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + api_version=api_version, + template_url=self.list_by_namespace.metadata["url"], headers=_headers, params=_params, ) @@ -566,18 +699,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -593,10 +719,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -607,49 +731,115 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 + @overload async def create_or_update( self, resource_group_name: str, namespace_name: str, topic_name: str, parameters: _models.SBTopic, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBTopic: """Creates a topic in the specified namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param parameters: Parameters supplied to create a topic resource. + :param parameters: Parameters supplied to create a topic resource. Required. :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.SBTopic + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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.v2017_04_01.models.SBTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBTopic: + """Creates a topic in the specified namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param parameters: Parameters supplied to create a topic resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBTopic, or the result of cls(response) + :return: SBTopic or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBTopic - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + parameters: Union[_models.SBTopic, IO], + **kwargs: Any + ) -> _models.SBTopic: + """Creates a topic in the specified namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param parameters: Parameters supplied to create a topic resource. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.SBTopic or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2017_04_01.models.SBTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBTopic] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBTopic] - _json = self._serialize.body(parameters, 'SBTopic') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBTopic") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -659,7 +849,8 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -667,10 +858,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -678,56 +868,48 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBTopic', pipeline_response) + 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 - + 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, - topic_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -735,10 +917,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -749,49 +930,41 @@ async def delete( # pylint: disable=inconsistent-return-statements 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, - namespace_name: str, - topic_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :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) + :return: SBTopic or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBTopic - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBTopic] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBTopic] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -799,10 +972,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -810,12 +982,11 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBTopic', pipeline_response) + 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 - + 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 9757ddefc7b6..81bbf2048b5b 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 @@ -56,90 +56,88 @@ from ._models_py3 import Subnet from ._models_py3 import TrackedResource - -from ._service_bus_management_client_enums import ( - AccessRights, - DefaultAction, - EncodingCaptureDescription, - EntityStatus, - FilterType, - KeyType, - MigrationConfigurationName, - NameSpaceType, - NetworkRuleIPAction, - ProvisioningStateDR, - RoleDisasterRecovery, - SkuName, - SkuTier, - UnavailableReason, -) +from ._service_bus_management_client_enums import AccessRights +from ._service_bus_management_client_enums import DefaultAction +from ._service_bus_management_client_enums import EncodingCaptureDescription +from ._service_bus_management_client_enums import EntityStatus +from ._service_bus_management_client_enums import FilterType +from ._service_bus_management_client_enums import KeyType +from ._service_bus_management_client_enums import MigrationConfigurationName +from ._service_bus_management_client_enums import NameSpaceType +from ._service_bus_management_client_enums import NetworkRuleIPAction +from ._service_bus_management_client_enums import ProvisioningStateDR +from ._service_bus_management_client_enums import RoleDisasterRecovery +from ._service_bus_management_client_enums import SkuName +from ._service_bus_management_client_enums import SkuTier +from ._service_bus_management_client_enums import UnavailableReason from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'AccessKeys', - 'Action', - 'ArmDisasterRecovery', - 'ArmDisasterRecoveryListResult', - 'CaptureDescription', - 'CheckNameAvailability', - 'CheckNameAvailabilityResult', - 'CorrelationFilter', - 'Destination', - 'ErrorAdditionalInfo', - 'ErrorResponse', - 'ErrorResponseError', - 'EventHubListResult', - 'Eventhub', - 'MessageCountDetails', - 'MigrationConfigListResult', - 'MigrationConfigProperties', - 'NWRuleSetIpRules', - 'NWRuleSetVirtualNetworkRules', - 'NetworkRuleSet', - 'NetworkRuleSetListResult', - 'Operation', - 'OperationDisplay', - 'OperationListResult', - 'PremiumMessagingRegions', - 'PremiumMessagingRegionsListResult', - 'PremiumMessagingRegionsProperties', - 'RegenerateAccessKeyParameters', - 'Resource', - 'ResourceNamespacePatch', - 'Rule', - 'RuleListResult', - 'SBAuthorizationRule', - 'SBAuthorizationRuleListResult', - 'SBNamespace', - 'SBNamespaceListResult', - 'SBNamespaceMigrate', - 'SBNamespaceUpdateParameters', - 'SBQueue', - 'SBQueueListResult', - 'SBSku', - 'SBSubscription', - 'SBSubscriptionListResult', - 'SBTopic', - 'SBTopicListResult', - 'SqlFilter', - 'SqlRuleAction', - 'Subnet', - 'TrackedResource', - 'AccessRights', - 'DefaultAction', - 'EncodingCaptureDescription', - 'EntityStatus', - 'FilterType', - 'KeyType', - 'MigrationConfigurationName', - 'NameSpaceType', - 'NetworkRuleIPAction', - 'ProvisioningStateDR', - 'RoleDisasterRecovery', - 'SkuName', - 'SkuTier', - 'UnavailableReason', + "AccessKeys", + "Action", + "ArmDisasterRecovery", + "ArmDisasterRecoveryListResult", + "CaptureDescription", + "CheckNameAvailability", + "CheckNameAvailabilityResult", + "CorrelationFilter", + "Destination", + "ErrorAdditionalInfo", + "ErrorResponse", + "ErrorResponseError", + "EventHubListResult", + "Eventhub", + "MessageCountDetails", + "MigrationConfigListResult", + "MigrationConfigProperties", + "NWRuleSetIpRules", + "NWRuleSetVirtualNetworkRules", + "NetworkRuleSet", + "NetworkRuleSetListResult", + "Operation", + "OperationDisplay", + "OperationListResult", + "PremiumMessagingRegions", + "PremiumMessagingRegionsListResult", + "PremiumMessagingRegionsProperties", + "RegenerateAccessKeyParameters", + "Resource", + "ResourceNamespacePatch", + "Rule", + "RuleListResult", + "SBAuthorizationRule", + "SBAuthorizationRuleListResult", + "SBNamespace", + "SBNamespaceListResult", + "SBNamespaceMigrate", + "SBNamespaceUpdateParameters", + "SBQueue", + "SBQueueListResult", + "SBSku", + "SBSubscription", + "SBSubscriptionListResult", + "SBTopic", + "SBTopicListResult", + "SqlFilter", + "SqlRuleAction", + "Subnet", + "TrackedResource", + "AccessRights", + "DefaultAction", + "EncodingCaptureDescription", + "EntityStatus", + "FilterType", + "KeyType", + "MigrationConfigurationName", + "NameSpaceType", + "NetworkRuleIPAction", + "ProvisioningStateDR", + "RoleDisasterRecovery", + "SkuName", + "SkuTier", + "UnavailableReason", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() 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 919aaa6fd79c..b2e9daaf2f98 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 @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -9,15 +10,14 @@ import datetime from typing import Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - import __init__ as _models + from .. import models as _models -class AccessKeys(msrest.serialization.Model): +class AccessKeys(_serialization.Model): """Namespace/ServiceBus Connection String. Variables are only populated by the server, and will be ignored when sending a request. @@ -45,32 +45,28 @@ class AccessKeys(msrest.serialization.Model): """ _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}, + "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) + "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().__init__(**kwargs) self.primary_connection_string = None self.secondary_connection_string = None self.alias_primary_connection_string = None @@ -80,7 +76,7 @@ def __init__( self.key_name = None -class Action(msrest.serialization.Model): +class Action(_serialization.Model): """Represents the filter actions which are allowed for the transformation of a message that have been matched by a filter expression. :ivar sql_expression: SQL expression. e.g. MyProperty='ABC'. @@ -94,9 +90,9 @@ class Action(msrest.serialization.Model): """ _attribute_map = { - 'sql_expression': {'key': 'sqlExpression', 'type': 'str'}, - 'compatibility_level': {'key': 'compatibilityLevel', 'type': 'int'}, - 'requires_preprocessing': {'key': 'requiresPreprocessing', 'type': 'bool'}, + "sql_expression": {"key": "sqlExpression", "type": "str"}, + "compatibility_level": {"key": "compatibilityLevel", "type": "int"}, + "requires_preprocessing": {"key": "requiresPreprocessing", "type": "bool"}, } def __init__( @@ -104,7 +100,7 @@ def __init__( *, sql_expression: Optional[str] = None, compatibility_level: Optional[int] = None, - requires_preprocessing: Optional[bool] = True, + requires_preprocessing: bool = True, **kwargs ): """ @@ -117,13 +113,13 @@ def __init__( preprocessing. :paramtype requires_preprocessing: bool """ - super(Action, self).__init__(**kwargs) + super().__init__(**kwargs) self.sql_expression = sql_expression self.compatibility_level = compatibility_level self.requires_preprocessing = requires_preprocessing -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """The Resource definition for other than namespace. Variables are only populated by the server, and will be ignored when sending a request. @@ -137,24 +133,20 @@ class Resource(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "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'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Resource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -173,11 +165,11 @@ class ArmDisasterRecovery(Resource): :vartype type: str :ivar provisioning_state: Provisioning state of the Alias(Disaster Recovery configuration) - possible values 'Accepted' or 'Succeeded' or 'Failed'. Known values are: "Accepted", - "Succeeded", "Failed". + "Succeeded", and "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 + :vartype pending_replication_operations_count: int :ivar partner_namespace: ARM Id of the Primary/Secondary eventhub namespace name, which is part of GEO DR pairing. :vartype partner_namespace: str @@ -185,37 +177,31 @@ class ArmDisasterRecovery(Resource): pairing. :vartype alternate_name: str :ivar role: role of namespace in GEO DR - possible values 'Primary' or 'PrimaryNotReplicating' - or 'Secondary'. Known values are: "Primary", "PrimaryNotReplicating", "Secondary". + or 'Secondary'. Known values are: "Primary", "PrimaryNotReplicating", and "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}, + "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'}, + "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": "int"}, + "partner_namespace": {"key": "properties.partnerNamespace", "type": "str"}, + "alternate_name": {"key": "properties.alternateName", "type": "str"}, + "role": {"key": "properties.role", "type": "str"}, } - def __init__( - self, - *, - partner_namespace: Optional[str] = None, - alternate_name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, partner_namespace: Optional[str] = None, 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. @@ -224,7 +210,7 @@ def __init__( pairing. :paramtype alternate_name: str """ - super(ArmDisasterRecovery, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.pending_replication_operations_count = None self.partner_namespace = partner_namespace @@ -232,7 +218,7 @@ def __init__( self.role = None -class ArmDisasterRecoveryListResult(msrest.serialization.Model): +class ArmDisasterRecoveryListResult(_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. @@ -245,36 +231,31 @@ class ArmDisasterRecoveryListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ArmDisasterRecovery]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ArmDisasterRecovery]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.ArmDisasterRecovery"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.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) + super().__init__(**kwargs) self.value = value self.next_link = None -class CaptureDescription(msrest.serialization.Model): +class CaptureDescription(_serialization.Model): """Properties to configure capture description for eventhub. :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. - Known values are: "Avro", "AvroDeflate". + Known values are: "Avro" and "AvroDeflate". :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. @@ -288,16 +269,16 @@ class CaptureDescription(msrest.serialization.Model): """ _validation = { - 'interval_in_seconds': {'maximum': 900, 'minimum': 60}, - 'size_limit_in_bytes': {'maximum': 524288000, 'minimum': 10485760}, + "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'}, + "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__( @@ -314,7 +295,7 @@ def __init__( :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. Known values are: "Avro", "AvroDeflate". + description. Known values are: "Avro" and "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 @@ -327,7 +308,7 @@ def __init__( Blob Names). :paramtype destination: ~azure.mgmt.servicebus.v2017_04_01.models.Destination """ - super(CaptureDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.encoding = encoding self.interval_in_seconds = interval_in_seconds @@ -335,42 +316,37 @@ def __init__( self.destination = destination -class CheckNameAvailability(msrest.serialization.Model): +class CheckNameAvailability(_serialization.Model): """Description of a Check Name availability request properties. All required parameters must be populated in order to send to Azure. - :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. + :ivar name: 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. Required. :vartype name: str """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - name: str, - **kwargs - ): + def __init__(self, *, 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. + :keyword name: 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. Required. :paramtype name: str """ - super(CheckNameAvailability, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class CheckNameAvailabilityResult(msrest.serialization.Model): +class CheckNameAvailabilityResult(_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. @@ -381,19 +357,19 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): available; otherwise, false. :vartype name_available: bool :ivar reason: The reason for unavailability of a namespace. Known values are: "None", - "InvalidName", "SubscriptionIsDisabled", "NameInUse", "NameInLockdown", + "InvalidName", "SubscriptionIsDisabled", "NameInUse", "NameInLockdown", and "TooManyNamespaceInCurrentSubscription". :vartype reason: str or ~azure.mgmt.servicebus.v2017_04_01.models.UnavailableReason """ _validation = { - 'message': {'readonly': True}, + "message": {"readonly": True}, } _attribute_map = { - 'message': {'key': 'message', 'type': 'str'}, - 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, - 'reason': {'key': 'reason', 'type': 'str'}, + "message": {"key": "message", "type": "str"}, + "name_available": {"key": "nameAvailable", "type": "bool"}, + "reason": {"key": "reason", "type": "str"}, } def __init__( @@ -408,17 +384,17 @@ def __init__( available; otherwise, false. :paramtype name_available: bool :keyword reason: The reason for unavailability of a namespace. Known values are: "None", - "InvalidName", "SubscriptionIsDisabled", "NameInUse", "NameInLockdown", + "InvalidName", "SubscriptionIsDisabled", "NameInUse", "NameInLockdown", and "TooManyNamespaceInCurrentSubscription". :paramtype reason: str or ~azure.mgmt.servicebus.v2017_04_01.models.UnavailableReason """ - super(CheckNameAvailabilityResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.message = None self.name_available = name_available self.reason = reason -class CorrelationFilter(msrest.serialization.Model): +class CorrelationFilter(_serialization.Model): """Represents the correlation filter expression. :ivar properties: dictionary object for custom filters. @@ -445,16 +421,16 @@ class CorrelationFilter(msrest.serialization.Model): """ _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'}, + "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__( @@ -469,7 +445,7 @@ def __init__( session_id: Optional[str] = None, reply_to_session_id: Optional[str] = None, content_type: Optional[str] = None, - requires_preprocessing: Optional[bool] = True, + requires_preprocessing: bool = True, **kwargs ): """ @@ -495,7 +471,7 @@ def __init__( preprocessing. :paramtype requires_preprocessing: bool """ - super(CorrelationFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.correlation_id = correlation_id self.message_id = message_id @@ -508,7 +484,7 @@ def __init__( self.requires_preprocessing = requires_preprocessing -class Destination(msrest.serialization.Model): +class Destination(_serialization.Model): """Capture storage details for capture description. :ivar name: Name for capture destination. @@ -525,10 +501,10 @@ class Destination(msrest.serialization.Model): """ _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'}, + "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__( @@ -553,14 +529,14 @@ def __init__( the parameters (Namespace,EventHub .. etc) are mandatory irrespective of order. :paramtype archive_name_format: str """ - super(Destination, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.storage_account_resource_id = storage_account_resource_id self.blob_container = blob_container self.archive_name_format = archive_name_format -class ErrorAdditionalInfo(msrest.serialization.Model): +class ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. Variables are only populated by the server, and will be ignored when sending a request. @@ -568,31 +544,27 @@ class ErrorAdditionalInfo(msrest.serialization.Model): :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. - :vartype info: any + :vartype info: JSON """ _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, + "type": {"readonly": True}, + "info": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorAdditionalInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.info = None -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """The resource management error response. :ivar error: The error object. @@ -600,24 +572,19 @@ class ErrorResponse(msrest.serialization.Model): """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponseError'}, + "error": {"key": "error", "type": "ErrorResponseError"}, } - def __init__( - self, - *, - error: Optional["_models.ErrorResponseError"] = None, - **kwargs - ): + def __init__(self, *, error: Optional["_models.ErrorResponseError"] = None, **kwargs): """ :keyword error: The error object. :paramtype error: ~azure.mgmt.servicebus.v2017_04_01.models.ErrorResponseError """ - super(ErrorResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error -class ErrorResponseError(msrest.serialization.Model): +class ErrorResponseError(_serialization.Model): """The error object. Variables are only populated by the server, and will be ignored when sending a request. @@ -635,28 +602,24 @@ class ErrorResponseError(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, + "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]'}, + "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) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.message = None self.target = None @@ -683,40 +646,40 @@ class Eventhub(Resource): :vartype updated_at: ~datetime.datetime :ivar message_retention_in_days: Number of days to retain the events for this Event Hub, value should be 1 to 7 days. - :vartype message_retention_in_days: long + :vartype message_retention_in_days: int :ivar partition_count: Number of partitions created for the Event Hub, allowed values are from 1 to 32 partitions. - :vartype partition_count: long + :vartype partition_count: int :ivar status: Enumerates the possible values for the status of a Event Hub. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", "Deleting", - "Renaming", "Unknown". + "Renaming", and "Unknown". :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 = { - '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}, + "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'}, + "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": "int"}, + "partition_count": {"key": "properties.partitionCount", "type": "int"}, + "status": {"key": "properties.status", "type": "str"}, + "capture_description": {"key": "properties.captureDescription", "type": "CaptureDescription"}, } def __init__( @@ -731,18 +694,18 @@ def __init__( """ :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 + :paramtype message_retention_in_days: int :keyword partition_count: Number of partitions created for the Event Hub, allowed values are from 1 to 32 partitions. - :paramtype partition_count: long + :paramtype partition_count: int :keyword status: Enumerates the possible values for the status of a Event Hub. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". + "Deleting", "Renaming", and "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) + super().__init__(**kwargs) self.partition_ids = None self.created_at = None self.updated_at = None @@ -752,7 +715,7 @@ def __init__( self.capture_description = capture_description -class EventHubListResult(msrest.serialization.Model): +class EventHubListResult(_serialization.Model): """The result of the List EventHubs operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -765,70 +728,61 @@ class EventHubListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Eventhub]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Eventhub]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.Eventhub"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.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) + super().__init__(**kwargs) self.value = value self.next_link = None -class MessageCountDetails(msrest.serialization.Model): +class MessageCountDetails(_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 + :vartype active_message_count: int :ivar dead_letter_message_count: Number of messages that are dead lettered. - :vartype dead_letter_message_count: long + :vartype dead_letter_message_count: int :ivar scheduled_message_count: Number of scheduled messages. - :vartype scheduled_message_count: long + :vartype scheduled_message_count: int :ivar transfer_message_count: Number of messages transferred to another queue, topic, or subscription. - :vartype transfer_message_count: long + :vartype transfer_message_count: int :ivar transfer_dead_letter_message_count: Number of messages transferred into dead letters. - :vartype transfer_dead_letter_message_count: long + :vartype transfer_dead_letter_message_count: int """ _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}, + "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'}, + "active_message_count": {"key": "activeMessageCount", "type": "int"}, + "dead_letter_message_count": {"key": "deadLetterMessageCount", "type": "int"}, + "scheduled_message_count": {"key": "scheduledMessageCount", "type": "int"}, + "transfer_message_count": {"key": "transferMessageCount", "type": "int"}, + "transfer_dead_letter_message_count": {"key": "transferDeadLetterMessageCount", "type": "int"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(MessageCountDetails, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.active_message_count = None self.dead_letter_message_count = None self.scheduled_message_count = None @@ -836,7 +790,7 @@ def __init__( self.transfer_dead_letter_message_count = None -class MigrationConfigListResult(msrest.serialization.Model): +class MigrationConfigListResult(_serialization.Model): """The result of the List migrationConfigurations operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -849,25 +803,20 @@ class MigrationConfigListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[MigrationConfigProperties]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[MigrationConfigProperties]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.MigrationConfigProperties"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.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) + super().__init__(**kwargs) self.value = value self.next_link = None @@ -886,7 +835,7 @@ class MigrationConfigProperties(Resource): :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 + :vartype pending_replication_operations_count: int :ivar target_namespace: Existing premium Namespace ARM Id name which has no entities, will be used for migration. :vartype target_namespace: str @@ -898,32 +847,26 @@ class MigrationConfigProperties(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'pending_replication_operations_count': {'readonly': True}, - 'migration_state': {'readonly': True}, + "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'}, + "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": "int"}, + "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, - *, - target_namespace: Optional[str] = None, - post_migration_name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, target_namespace: Optional[str] = None, 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. @@ -931,7 +874,7 @@ def __init__( :keyword post_migration_name: Name to access Standard Namespace after migration. :paramtype post_migration_name: str """ - super(MigrationConfigProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.pending_replication_operations_count = None self.target_namespace = target_namespace @@ -950,7 +893,8 @@ class NetworkRuleSet(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :ivar default_action: Default Action for Network Rule Set. Known values are: "Allow", "Deny". + :ivar default_action: Default Action for Network Rule Set. Known values are: "Allow" and + "Deny". :vartype default_action: str or ~azure.mgmt.servicebus.v2017_04_01.models.DefaultAction :ivar virtual_network_rules: List VirtualNetwork Rules. :vartype virtual_network_rules: @@ -960,18 +904,18 @@ class NetworkRuleSet(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "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]'}, + "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__( @@ -983,7 +927,7 @@ def __init__( **kwargs ): """ - :keyword default_action: Default Action for Network Rule Set. Known values are: "Allow", + :keyword default_action: Default Action for Network Rule Set. Known values are: "Allow" and "Deny". :paramtype default_action: str or ~azure.mgmt.servicebus.v2017_04_01.models.DefaultAction :keyword virtual_network_rules: List VirtualNetwork Rules. @@ -992,13 +936,13 @@ def __init__( :keyword ip_rules: List of IpRules. :paramtype ip_rules: list[~azure.mgmt.servicebus.v2017_04_01.models.NWRuleSetIpRules] """ - super(NetworkRuleSet, self).__init__(**kwargs) + super().__init__(**kwargs) self.default_action = default_action self.virtual_network_rules = virtual_network_rules self.ip_rules = ip_rules -class NetworkRuleSetListResult(msrest.serialization.Model): +class NetworkRuleSetListResult(_serialization.Model): """The response of the List NetworkRuleSet operation. :ivar value: Result of the List NetworkRuleSet operation. @@ -1009,16 +953,12 @@ class NetworkRuleSetListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[NetworkRuleSet]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[NetworkRuleSet]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.NetworkRuleSet"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.NetworkRuleSet"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Result of the List NetworkRuleSet operation. @@ -1027,44 +967,40 @@ def __init__( list of NetworkRuleSet. :paramtype next_link: str """ - super(NetworkRuleSetListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class NWRuleSetIpRules(msrest.serialization.Model): +class NWRuleSetIpRules(_serialization.Model): """Description of NetWorkRuleSet - IpRules resource. :ivar ip_mask: IP Mask. :vartype ip_mask: str - :ivar action: The IP Filter Action. Known values are: "Allow". Default value: "Allow". + :ivar action: The IP Filter Action. "Allow" :vartype action: str or ~azure.mgmt.servicebus.v2017_04_01.models.NetworkRuleIPAction """ _attribute_map = { - 'ip_mask': {'key': 'ipMask', 'type': 'str'}, - 'action': {'key': 'action', 'type': 'str'}, + "ip_mask": {"key": "ipMask", "type": "str"}, + "action": {"key": "action", "type": "str"}, } def __init__( - self, - *, - ip_mask: Optional[str] = None, - action: Optional[Union[str, "_models.NetworkRuleIPAction"]] = "Allow", - **kwargs + self, *, ip_mask: Optional[str] = None, action: Union[str, "_models.NetworkRuleIPAction"] = "Allow", **kwargs ): """ :keyword ip_mask: IP Mask. :paramtype ip_mask: str - :keyword action: The IP Filter Action. Known values are: "Allow". Default value: "Allow". + :keyword action: The IP Filter Action. "Allow" :paramtype action: str or ~azure.mgmt.servicebus.v2017_04_01.models.NetworkRuleIPAction """ - super(NWRuleSetIpRules, self).__init__(**kwargs) + super().__init__(**kwargs) self.ip_mask = ip_mask self.action = action -class NWRuleSetVirtualNetworkRules(msrest.serialization.Model): +class NWRuleSetVirtualNetworkRules(_serialization.Model): """Description of VirtualNetworkRules - NetworkRules resource. :ivar subnet: Subnet properties. @@ -1075,8 +1011,8 @@ class NWRuleSetVirtualNetworkRules(msrest.serialization.Model): """ _attribute_map = { - 'subnet': {'key': 'subnet', 'type': 'Subnet'}, - 'ignore_missing_vnet_service_endpoint': {'key': 'ignoreMissingVnetServiceEndpoint', 'type': 'bool'}, + "subnet": {"key": "subnet", "type": "Subnet"}, + "ignore_missing_vnet_service_endpoint": {"key": "ignoreMissingVnetServiceEndpoint", "type": "bool"}, } def __init__( @@ -1093,12 +1029,12 @@ def __init__( VNet Service Endpoint. :paramtype ignore_missing_vnet_service_endpoint: bool """ - super(NWRuleSetVirtualNetworkRules, self).__init__(**kwargs) + super().__init__(**kwargs) self.subnet = subnet self.ignore_missing_vnet_service_endpoint = ignore_missing_vnet_service_endpoint -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """A ServiceBus REST API operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -1110,30 +1046,25 @@ class Operation(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, + "name": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, } - def __init__( - self, - *, - display: Optional["_models.OperationDisplay"] = None, - **kwargs - ): + def __init__(self, *, display: Optional["_models.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) + super().__init__(**kwargs) self.name = None self.display = display -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """The object that represents the operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -1147,30 +1078,26 @@ class OperationDisplay(msrest.serialization.Model): """ _validation = { - 'provider': {'readonly': True}, - 'resource': {'readonly': True}, - 'operation': {'readonly': True}, + "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'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(OperationDisplay, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.provider = None self.resource = None self.operation = None -class OperationListResult(msrest.serialization.Model): +class OperationListResult(_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. @@ -1183,22 +1110,18 @@ class OperationListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(OperationListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None @@ -1216,38 +1139,32 @@ class ResourceNamespacePatch(Resource): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "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}'}, + "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, - *, - location: Optional[str] = None, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs): """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(ResourceNamespacePatch, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.tags = tags @@ -1265,7 +1182,7 @@ class PremiumMessagingRegions(ResourceNamespacePatch): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar properties: :vartype properties: @@ -1273,18 +1190,18 @@ class PremiumMessagingRegions(ResourceNamespacePatch): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "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'}, + "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__( @@ -1298,17 +1215,17 @@ def __init__( """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword 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) + super().__init__(location=location, tags=tags, **kwargs) self.properties = properties -class PremiumMessagingRegionsListResult(msrest.serialization.Model): +class PremiumMessagingRegionsListResult(_serialization.Model): """The response of the List PremiumMessagingRegions operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -1321,30 +1238,25 @@ class PremiumMessagingRegionsListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[PremiumMessagingRegions]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PremiumMessagingRegions]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.PremiumMessagingRegions"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.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) + super().__init__(**kwargs) self.value = value self.next_link = None -class PremiumMessagingRegionsProperties(msrest.serialization.Model): +class PremiumMessagingRegionsProperties(_serialization.Model): """PremiumMessagingRegionsProperties. Variables are only populated by the server, and will be ignored when sending a request. @@ -1356,32 +1268,28 @@ class PremiumMessagingRegionsProperties(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'full_name': {'readonly': True}, + "code": {"readonly": True}, + "full_name": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'full_name': {'key': 'fullName', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "full_name": {"key": "fullName", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(PremiumMessagingRegionsProperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.full_name = None -class RegenerateAccessKeyParameters(msrest.serialization.Model): +class RegenerateAccessKeyParameters(_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. - :ivar key_type: Required. The access key to regenerate. Known values are: "PrimaryKey", + :ivar key_type: The access key to regenerate. Required. Known values are: "PrimaryKey" and "SecondaryKey". :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 @@ -1390,30 +1298,24 @@ class RegenerateAccessKeyParameters(msrest.serialization.Model): """ _validation = { - 'key_type': {'required': True}, + "key_type": {"required": True}, } _attribute_map = { - 'key_type': {'key': 'keyType', 'type': 'str'}, - 'key': {'key': 'key', 'type': 'str'}, + "key_type": {"key": "keyType", "type": "str"}, + "key": {"key": "key", "type": "str"}, } - def __init__( - self, - *, - key_type: Union[str, "_models.KeyType"], - key: Optional[str] = None, - **kwargs - ): + def __init__(self, *, key_type: Union[str, "_models.KeyType"], key: Optional[str] = None, **kwargs): """ - :keyword key_type: Required. The access key to regenerate. Known values are: "PrimaryKey", + :keyword key_type: The access key to regenerate. Required. Known values are: "PrimaryKey" and "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) + super().__init__(**kwargs) self.key_type = key_type self.key = key @@ -1433,7 +1335,7 @@ class Rule(Resource): message that have been matched by a filter expression. :vartype action: ~azure.mgmt.servicebus.v2017_04_01.models.Action :ivar filter_type: Filter type that is evaluated against a BrokeredMessage. Known values are: - "SqlFilter", "CorrelationFilter". + "SqlFilter" and "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 @@ -1442,19 +1344,19 @@ class Rule(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "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'}, + "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__( @@ -1471,21 +1373,21 @@ def __init__( 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. Known values - are: "SqlFilter", "CorrelationFilter". + are: "SqlFilter" and "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) + super().__init__(**kwargs) self.action = action self.filter_type = filter_type self.sql_filter = sql_filter self.correlation_filter = correlation_filter -class RuleListResult(msrest.serialization.Model): +class RuleListResult(_serialization.Model): """The response of the List rule operation. :ivar value: Result of the List Rules operation. @@ -1496,17 +1398,11 @@ class RuleListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Rule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Rule]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.Rule"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Rule"]] = None, 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] @@ -1514,7 +1410,7 @@ def __init__( list of rules. :paramtype next_link: str """ - super(RuleListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link @@ -1535,33 +1431,28 @@ class SBAuthorizationRule(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "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]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "rights": {"key": "properties.rights", "type": "[str]"}, } - def __init__( - self, - *, - rights: Optional[List[Union[str, "_models.AccessRights"]]] = None, - **kwargs - ): + def __init__(self, *, rights: Optional[List[Union[str, "_models.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) + super().__init__(**kwargs) self.rights = rights -class SBAuthorizationRuleListResult(msrest.serialization.Model): +class SBAuthorizationRuleListResult(_serialization.Model): """The response to the List Namespace operation. :ivar value: Result of the List Authorization Rules operation. @@ -1572,16 +1463,12 @@ class SBAuthorizationRuleListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SBAuthorizationRule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SBAuthorizationRule]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.SBAuthorizationRule"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.SBAuthorizationRule"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Result of the List Authorization Rules operation. @@ -1590,7 +1477,7 @@ def __init__( list of Authorization Rules. :paramtype next_link: str """ - super(SBAuthorizationRuleListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link @@ -1608,46 +1495,40 @@ class TrackedResource(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :ivar location: Required. The Geo-location where the resource lives. + :ivar location: The Geo-location where the resource lives. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "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}'}, + "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, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword location: Required. The Geo-location where the resource lives. + :keyword location: The Geo-location where the resource lives. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(TrackedResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.tags = tags -class SBNamespace(TrackedResource): +class SBNamespace(TrackedResource): # pylint: disable=too-many-instance-attributes """Description of a namespace resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -1660,9 +1541,9 @@ class SBNamespace(TrackedResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :ivar location: Required. The Geo-location where the resource lives. + :ivar location: The Geo-location where the resource lives. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar sku: Properties of Sku. :vartype sku: ~azure.mgmt.servicebus.v2017_04_01.models.SBSku @@ -1679,48 +1560,43 @@ class SBNamespace(TrackedResource): """ _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}, + "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'}, + "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, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.SBSku"] = None, - **kwargs + self, *, location: str, tags: Optional[Dict[str, str]] = None, sku: Optional["_models.SBSku"] = None, **kwargs ): """ - :keyword location: Required. The Geo-location where the resource lives. + :keyword location: The Geo-location where the resource lives. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword 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) + super().__init__(location=location, tags=tags, **kwargs) self.sku = sku self.provisioning_state = None self.created_at = None @@ -1729,7 +1605,7 @@ def __init__( self.metric_id = None -class SBNamespaceListResult(msrest.serialization.Model): +class SBNamespaceListResult(_serialization.Model): """The response of the List Namespace operation. :ivar value: Result of the List Namespace operation. @@ -1740,16 +1616,12 @@ class SBNamespaceListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SBNamespace]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SBNamespace]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.SBNamespace"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.SBNamespace"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Result of the List Namespace operation. @@ -1758,46 +1630,41 @@ def __init__( list of Namespaces. :paramtype next_link: str """ - super(SBNamespaceListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SBNamespaceMigrate(msrest.serialization.Model): +class SBNamespaceMigrate(_serialization.Model): """Namespace Migrate Object. All required parameters must be populated in order to send to Azure. - :ivar target_namespace_type: Required. Type of namespaces. Known values are: "Messaging", - "NotificationHub", "Mixed", "EventHub", "Relay". + :ivar target_namespace_type: Type of namespaces. Required. Known values are: "Messaging", + "NotificationHub", "Mixed", "EventHub", and "Relay". :vartype target_namespace_type: str or ~azure.mgmt.servicebus.v2017_04_01.models.NameSpaceType """ _validation = { - 'target_namespace_type': {'required': True}, + "target_namespace_type": {"required": True}, } _attribute_map = { - 'target_namespace_type': {'key': 'targetNamespaceType', 'type': 'str'}, + "target_namespace_type": {"key": "targetNamespaceType", "type": "str"}, } - def __init__( - self, - *, - target_namespace_type: Union[str, "_models.NameSpaceType"], - **kwargs - ): + def __init__(self, *, target_namespace_type: Union[str, "_models.NameSpaceType"], **kwargs): """ - :keyword target_namespace_type: Required. Type of namespaces. Known values are: "Messaging", - "NotificationHub", "Mixed", "EventHub", "Relay". + :keyword target_namespace_type: Type of namespaces. Required. Known values are: "Messaging", + "NotificationHub", "Mixed", "EventHub", and "Relay". :paramtype target_namespace_type: str or ~azure.mgmt.servicebus.v2017_04_01.models.NameSpaceType """ - super(SBNamespaceMigrate, self).__init__(**kwargs) + super().__init__(**kwargs) self.target_namespace_type = target_namespace_type -class SBNamespaceUpdateParameters(ResourceNamespacePatch): +class SBNamespaceUpdateParameters(ResourceNamespacePatch): # pylint: disable=too-many-instance-attributes """Description of a namespace resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -1810,7 +1677,7 @@ class SBNamespaceUpdateParameters(ResourceNamespacePatch): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar sku: Properties of Sku. :vartype sku: ~azure.mgmt.servicebus.v2017_04_01.models.SBSku @@ -1827,28 +1694,28 @@ class SBNamespaceUpdateParameters(ResourceNamespacePatch): """ _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}, + "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'}, + "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__( @@ -1862,12 +1729,12 @@ def __init__( """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword 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) + super().__init__(location=location, tags=tags, **kwargs) self.sku = sku self.provisioning_state = None self.created_at = None @@ -1876,7 +1743,7 @@ def __init__( self.metric_id = None -class SBQueue(Resource): +class SBQueue(Resource): # pylint: disable=too-many-instance-attributes """Description of queue Resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -1897,9 +1764,9 @@ class SBQueue(Resource): to this queue. :vartype accessed_at: ~datetime.datetime :ivar size_in_bytes: The size of the queue, in bytes. - :vartype size_in_bytes: long + :vartype size_in_bytes: int :ivar message_count: The number of messages in the queue. - :vartype message_count: long + :vartype message_count: int :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. @@ -1928,7 +1795,7 @@ class SBQueue(Resource): :vartype max_delivery_count: int :ivar status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". + "Deleting", "Renaming", and "Unknown". :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. @@ -1949,45 +1816,48 @@ class SBQueue(Resource): """ _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}, + "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__( + "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": "int"}, + "message_count": {"key": "properties.messageCount", "type": "int"}, + "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__( # pylint: disable=too-many-locals self, *, lock_duration: Optional[datetime.timedelta] = None, @@ -2036,7 +1906,7 @@ def __init__( :paramtype max_delivery_count: int :keyword status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". + "Deleting", "Renaming", and "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. @@ -2056,7 +1926,7 @@ def __init__( message. :paramtype forward_dead_lettered_messages_to: str """ - super(SBQueue, self).__init__(**kwargs) + super().__init__(**kwargs) self.count_details = None self.created_at = None self.updated_at = None @@ -2080,7 +1950,7 @@ def __init__( self.forward_dead_lettered_messages_to = forward_dead_lettered_messages_to -class SBQueueListResult(msrest.serialization.Model): +class SBQueueListResult(_serialization.Model): """The response to the List Queues operation. :ivar value: Result of the List Queues operation. @@ -2091,17 +1961,11 @@ class SBQueueListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SBQueue]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SBQueue]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.SBQueue"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.SBQueue"]] = None, 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] @@ -2109,19 +1973,19 @@ def __init__( list of queues. :paramtype next_link: str """ - super(SBQueueListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SBSku(msrest.serialization.Model): +class SBSku(_serialization.Model): """SKU of the namespace. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Name of this SKU. Known values are: "Basic", "Standard", "Premium". + :ivar name: Name of this SKU. Required. Known values are: "Basic", "Standard", and "Premium". :vartype name: str or ~azure.mgmt.servicebus.v2017_04_01.models.SkuName - :ivar tier: The billing tier of this particular SKU. Known values are: "Basic", "Standard", + :ivar tier: The billing tier of this particular SKU. Known values are: "Basic", "Standard", and "Premium". :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 @@ -2130,13 +1994,13 @@ class SBSku(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'int'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "capacity": {"key": "capacity", "type": "int"}, } def __init__( @@ -2148,22 +2012,23 @@ def __init__( **kwargs ): """ - :keyword name: Required. Name of this SKU. Known values are: "Basic", "Standard", "Premium". + :keyword name: Name of this SKU. Required. Known values are: "Basic", "Standard", and + "Premium". :paramtype name: str or ~azure.mgmt.servicebus.v2017_04_01.models.SkuName :keyword tier: The billing tier of this particular SKU. Known values are: "Basic", "Standard", - "Premium". + and "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) + super().__init__(**kwargs) self.name = name self.tier = tier self.capacity = capacity -class SBSubscription(Resource): +class SBSubscription(Resource): # pylint: disable=too-many-instance-attributes """Description of subscription resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2175,7 +2040,7 @@ class SBSubscription(Resource): :ivar type: Resource type. :vartype type: str :ivar message_count: Number of messages. - :vartype message_count: long + :vartype message_count: int :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. @@ -2206,7 +2071,7 @@ class SBSubscription(Resource): :vartype max_delivery_count: int :ivar status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". + "Deleting", "Renaming", and "Unknown". :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. @@ -2221,37 +2086,43 @@ class SBSubscription(Resource): """ _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}, + "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'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "message_count": {"key": "properties.messageCount", "type": "int"}, + "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__( @@ -2294,7 +2165,7 @@ def __init__( :paramtype max_delivery_count: int :keyword status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". + "Deleting", "Renaming", and "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. @@ -2308,7 +2179,7 @@ def __init__( message. :paramtype forward_dead_lettered_messages_to: str """ - super(SBSubscription, self).__init__(**kwargs) + super().__init__(**kwargs) self.message_count = None self.created_at = None self.accessed_at = None @@ -2328,7 +2199,7 @@ def __init__( self.forward_dead_lettered_messages_to = forward_dead_lettered_messages_to -class SBSubscriptionListResult(msrest.serialization.Model): +class SBSubscriptionListResult(_serialization.Model): """The response to the List Subscriptions operation. :ivar value: Result of the List Subscriptions operation. @@ -2339,16 +2210,12 @@ class SBSubscriptionListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SBSubscription]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SBSubscription]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.SBSubscription"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.SBSubscription"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Result of the List Subscriptions operation. @@ -2357,12 +2224,12 @@ def __init__( list of subscriptions. :paramtype next_link: str """ - super(SBSubscriptionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SBTopic(Resource): +class SBTopic(Resource): # pylint: disable=too-many-instance-attributes """Description of topic resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2374,7 +2241,7 @@ class SBTopic(Resource): :ivar type: Resource type. :vartype type: str :ivar size_in_bytes: Size of the topic, in bytes. - :vartype size_in_bytes: long + :vartype size_in_bytes: int :ivar created_at: Exact time the message was created. :vartype created_at: ~datetime.datetime :ivar updated_at: The exact time the message was updated. @@ -2403,7 +2270,7 @@ class SBTopic(Resource): :vartype enable_batched_operations: bool :ivar status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". + "Deleting", "Renaming", and "Unknown". :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 @@ -2419,37 +2286,40 @@ class SBTopic(Resource): """ _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}, + "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'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "size_in_bytes": {"key": "properties.sizeInBytes", "type": "int"}, + "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__( @@ -2486,7 +2356,7 @@ def __init__( :paramtype enable_batched_operations: bool :keyword status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". + "Deleting", "Renaming", and "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 @@ -2500,7 +2370,7 @@ def __init__( topic holds a message in memory temporarily before writing it to persistent storage. :paramtype enable_express: bool """ - super(SBTopic, self).__init__(**kwargs) + super().__init__(**kwargs) self.size_in_bytes = None self.created_at = None self.updated_at = None @@ -2519,7 +2389,7 @@ def __init__( self.enable_express = enable_express -class SBTopicListResult(msrest.serialization.Model): +class SBTopicListResult(_serialization.Model): """The response to the List Topics operation. :ivar value: Result of the List Topics operation. @@ -2530,17 +2400,11 @@ class SBTopicListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SBTopic]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SBTopic]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.SBTopic"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.SBTopic"]] = None, 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] @@ -2548,12 +2412,12 @@ def __init__( list of topics. :paramtype next_link: str """ - super(SBTopicListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SqlFilter(msrest.serialization.Model): +class SqlFilter(_serialization.Model): """Represents a filter which is a composition of an expression and an action that is executed in the pub/sub pipeline. :ivar sql_expression: The SQL expression. e.g. MyProperty='ABC'. @@ -2567,21 +2431,21 @@ class SqlFilter(msrest.serialization.Model): """ _validation = { - 'compatibility_level': {'maximum': 20, 'minimum': 20}, + "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'}, + "sql_expression": {"key": "sqlExpression", "type": "str"}, + "compatibility_level": {"key": "compatibilityLevel", "type": "int"}, + "requires_preprocessing": {"key": "requiresPreprocessing", "type": "bool"}, } def __init__( self, *, sql_expression: Optional[str] = None, - compatibility_level: Optional[int] = 20, - requires_preprocessing: Optional[bool] = True, + compatibility_level: int = 20, + requires_preprocessing: bool = True, **kwargs ): """ @@ -2594,7 +2458,7 @@ def __init__( preprocessing. :paramtype requires_preprocessing: bool """ - super(SqlFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.sql_expression = sql_expression self.compatibility_level = compatibility_level self.requires_preprocessing = requires_preprocessing @@ -2614,9 +2478,9 @@ class SqlRuleAction(Action): """ _attribute_map = { - 'sql_expression': {'key': 'sqlExpression', 'type': 'str'}, - 'compatibility_level': {'key': 'compatibilityLevel', 'type': 'int'}, - 'requires_preprocessing': {'key': 'requiresPreprocessing', 'type': 'bool'}, + "sql_expression": {"key": "sqlExpression", "type": "str"}, + "compatibility_level": {"key": "compatibilityLevel", "type": "int"}, + "requires_preprocessing": {"key": "requiresPreprocessing", "type": "bool"}, } def __init__( @@ -2624,7 +2488,7 @@ def __init__( *, sql_expression: Optional[str] = None, compatibility_level: Optional[int] = None, - requires_preprocessing: Optional[bool] = True, + requires_preprocessing: bool = True, **kwargs ): """ @@ -2637,35 +2501,35 @@ def __init__( preprocessing. :paramtype requires_preprocessing: bool """ - super(SqlRuleAction, self).__init__(sql_expression=sql_expression, compatibility_level=compatibility_level, requires_preprocessing=requires_preprocessing, **kwargs) + super().__init__( + sql_expression=sql_expression, + compatibility_level=compatibility_level, + requires_preprocessing=requires_preprocessing, + **kwargs + ) -class Subnet(msrest.serialization.Model): +class Subnet(_serialization.Model): """Properties supplied for Subnet. All required parameters must be populated in order to send to Azure. - :ivar id: Required. Resource ID of Virtual Network Subnet. + :ivar id: Resource ID of Virtual Network Subnet. Required. :vartype id: str """ _validation = { - 'id': {'required': True}, + "id": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: str, - **kwargs - ): + def __init__(self, *, id: str, **kwargs): # pylint: disable=redefined-builtin """ - :keyword id: Required. Resource ID of Virtual Network Subnet. + :keyword id: Resource ID of Virtual Network Subnet. Required. :paramtype id: str """ - super(Subnet, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/models/_patch.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/models/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/models/_patch.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/models/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. 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 c1bc966d4444..ccd7445092c7 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 @@ -11,28 +11,29 @@ class AccessRights(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """AccessRights.""" MANAGE = "Manage" SEND = "Send" LISTEN = "Listen" + class DefaultAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Default Action for Network Rule Set - """ + """Default Action for Network Rule Set.""" ALLOW = "Allow" DENY = "Deny" + class EncodingCaptureDescription(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Enumerates the possible values for the encoding format of capture description. - """ + """Enumerates the possible values for the encoding format of capture description.""" AVRO = "Avro" AVRO_DEFLATE = "AvroDeflate" + class EntityStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Entity status. - """ + """Entity status.""" ACTIVE = "Active" DISABLED = "Disabled" @@ -44,27 +45,29 @@ class EntityStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): RENAMING = "Renaming" UNKNOWN = "Unknown" + class FilterType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Rule filter types - """ + """Rule filter types.""" SQL_FILTER = "SqlFilter" CORRELATION_FILTER = "CorrelationFilter" + class KeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The access key to regenerate. - """ + """The access key to regenerate.""" PRIMARY_KEY = "PrimaryKey" SECONDARY_KEY = "SecondaryKey" + class MigrationConfigurationName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """MigrationConfigurationName.""" _DEFAULT = "$default" + class NameSpaceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Type of namespaces - """ + """Type of namespaces.""" MESSAGING = "Messaging" NOTIFICATION_HUB = "NotificationHub" @@ -72,49 +75,51 @@ class NameSpaceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): EVENT_HUB = "EventHub" RELAY = "Relay" + class NetworkRuleIPAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The IP Filter Action - """ + """The IP Filter Action.""" ALLOW = "Allow" + class ProvisioningStateDR(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Provisioning state of the Alias(Disaster Recovery configuration) - possible values 'Accepted' - or 'Succeeded' or 'Failed' + or 'Succeeded' or 'Failed'. """ ACCEPTED = "Accepted" SUCCEEDED = "Succeeded" FAILED = "Failed" + class RoleDisasterRecovery(str, Enum, metaclass=CaseInsensitiveEnumMeta): """role of namespace in GEO DR - possible values 'Primary' or 'PrimaryNotReplicating' or - 'Secondary' + 'Secondary'. """ PRIMARY = "Primary" PRIMARY_NOT_REPLICATING = "PrimaryNotReplicating" SECONDARY = "Secondary" + class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Name of this SKU. - """ + """Name of this SKU.""" BASIC = "Basic" STANDARD = "Standard" PREMIUM = "Premium" + class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The billing tier of this particular SKU. - """ + """The billing tier of this particular SKU.""" BASIC = "Basic" STANDARD = "Standard" PREMIUM = "Premium" + class UnavailableReason(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the reason for the unavailability of the service. - """ + """Specifies the reason for the unavailability of the service.""" NONE = "None" INVALID_NAME = "InvalidName" diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/__init__.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/__init__.py index 02badefef72e..3dac39fcba9c 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/__init__.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/__init__.py @@ -21,18 +21,19 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'NamespacesOperations', - 'QueuesOperations', - 'TopicsOperations', - 'DisasterRecoveryConfigsOperations', - 'EventHubsOperations', - 'MigrationConfigsOperations', - 'Operations', - 'PremiumMessagingRegionsOperations', - 'RulesOperations', - 'RegionsOperations', - 'SubscriptionsOperations', + "NamespacesOperations", + "QueuesOperations", + "TopicsOperations", + "DisasterRecoveryConfigsOperations", + "EventHubsOperations", + "MigrationConfigsOperations", + "Operations", + "PremiumMessagingRegionsOperations", + "RulesOperations", + "RegionsOperations", + "SubscriptionsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() 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 f46ad7068852..cf6971d7116c 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 @@ -6,11 +6,16 @@ # 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, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -20,335 +25,290 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") 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: Optional[_models.CheckNameAvailability] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - resource_group_name: str, - namespace_name: str, - alias: str, - subscription_id: str, - *, - json: Optional[_models.ArmDisasterRecovery] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, alias: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - namespace_name: str, - alias: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, alias: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - namespace_name: str, - alias: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, alias: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_break_pairing_request( - resource_group_name: str, - namespace_name: str, - alias: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, alias: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_fail_over_request( - resource_group_name: str, - namespace_name: str, - alias: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, alias: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_authorization_rules_request( - resource_group_name: str, - namespace_name: str, - alias: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, alias: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_authorization_rule_request( @@ -362,34 +322,35 @@ def build_get_authorization_rule_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( @@ -403,34 +364,36 @@ def build_list_keys_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class DisasterRecoveryConfigsOperations: """ @@ -451,41 +414,102 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace + @overload def check_name_availability( self, resource_group_name: str, namespace_name: str, parameters: _models.CheckNameAvailability, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Check the give namespace name availability. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters to check availability of the given namespace name. + :param parameters: Parameters to check availability of the given namespace name. Required. :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.CheckNameAvailability + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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.v2017_04_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters to check availability of the given namespace name. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameAvailabilityResult, or the result of cls(response) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace + def check_name_availability( + self, + resource_group_name: str, + namespace_name: str, + parameters: Union[_models.CheckNameAvailability, IO], + **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters to check availability of the given namespace name. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.CheckNameAvailability or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :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.v2017_04_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResult] - _json = self._serialize.body(parameters, 'CheckNameAvailability') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CheckNameAvailability") request = build_check_name_availability_request( resource_group_name=resource_group_name, @@ -494,7 +518,8 @@ def check_name_availability( api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) @@ -502,10 +527,9 @@ def check_name_availability( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -513,55 +537,49 @@ def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + 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 - + 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, - namespace_name: str, - **kwargs: Any - ) -> Iterable[_models.ArmDisasterRecoveryListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> Iterable["_models.ArmDisasterRecovery"]: """Gets all Alias(Disaster Recovery configurations). - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: An iterator like instance of either ArmDisasterRecovery or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.ArmDisasterRecoveryListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.ArmDisasterRecovery] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ArmDisasterRecoveryListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -569,16 +587,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -594,10 +607,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -608,49 +619,117 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 + @overload def create_or_update( self, resource_group_name: str, namespace_name: str, alias: str, parameters: _models.ArmDisasterRecovery, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Required. :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.ArmDisasterRecovery + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ArmDisasterRecovery, or the result of cls(response) + :return: ArmDisasterRecovery or None or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.ArmDisasterRecovery or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ArmDisasterRecovery or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.ArmDisasterRecovery or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: Union[_models.ArmDisasterRecovery, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). Is + either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.ArmDisasterRecovery or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ArmDisasterRecovery or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.ArmDisasterRecovery or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ArmDisasterRecovery]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ArmDisasterRecovery]] - _json = self._serialize.body(parameters, 'ArmDisasterRecovery') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ArmDisasterRecovery") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -660,7 +739,8 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -668,10 +748,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -681,56 +760,48 @@ def create_or_update( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ArmDisasterRecovery', pipeline_response) + 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 - + 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: str, - namespace_name: str, - alias: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -738,10 +809,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -752,49 +822,41 @@ def delete( # pylint: disable=inconsistent-return-statements 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: str, - namespace_name: str, - alias: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :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) + :return: ArmDisasterRecovery or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.ArmDisasterRecovery - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ArmDisasterRecovery] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ArmDisasterRecovery] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -802,10 +864,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -813,57 +874,49 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ArmDisasterRecovery', pipeline_response) + 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 - + 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: str, - namespace_name: str, - alias: str, - **kwargs: Any + self, 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. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.break_pairing.metadata["url"], headers=_headers, params=_params, ) @@ -871,10 +924,9 @@ def break_pairing( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -885,49 +937,41 @@ def break_pairing( # pylint: disable=inconsistent-return-statements 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 @distributed_trace def fail_over( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - alias: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[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, - template_url=self.fail_over.metadata['url'], + template_url=self.fail_over.metadata["url"], headers=_headers, params=_params, ) @@ -935,10 +979,9 @@ def fail_over( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -949,52 +992,45 @@ def fail_over( # pylint: disable=inconsistent-return-statements 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, - namespace_name: str, - alias: str, - **kwargs: Any - ) -> Iterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, alias: str, **kwargs: Any + ) -> Iterable["_models.SBAuthorizationRule"]: """Gets the authorization rules for a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :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) + :return: An iterator like instance of either SBAuthorizationRule or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) @@ -1002,17 +1038,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -1028,10 +1058,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1042,48 +1070,38 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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: str, - namespace_name: str, - alias: str, - authorization_rule_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -1091,7 +1109,7 @@ def get_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -1099,10 +1117,9 @@ def get_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1110,52 +1127,43 @@ def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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: str, - namespace_name: str, - alias: str, - authorization_rule_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -1163,7 +1171,7 @@ def list_keys( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1171,10 +1179,9 @@ def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1182,12 +1189,11 @@ def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 - + 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 cb56d50dbebc..da31675d5ac5 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 @@ -7,10 +7,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- 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 urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -20,48 +25,48 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class EventHubsOperations: """ @@ -82,45 +87,39 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_by_namespace( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> Iterable[_models.EventHubListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> Iterable["_models.Eventhub"]: """Gets all the Event Hubs in a service bus Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Eventhub or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.Eventhub] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.EventHubListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_by_namespace.metadata["url"], headers=_headers, params=_params, ) @@ -128,16 +127,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -153,10 +147,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -167,8 +159,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 883b733d3232..936581785e18 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 @@ -6,11 +6,16 @@ # 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, Iterable, Optional, TypeVar, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -22,95 +27,88 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_and_start_migration_request_initial( +def build_create_and_start_migration_request( resource_group_name: str, namespace_name: str, config_name: Union[str, "_models.MigrationConfigurationName"], subscription_id: str, - *, - json: Optional[_models.MigrationConfigProperties] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( @@ -123,33 +121,32 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( @@ -162,33 +159,32 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_complete_migration_request( @@ -201,33 +197,32 @@ def build_complete_migration_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_revert_request( @@ -240,33 +235,33 @@ def build_revert_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class MigrationConfigsOperations: """ @@ -287,46 +282,41 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> Iterable[_models.MigrationConfigListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> Iterable["_models.MigrationConfigProperties"]: """Gets all migrationConfigurations. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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 + :return: An iterator like instance of either MigrationConfigProperties or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.MigrationConfigListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.MigrationConfigProperties] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MigrationConfigListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -334,16 +324,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -359,10 +344,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -373,35 +356,37 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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: str, namespace_name: str, config_name: Union[str, "_models.MigrationConfigurationName"], - parameters: _models.MigrationConfigProperties, + parameters: Union[_models.MigrationConfigProperties, IO], **kwargs: Any ) -> Optional[_models.MigrationConfigProperties]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.MigrationConfigProperties]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.MigrationConfigProperties]] - _json = self._serialize.body(parameters, 'MigrationConfigProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "MigrationConfigProperties") - request = build_create_and_start_migration_request_initial( + request = build_create_and_start_migration_request( resource_group_name=resource_group_name, namespace_name=namespace_name, config_name=config_name, @@ -409,7 +394,8 @@ def _create_and_start_migration_initial( api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_and_start_migration_initial.metadata['url'], + content=_content, + template_url=self._create_and_start_migration_initial.metadata["url"], headers=_headers, params=_params, ) @@ -417,48 +403,92 @@ def _create_and_start_migration_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) + 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 - + _create_and_start_migration_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore - @distributed_trace + @overload def begin_create_and_start_migration( self, resource_group_name: str, namespace_name: str, config_name: Union[str, "_models.MigrationConfigurationName"], parameters: _models.MigrationConfigProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2017_04_01.models.MigrationConfigurationName - :param parameters: Parameters required to create Migration Configuration. + :param parameters: Parameters required to create Migration Configuration. Required. :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.MigrationConfigProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. + :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: + """ + + @overload + def begin_create_and_start_migration( + self, + resource_group_name: str, + namespace_name: str, + config_name: Union[str, "_models.MigrationConfigurationName"], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param config_name: The configuration name. Should always be "$default". "$default" Required. + :type config_name: str or ~azure.mgmt.servicebus.v2017_04_01.models.MigrationConfigurationName + :param parameters: Parameters required to create Migration Configuration. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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 @@ -471,20 +501,56 @@ def begin_create_and_start_migration( of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.servicebus.v2017_04_01.models.MigrationConfigProperties] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_and_start_migration( + self, + resource_group_name: str, + namespace_name: str, + config_name: Union[str, "_models.MigrationConfigurationName"], + parameters: Union[_models.MigrationConfigProperties, IO], + **kwargs: Any + ) -> LROPoller[_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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param config_name: The configuration name. Should always be "$default". "$default" Required. + :type config_name: str or ~azure.mgmt.servicebus.v2017_04_01.models.MigrationConfigurationName + :param parameters: Parameters required to create Migration Configuration. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.MigrationConfigProperties or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.MigrationConfigProperties] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MigrationConfigProperties] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + 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 = self._create_and_start_migration_initial( # type: ignore resource_group_name=resource_group_name, @@ -493,39 +559,35 @@ def begin_create_and_start_migration( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) + deserialized = self._deserialize("MigrationConfigProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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 @@ -537,36 +599,33 @@ def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes a MigrationConfiguration. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2017_04_01.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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -574,10 +633,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -588,8 +646,7 @@ def delete( # pylint: disable=inconsistent-return-statements 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( @@ -601,36 +658,33 @@ def get( ) -> _models.MigrationConfigProperties: """Retrieves Migration Config. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2017_04_01.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) + :return: MigrationConfigProperties or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.MigrationConfigProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MigrationConfigProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MigrationConfigProperties] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -638,10 +692,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -649,15 +702,14 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) + 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 - + 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 @@ -671,36 +723,33 @@ def complete_migration( # pylint: disable=inconsistent-return-statements 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2017_04_01.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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.complete_migration.metadata["url"], headers=_headers, params=_params, ) @@ -708,10 +757,9 @@ def complete_migration( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -722,8 +770,7 @@ def complete_migration( # pylint: disable=inconsistent-return-statements 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 @distributed_trace def revert( # pylint: disable=inconsistent-return-statements @@ -735,36 +782,33 @@ def revert( # pylint: disable=inconsistent-return-statements ) -> None: """This operation reverts Migration. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2017_04_01.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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.revert.metadata["url"], headers=_headers, params=_params, ) @@ -772,10 +816,9 @@ def revert( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -786,5 +829,4 @@ def revert( # pylint: disable=inconsistent-return-statements 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 e5bbab201477..8bc0ff9f022f 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 @@ -6,11 +6,16 @@ # 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, Iterable, Optional, TypeVar, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -22,696 +27,593 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") 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 + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_authorization_rule_request( - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - subscription_id: str, - *, - json: Optional[_models.SBAuthorizationRule] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, authorization_rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_authorization_rule_request( - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, authorization_rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_authorization_rule_request( - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, authorization_rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, authorization_rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_regenerate_keys_request( - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - subscription_id: str, - *, - json: Optional[_models.RegenerateAccessKeyParameters] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, authorization_rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_check_name_availability_request( - subscription_id: str, - *, - json: Optional[_models.CheckNameAvailability] = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: + +def build_check_name_availability_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_migrate_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - *, - json: Optional[_models.SBNamespaceMigrate] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + accept = _headers.pop("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'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_resource_group_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces") # pylint: disable=line-too-long + _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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request_initial( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - *, - json: Optional[_models.SBNamespace] = None, - content: Any = None, - **kwargs: Any +def build_create_or_update_request( + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long + _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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any +def build_delete_request( + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - *, - json: Optional[_models.SBNamespaceUpdateParameters] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_network_rule_set_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - *, - json: Optional[_models.NetworkRuleSet] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_network_rule_set_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_network_rule_sets_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + class NamespacesOperations: """ @@ -732,46 +634,40 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> Iterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> Iterable["_models.SBAuthorizationRule"]: """Gets the authorization rules for a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: An iterator like instance of either SBAuthorizationRule or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) @@ -779,16 +675,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -804,10 +695,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -818,49 +707,115 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 + @overload def create_or_update_authorization_rule( self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, parameters: _models.SBAuthorizationRule, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2017_04_01.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: Union[_models.SBAuthorizationRule, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2017_04_01.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - _json = self._serialize.body(parameters, 'SBAuthorizationRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBAuthorizationRule") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -870,7 +825,8 @@ def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -878,10 +834,9 @@ def create_or_update_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -889,56 +844,48 @@ def create_or_update_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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: str, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -946,10 +893,9 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -960,49 +906,41 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements 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: str, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - 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'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -1010,10 +948,9 @@ def get_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1021,56 +958,48 @@ def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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: str, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - 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'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1078,10 +1007,9 @@ def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1089,53 +1017,120 @@ def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys"} # type: ignore - - @distributed_trace + @overload def regenerate_keys( self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, parameters: _models.RegenerateAccessKeyParameters, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.RegenerateAccessKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2017_04_01.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateAccessKeyParameters, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.RegenerateAccessKeyParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2017_04_01.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateAccessKeyParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -1145,7 +1140,8 @@ def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1153,10 +1149,9 @@ def regenerate_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1164,51 +1159,91 @@ def regenerate_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 + regenerate_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore + @overload + def check_name_availability( + self, parameters: _models.CheckNameAvailability, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param parameters: Parameters to check availability of the given namespace name. Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.CheckNameAvailability + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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.v2017_04_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param parameters: Parameters to check availability of the given namespace name. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :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.v2017_04_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def check_name_availability( - self, - parameters: _models.CheckNameAvailability, - **kwargs: Any + self, parameters: Union[_models.CheckNameAvailability, IO], **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Check the give namespace name availability. - :param parameters: Parameters to check availability of the given namespace name. - :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.CheckNameAvailability + :param parameters: Parameters to check availability of the given namespace name. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.CheckNameAvailability or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameAvailabilityResult, or the result of cls(response) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResult] - _json = self._serialize.body(parameters, 'CheckNameAvailability') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _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'], + content=_content, + template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) @@ -1216,10 +1251,9 @@ def check_name_availability( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1227,50 +1261,111 @@ def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + 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 - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability"} # type: ignore - @distributed_trace + @overload def migrate( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, parameters: _models.SBNamespaceMigrate, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters supplied to migrate namespace type. + :param parameters: Parameters supplied to migrate namespace type. Required. :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.SBNamespaceMigrate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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: + """ + + @overload + def migrate( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to migrate namespace type. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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: + """ + + @distributed_trace + def migrate( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + namespace_name: str, + parameters: Union[_models.SBNamespaceMigrate, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to migrate namespace type. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.SBNamespaceMigrate or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(parameters, 'SBNamespaceMigrate') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBNamespaceMigrate") request = build_migrate_request( resource_group_name=resource_group_name, @@ -1279,7 +1374,8 @@ def migrate( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, json=_json, - template_url=self.migrate.metadata['url'], + content=_content, + template_url=self.migrate.metadata["url"], headers=_headers, params=_params, ) @@ -1287,10 +1383,9 @@ def migrate( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1301,40 +1396,33 @@ def migrate( # pylint: disable=inconsistent-return-statements 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 - ) -> Iterable[_models.SBNamespaceListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.SBNamespace"]: """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] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either SBNamespace or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBNamespace] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespaceListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -1342,14 +1430,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -1365,10 +1450,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1379,47 +1462,38 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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: str, - **kwargs: Any - ) -> Iterable[_models.SBNamespaceListResult]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.SBNamespace"]: """Gets the available namespaces within a resource group. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :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] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either SBNamespace or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBNamespace] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespaceListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -1427,15 +1501,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -1451,10 +1521,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1465,41 +1533,40 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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: str, - namespace_name: str, - parameters: _models.SBNamespace, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, parameters: Union[_models.SBNamespace, IO], **kwargs: Any ) -> Optional[_models.SBNamespace]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.SBNamespace]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.SBNamespace]] - _json = self._serialize.body(parameters, 'SBNamespace') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBNamespace") - request = build_create_or_update_request_initial( + request = build_create_or_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._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1507,48 +1574,88 @@ def _create_or_update_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SBNamespace', pipeline_response) + 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 - + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, namespace_name: str, parameters: _models.SBNamespace, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters supplied to create a namespace resource. + :param parameters: Parameters supplied to create a namespace resource. Required. :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.SBNamespace + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. + :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.v2017_04_01.models.SBNamespace] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to create a namespace resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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 @@ -1560,20 +1667,48 @@ def begin_create_or_update( :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: + """ + + @distributed_trace + def begin_create_or_update( + self, resource_group_name: str, namespace_name: str, parameters: Union[_models.SBNamespace, IO], **kwargs: Any + ) -> LROPoller[_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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to create a namespace resource. Is either a model type + or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.SBNamespace or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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.v2017_04_01.models.SBNamespace] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespace] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBNamespace] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + 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 = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, @@ -1581,64 +1716,54 @@ def begin_create_or_update( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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: str, - namespace_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_request_initial( + request = build_delete_request( 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'], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1646,35 +1771,29 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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_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 @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, 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. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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. @@ -1686,92 +1805,77 @@ def begin_delete( # pylint: disable=inconsistent-return-statements 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + 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 = self._delete_initial( # type: ignore resource_group_name=resource_group_name, namespace_name=namespace_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> _models.SBNamespace: + def get(self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: SBNamespace or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBNamespace - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespace] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBNamespace] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -1779,10 +1883,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1790,51 +1893,114 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBNamespace', pipeline_response) + 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 + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - - @distributed_trace + @overload def update( self, resource_group_name: str, namespace_name: str, parameters: _models.SBNamespaceUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters supplied to update a namespace resource. + :param parameters: Parameters supplied to update a namespace resource. Required. :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.SBNamespaceUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBNamespace, or the result of cls(response) + :return: SBNamespace or None or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBNamespace or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def update( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> 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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to update a namespace resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBNamespace or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBNamespace or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + namespace_name: str, + parameters: Union[_models.SBNamespaceUpdateParameters, IO], + **kwargs: Any + ) -> 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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to update a namespace resource. Is either a model type + or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.SBNamespaceUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBNamespace or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBNamespace or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.SBNamespace]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.SBNamespace]] - _json = self._serialize.body(parameters, 'SBNamespaceUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBNamespaceUpdateParameters") request = build_update_request( resource_group_name=resource_group_name, @@ -1843,7 +2009,8 @@ def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -1851,10 +2018,9 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -1864,53 +2030,113 @@ def update( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SBNamespace', pipeline_response) + 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 - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - @distributed_trace + @overload def create_or_update_network_rule_set( self, resource_group_name: str, namespace_name: str, parameters: _models.NetworkRuleSet, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.NetworkRuleSet: """Create or update NetworkRuleSet for a Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: The Namespace IpFilterRule. + :param parameters: The Namespace IpFilterRule. Required. :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.NetworkRuleSet + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: NetworkRuleSet, or the result of cls(response) + :return: NetworkRuleSet or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.NetworkRuleSet - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def create_or_update_network_rule_set( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NetworkRuleSet: + """Create or update NetworkRuleSet for a Namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: The Namespace IpFilterRule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2017_04_01.models.NetworkRuleSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_network_rule_set( + self, + resource_group_name: str, + namespace_name: str, + parameters: Union[_models.NetworkRuleSet, IO], + **kwargs: Any + ) -> _models.NetworkRuleSet: + """Create or update NetworkRuleSet for a Namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: The Namespace IpFilterRule. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.NetworkRuleSet or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2017_04_01.models.NetworkRuleSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkRuleSet] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.NetworkRuleSet] - _json = self._serialize.body(parameters, 'NetworkRuleSet') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "NetworkRuleSet") request = build_create_or_update_network_rule_set_request( resource_group_name=resource_group_name, @@ -1919,7 +2145,8 @@ def create_or_update_network_rule_set( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_network_rule_set.metadata['url'], + content=_content, + template_url=self.create_or_update_network_rule_set.metadata["url"], headers=_headers, params=_params, ) @@ -1927,10 +2154,9 @@ def create_or_update_network_rule_set( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1938,52 +2164,45 @@ def create_or_update_network_rule_set( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('NetworkRuleSet', pipeline_response) + 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 - + 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: str, - namespace_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: NetworkRuleSet or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.NetworkRuleSet - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkRuleSet] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.NetworkRuleSet] - 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'], + template_url=self.get_network_rule_set.metadata["url"], headers=_headers, params=_params, ) @@ -1991,10 +2210,9 @@ def get_network_rule_set( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -2002,55 +2220,48 @@ def get_network_rule_set( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('NetworkRuleSet', pipeline_response) + 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 - + 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, - namespace_name: str, - **kwargs: Any - ) -> Iterable[_models.NetworkRuleSetListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> Iterable["_models.NetworkRuleSet"]: """Gets list of NetworkRuleSet for a Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either NetworkRuleSet or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.NetworkRuleSet] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkRuleSetListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_network_rule_sets.metadata["url"], headers=_headers, params=_params, ) @@ -2058,16 +2269,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -2083,10 +2289,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2097,8 +2301,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 d45dbc6315d6..46d97178c0de 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 @@ -7,10 +7,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- 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 urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -20,38 +25,34 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +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: + +def build_list_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.ServiceBus/operations") # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class Operations: """ @@ -72,36 +73,30 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.OperationListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """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] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -109,13 +104,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -131,10 +124,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -145,8 +136,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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/_patch.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_patch.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2017_04_01/operations/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. 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 ff17dfe25d29..82bbfaffd53a 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 @@ -7,10 +7,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- 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 urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -20,44 +25,41 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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: + +def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/premiumMessagingRegions") # pylint: disable=line-too-long + _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'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class PremiumMessagingRegionsOperations: """ @@ -78,38 +80,33 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.PremiumMessagingRegionsListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.PremiumMessagingRegions"]: """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 + :return: An iterator like instance of either PremiumMessagingRegions or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.PremiumMessagingRegionsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.PremiumMessagingRegions] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PremiumMessagingRegionsListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -117,14 +114,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -140,10 +134,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -154,8 +146,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 979a0614b863..8f282a1258ad 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 @@ -6,11 +6,16 @@ # 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, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -20,50 +25,48 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") 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 + resource_group_name: str, namespace_name: str, queue_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_authorization_rule_request( @@ -72,47 +75,43 @@ def build_create_or_update_authorization_rule_request( queue_name: str, authorization_rule_name: str, subscription_id: str, - *, - json: Optional[_models.SBAuthorizationRule] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_authorization_rule_request( @@ -126,34 +125,35 @@ def build_delete_authorization_rule_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_authorization_rule_request( @@ -167,34 +167,35 @@ def build_get_authorization_rule_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( @@ -208,34 +209,35 @@ def build_list_keys_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_regenerate_keys_request( @@ -244,47 +246,43 @@ def build_regenerate_keys_request( queue_name: str, authorization_rule_name: str, subscription_id: str, - *, - json: Optional[_models.RegenerateAccessKeyParameters] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_namespace_request( @@ -299,161 +297,141 @@ def build_list_by_namespace_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if skip is not None: - _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', maximum=1000, minimum=0) + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", maximum=1000, minimum=0) if top is not None: - _params['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - resource_group_name: str, - namespace_name: str, - queue_name: str, - subscription_id: str, - *, - json: Optional[_models.SBQueue] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, queue_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - namespace_name: str, - queue_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, queue_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - namespace_name: str, - queue_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, queue_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class QueuesOperations: """ @@ -474,50 +452,43 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - **kwargs: Any - ) -> Iterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, queue_name: str, **kwargs: Any + ) -> Iterable["_models.SBAuthorizationRule"]: """Gets all authorization rules for a queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :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) + :return: An iterator like instance of either SBAuthorizationRule or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) @@ -525,17 +496,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -551,10 +516,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -565,13 +528,11 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 + @overload def create_or_update_authorization_rule( self, resource_group_name: str, @@ -579,38 +540,112 @@ def create_or_update_authorization_rule( queue_name: str, authorization_rule_name: str, parameters: _models.SBAuthorizationRule, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBAuthorizationRule: """Creates an authorization rule for a queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for a queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2017_04_01.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: Union[_models.SBAuthorizationRule, IO], + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for a queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2017_04_01.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - _json = self._serialize.body(parameters, 'SBAuthorizationRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBAuthorizationRule") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -621,7 +656,8 @@ def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -629,10 +665,9 @@ def create_or_update_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -640,15 +675,14 @@ def create_or_update_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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 @@ -661,31 +695,28 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes a queue authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -693,7 +724,7 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_authorization_rule.metadata['url'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -701,10 +732,9 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -715,8 +745,7 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements 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( @@ -729,31 +758,28 @@ def get_authorization_rule( ) -> _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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -761,7 +787,7 @@ def get_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -769,10 +795,9 @@ def get_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -780,15 +805,14 @@ def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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( @@ -801,31 +825,28 @@ def list_keys( ) -> _models.AccessKeys: """Primary and secondary connection strings to the queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -833,7 +854,7 @@ def list_keys( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -841,10 +862,9 @@ def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -852,17 +872,16 @@ def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore - - @distributed_trace + @overload def regenerate_keys( self, resource_group_name: str, @@ -870,38 +889,112 @@ def regenerate_keys( queue_name: str, authorization_rule_name: str, parameters: _models.RegenerateAccessKeyParameters, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.RegenerateAccessKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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.v2017_04_01.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateAccessKeyParameters, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.RegenerateAccessKeyParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2017_04_01.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateAccessKeyParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -912,7 +1005,8 @@ def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) @@ -920,10 +1014,9 @@ def regenerate_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -931,15 +1024,14 @@ def regenerate_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 - + 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( @@ -949,12 +1041,12 @@ def list_by_namespace( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable[_models.SBQueueListResult]: + ) -> Iterable["_models.SBQueue"]: """Gets the queues within a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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 @@ -964,32 +1056,30 @@ def list_by_namespace( 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] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either SBQueue or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBQueue] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBQueueListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + api_version=api_version, + template_url=self.list_by_namespace.metadata["url"], headers=_headers, params=_params, ) @@ -997,18 +1087,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -1024,10 +1107,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1038,49 +1119,115 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 + @overload def create_or_update( self, resource_group_name: str, namespace_name: str, queue_name: str, parameters: _models.SBQueue, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param parameters: Parameters supplied to create or update a queue resource. + :param parameters: Parameters supplied to create or update a queue resource. Required. :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.SBQueue + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBQueue, or the result of cls(response) + :return: SBQueue or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param parameters: Parameters supplied to create or update a queue resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2017_04_01.models.SBQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + parameters: Union[_models.SBQueue, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param parameters: Parameters supplied to create or update a queue resource. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.SBQueue or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2017_04_01.models.SBQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBQueue] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBQueue] - _json = self._serialize.body(parameters, 'SBQueue') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBQueue") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -1090,7 +1237,8 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -1098,10 +1246,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1109,56 +1256,48 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBQueue', pipeline_response) + 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 - + 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: str, - namespace_name: str, - queue_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -1166,10 +1305,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1180,49 +1318,39 @@ def delete( # pylint: disable=inconsistent-return-statements 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: str, - namespace_name: str, - queue_name: str, - **kwargs: Any - ) -> _models.SBQueue: + def get(self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :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) + :return: SBQueue or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBQueue] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBQueue] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -1230,10 +1358,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1241,12 +1368,11 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBQueue', pipeline_response) + 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 - + 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 d0b4fce6a80d..59ac029f802d 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 @@ -7,10 +7,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- 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 urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -20,46 +25,42 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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: + +def build_list_by_sku_request(sku: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/sku/{sku}/regions") + _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), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + class RegionsOperations: """ @@ -80,42 +81,36 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list_by_sku( - self, - sku: str, - **kwargs: Any - ) -> Iterable[_models.PremiumMessagingRegionsListResult]: + def list_by_sku(self, sku: str, **kwargs: Any) -> Iterable["_models.PremiumMessagingRegions"]: """Gets the available Regions for a given sku. - :param sku: The sku type. + :param sku: The sku type. Required. :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 + :return: An iterator like instance of either PremiumMessagingRegions or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.PremiumMessagingRegionsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.PremiumMessagingRegions] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PremiumMessagingRegionsListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_sku_request( - subscription_id=self._config.subscription_id, sku=sku, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_sku.metadata['url'], + template_url=self.list_by_sku.metadata["url"], headers=_headers, params=_params, ) @@ -123,15 +118,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_sku_request( - subscription_id=self._config.subscription_id, - sku=sku, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -147,10 +138,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -161,8 +150,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 29ff6684739f..357d68caa7c0 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 @@ -6,11 +6,16 @@ # 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, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -20,13 +25,16 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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_subscriptions_request( resource_group_name: str, namespace_name: str, @@ -41,38 +49,37 @@ def build_list_by_subscriptions_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if skip is not None: - _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', maximum=1000, minimum=0) + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", maximum=1000, minimum=0) if top is not None: - _params['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( @@ -82,48 +89,42 @@ def build_create_or_update_request( subscription_name: str, rule_name: str, subscription_id: str, - *, - json: Optional[_models.Rule] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( @@ -138,35 +139,34 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( @@ -181,35 +181,35 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class RulesOperations: """ @@ -230,7 +230,6 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_by_subscriptions( self, @@ -241,16 +240,16 @@ def list_by_subscriptions( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable[_models.RuleListResult]: + ) -> Iterable["_models.Rule"]: """List all the rules within given topic-subscription. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :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 @@ -260,33 +259,32 @@ def list_by_subscriptions( 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 + :return: An iterator like instance of either Rule or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.Rule] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.RuleListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + api_version=api_version, + template_url=self.list_by_subscriptions.metadata["url"], headers=_headers, params=_params, ) @@ -294,20 +292,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -323,10 +312,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -337,13 +324,11 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 + @overload def create_or_update( self, resource_group_name: str, @@ -352,40 +337,120 @@ def create_or_update( subscription_name: str, rule_name: str, parameters: _models.Rule, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param rule_name: The rule name. + :param rule_name: The rule name. Required. :type rule_name: str - :param parameters: Parameters supplied to create a rule. + :param parameters: Parameters supplied to create a rule. Required. :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.Rule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Rule, or the result of cls(response) + :return: Rule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.Rule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param rule_name: The rule name. Required. + :type rule_name: str + :param parameters: Parameters supplied to create a rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2017_04_01.models.Rule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + parameters: Union[_models.Rule, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param rule_name: The rule name. Required. + :type rule_name: str + :param parameters: Parameters supplied to create a rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.Rule or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2017_04_01.models.Rule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Rule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Rule] - _json = self._serialize.body(parameters, 'Rule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Rule") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -397,7 +462,8 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -405,10 +471,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -416,15 +481,14 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Rule', pipeline_response) + 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 - + 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 @@ -438,33 +502,30 @@ def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes an existing rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param rule_name: The rule name. + :param rule_name: The rule name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -473,7 +534,7 @@ def delete( # pylint: disable=inconsistent-return-statements rule_name=rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -481,10 +542,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -495,8 +555,7 @@ def delete( # pylint: disable=inconsistent-return-statements 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( @@ -510,33 +569,30 @@ def get( ) -> _models.Rule: """Retrieves the description for the specified rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param rule_name: The rule name. + :param rule_name: The rule name. Required. :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) + :return: Rule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.Rule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Rule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Rule] - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -545,7 +601,7 @@ def get( rule_name=rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -553,10 +609,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -564,12 +619,11 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Rule', pipeline_response) + 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 - + 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 3a7086fd12db..60a6bbc5f3f6 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 @@ -6,11 +6,16 @@ # 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, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -20,13 +25,16 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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_topic_request( resource_group_name: str, namespace_name: str, @@ -40,37 +48,36 @@ def build_list_by_topic_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if skip is not None: - _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', maximum=1000, minimum=0) + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", maximum=1000, minimum=0) if top is not None: - _params['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( @@ -79,47 +86,41 @@ def build_create_or_update_request( topic_name: str, subscription_name: str, subscription_id: str, - *, - json: Optional[_models.SBSubscription] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( @@ -133,34 +134,33 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( @@ -174,34 +174,34 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class SubscriptionsOperations: """ @@ -222,7 +222,6 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_by_topic( self, @@ -232,14 +231,14 @@ def list_by_topic( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable[_models.SBSubscriptionListResult]: + ) -> Iterable["_models.SBSubscription"]: """List all the subscriptions under a specified topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :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 @@ -249,34 +248,31 @@ def list_by_topic( 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] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either SBSubscription or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBSubscription] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBSubscriptionListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + api_version=api_version, + template_url=self.list_by_topic.metadata["url"], headers=_headers, params=_params, ) @@ -284,19 +280,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -312,10 +300,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -326,13 +312,11 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 + @overload def create_or_update( self, resource_group_name: str, @@ -340,38 +324,112 @@ def create_or_update( topic_name: str, subscription_name: str, parameters: _models.SBSubscription, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBSubscription: """Creates a topic subscription. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param parameters: Parameters supplied to create a subscription resource. + :param parameters: Parameters supplied to create a subscription resource. Required. :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.SBSubscription + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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.v2017_04_01.models.SBSubscription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBSubscription: + """Creates a topic subscription. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param parameters: Parameters supplied to create a subscription resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2017_04_01.models.SBSubscription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + parameters: Union[_models.SBSubscription, IO], + **kwargs: Any + ) -> _models.SBSubscription: + """Creates a topic subscription. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param parameters: Parameters supplied to create a subscription resource. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.SBSubscription or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBSubscription, or the result of cls(response) + :return: SBSubscription or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBSubscription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBSubscription] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBSubscription] - _json = self._serialize.body(parameters, 'SBSubscription') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBSubscription") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -382,7 +440,8 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -390,10 +449,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -401,52 +459,43 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBSubscription', pipeline_response) + 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 - + 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: str, - namespace_name: str, - topic_name: str, - subscription_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -454,7 +503,7 @@ def delete( # pylint: disable=inconsistent-return-statements subscription_name=subscription_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -462,10 +511,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -476,45 +524,36 @@ def delete( # pylint: disable=inconsistent-return-statements 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: str, - namespace_name: str, - topic_name: str, - subscription_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :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) + :return: SBSubscription or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBSubscription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBSubscription] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBSubscription] - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -522,7 +561,7 @@ def get( subscription_name=subscription_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -530,10 +569,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -541,12 +579,11 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBSubscription', pipeline_response) + 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 - + 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 11c7c9d66fe2..9fb92fc379e3 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 @@ -6,11 +6,16 @@ # 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, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -20,50 +25,48 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") 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 + resource_group_name: str, namespace_name: str, topic_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_authorization_rule_request( @@ -72,47 +75,43 @@ def build_create_or_update_authorization_rule_request( topic_name: str, authorization_rule_name: str, subscription_id: str, - *, - json: Optional[_models.SBAuthorizationRule] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_authorization_rule_request( @@ -126,34 +125,35 @@ def build_get_authorization_rule_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_authorization_rule_request( @@ -167,34 +167,35 @@ def build_delete_authorization_rule_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( @@ -208,34 +209,35 @@ def build_list_keys_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_regenerate_keys_request( @@ -244,47 +246,43 @@ def build_regenerate_keys_request( topic_name: str, authorization_rule_name: str, subscription_id: str, - *, - json: Optional[_models.RegenerateAccessKeyParameters] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_namespace_request( @@ -299,161 +297,141 @@ def build_list_by_namespace_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if skip is not None: - _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', maximum=1000, minimum=0) + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", maximum=1000, minimum=0) if top is not None: - _params['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_id: str, - *, - json: Optional[_models.SBTopic] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, topic_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, topic_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, topic_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class TopicsOperations: """ @@ -474,50 +452,43 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - **kwargs: Any - ) -> Iterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, topic_name: str, **kwargs: Any + ) -> Iterable["_models.SBAuthorizationRule"]: """Gets authorization rules for a topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :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) + :return: An iterator like instance of either SBAuthorizationRule or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) @@ -525,17 +496,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -551,10 +516,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -565,13 +528,11 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 + @overload def create_or_update_authorization_rule( self, resource_group_name: str, @@ -579,38 +540,112 @@ def create_or_update_authorization_rule( topic_name: str, authorization_rule_name: str, parameters: _models.SBAuthorizationRule, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2017_04_01.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: Union[_models.SBAuthorizationRule, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2017_04_01.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - _json = self._serialize.body(parameters, 'SBAuthorizationRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBAuthorizationRule") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -621,7 +656,8 @@ def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -629,10 +665,9 @@ def create_or_update_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -640,15 +675,14 @@ def create_or_update_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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( @@ -661,31 +695,28 @@ def get_authorization_rule( ) -> _models.SBAuthorizationRule: """Returns the specified authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -693,7 +724,7 @@ def get_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -701,10 +732,9 @@ def get_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -712,15 +742,14 @@ def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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 @@ -733,31 +762,28 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes a topic authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -765,7 +791,7 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_authorization_rule.metadata['url'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -773,10 +799,9 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -787,8 +812,7 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements 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( @@ -801,31 +825,28 @@ def list_keys( ) -> _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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -833,7 +854,7 @@ def list_keys( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -841,10 +862,9 @@ def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -852,17 +872,16 @@ def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore - - @distributed_trace + @overload def regenerate_keys( self, resource_group_name: str, @@ -870,38 +889,112 @@ def regenerate_keys( topic_name: str, authorization_rule_name: str, parameters: _models.RegenerateAccessKeyParameters, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.RegenerateAccessKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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.v2017_04_01.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateAccessKeyParameters, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.RegenerateAccessKeyParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2017_04_01.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateAccessKeyParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -912,7 +1005,8 @@ def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) @@ -920,10 +1014,9 @@ def regenerate_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -931,15 +1024,14 @@ def regenerate_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 - + 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( @@ -949,12 +1041,12 @@ def list_by_namespace( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable[_models.SBTopicListResult]: + ) -> Iterable["_models.SBTopic"]: """Gets all the topics in a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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 @@ -964,32 +1056,30 @@ def list_by_namespace( 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] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either SBTopic or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2017_04_01.models.SBTopic] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBTopicListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + api_version=api_version, + template_url=self.list_by_namespace.metadata["url"], headers=_headers, params=_params, ) @@ -997,18 +1087,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -1024,10 +1107,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1038,49 +1119,115 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 + @overload def create_or_update( self, resource_group_name: str, namespace_name: str, topic_name: str, parameters: _models.SBTopic, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBTopic: """Creates a topic in the specified namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param parameters: Parameters supplied to create a topic resource. + :param parameters: Parameters supplied to create a topic resource. Required. :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.SBTopic + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBTopic, or the result of cls(response) + :return: SBTopic or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBTopic - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBTopic: + """Creates a topic in the specified namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param parameters: Parameters supplied to create a topic resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2017_04_01.models.SBTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + parameters: Union[_models.SBTopic, IO], + **kwargs: Any + ) -> _models.SBTopic: + """Creates a topic in the specified namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param parameters: Parameters supplied to create a topic resource. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2017_04_01.models.SBTopic or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2017_04_01.models.SBTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBTopic] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBTopic] - _json = self._serialize.body(parameters, 'SBTopic') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBTopic") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -1090,7 +1237,8 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -1098,10 +1246,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1109,56 +1256,48 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBTopic', pipeline_response) + 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 - + 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: str, - namespace_name: str, - topic_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -1166,10 +1305,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1180,49 +1318,39 @@ def delete( # pylint: disable=inconsistent-return-statements 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: str, - namespace_name: str, - topic_name: str, - **kwargs: Any - ) -> _models.SBTopic: + def get(self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :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) + :return: SBTopic or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2017_04_01.models.SBTopic - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBTopic] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBTopic] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -1230,10 +1358,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1241,12 +1368,11 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBTopic', pipeline_response) + 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 - + 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 221541a00fb6..2a82b6cb6f69 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 @@ -17,7 +17,8 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['ServiceBusManagementClient'] + +__all__ = ["ServiceBusManagementClient"] __all__.extend([p for p in _patch_all if p not in __all__]) _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 3c8663a0c0b6..52498dd19fcd 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 @@ -25,24 +25,19 @@ class ServiceBusManagementClientConfiguration(Configuration): # pylint: disable Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :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. + subscription. The subscription ID forms part of the URI for every service call. Required. :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: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, 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 + api_version = kwargs.pop("api_version", "2018-01-01-preview") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -52,23 +47,24 @@ def __init__( self.credential = credential self.subscription_id = subscription_id 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.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-servicebus/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> None - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(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 6a6601651a9e..b48a59bbe4d6 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 @@ -10,20 +10,20 @@ "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\"], \"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\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ServiceBusManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ServiceBusManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", + "signature": "subscription_id: str,", + "description": "Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", + "description": "Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false 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 index 0ad201a8c586..f7dd32510333 100644 --- 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 @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. 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 fd3c7382e5a3..4cf933c7d45b 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 @@ -9,20 +9,34 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import ServiceBusManagementClientConfiguration -from .operations import DisasterRecoveryConfigsOperations, EventHubsOperations, MigrationConfigsOperations, NamespacesOperations, Operations, PremiumMessagingRegionsOperations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, QueuesOperations, RegionsOperations, RulesOperations, SubscriptionsOperations, TopicsOperations +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: # pylint: disable=too-many-instance-attributes + +class ServiceBusManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Azure Service Bus client for managing Namespace, IPFilter Rules, VirtualNetworkRules and Zone Redundant. @@ -58,10 +72,10 @@ class ServiceBusManagementClient: # pylint: disable=too-many-instance-attribu :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. + :param credential: Credential needed for the client to connect to Azure. Required. :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. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -79,16 +93,16 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ServiceBusManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + 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._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.namespaces = NamespacesOperations( - 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 ) @@ -98,40 +112,21 @@ def __init__( 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.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.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: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -140,7 +135,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest 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 index 138f663c53a4..9aad73fc743e 100644 --- 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 @@ -7,6 +7,7 @@ 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) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): 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 - ] + 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 920456322fa1..9f1dc6e309ba 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 = "8.1.0" +VERSION = "0.0.0 (it should be stable)" 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 e7dd87df1f93..ba757410f14a 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 @@ -14,7 +14,8 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['ServiceBusManagementClient'] + +__all__ = ["ServiceBusManagementClient"] __all__.extend([p for p in _patch_all if p not in __all__]) _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 6808f4a0adc0..87ced630ad37 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 @@ -25,24 +25,19 @@ class ServiceBusManagementClientConfiguration(Configuration): # pylint: disable Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :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. + subscription. The subscription ID forms part of the URI for every service call. Required. :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: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(ServiceBusManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + api_version = kwargs.pop("api_version", "2018-01-01-preview") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -52,22 +47,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id 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.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-servicebus/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, - **kwargs: Any - ) -> None: - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(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 index 0ad201a8c586..f7dd32510333 100644 --- 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 @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. 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 14922a368644..ee0c0a7e8766 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 @@ -9,20 +9,34 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import ServiceBusManagementClientConfiguration -from .operations import DisasterRecoveryConfigsOperations, EventHubsOperations, MigrationConfigsOperations, NamespacesOperations, Operations, PremiumMessagingRegionsOperations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, QueuesOperations, RegionsOperations, RulesOperations, SubscriptionsOperations, TopicsOperations +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: # pylint: disable=too-many-instance-attributes + +class ServiceBusManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Azure Service Bus client for managing Namespace, IPFilter Rules, VirtualNetworkRules and Zone Redundant. @@ -60,10 +74,10 @@ class ServiceBusManagementClient: # pylint: disable=too-many-instance-attribu :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. + :param credential: Credential needed for the client to connect to Azure. Required. :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. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -81,16 +95,16 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ServiceBusManagementClientConfiguration(credential=credential, subscription_id=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._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.namespaces = NamespacesOperations( - 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 ) @@ -100,40 +114,21 @@ def __init__( 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.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.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 - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -142,7 +137,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/__init__.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/__init__.py index a21798eafb6a..75b6b102d52b 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/__init__.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/__init__.py @@ -23,20 +23,21 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'NamespacesOperations', - 'PrivateEndpointConnectionsOperations', - 'PrivateLinkResourcesOperations', - 'DisasterRecoveryConfigsOperations', - 'QueuesOperations', - 'TopicsOperations', - 'EventHubsOperations', - 'MigrationConfigsOperations', - 'PremiumMessagingRegionsOperations', - 'RegionsOperations', - 'SubscriptionsOperations', - 'RulesOperations', - 'Operations', + "NamespacesOperations", + "PrivateEndpointConnectionsOperations", + "PrivateLinkResourcesOperations", + "DisasterRecoveryConfigsOperations", + "QueuesOperations", + "TopicsOperations", + "EventHubsOperations", + "MigrationConfigsOperations", + "PremiumMessagingRegionsOperations", + "RegionsOperations", + "SubscriptionsOperations", + "RulesOperations", + "Operations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() 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 b5580e25977e..9bb7df76964f 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 @@ -6,10 +6,17 @@ # 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, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +27,23 @@ 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') +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]] + class DisasterRecoveryConfigsOperations: """ .. warning:: @@ -43,41 +63,102 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async + @overload async def check_name_availability( self, resource_group_name: str, namespace_name: str, parameters: _models.CheckNameAvailability, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Check the give namespace name availability. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters to check availability of the given namespace name. + :param parameters: Parameters to check availability of the given namespace name. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.CheckNameAvailability + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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.v2018_01_01_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters to check availability of the given namespace name. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :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.v2018_01_01_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, + resource_group_name: str, + namespace_name: str, + parameters: Union[_models.CheckNameAvailability, IO], + **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters to check availability of the given namespace name. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.CheckNameAvailability or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameAvailabilityResult, or the result of cls(response) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResult] - _json = self._serialize.body(parameters, 'CheckNameAvailability') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CheckNameAvailability") request = build_check_name_availability_request( resource_group_name=resource_group_name, @@ -86,7 +167,8 @@ async def check_name_availability( api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) @@ -94,10 +176,9 @@ async def check_name_availability( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -105,55 +186,49 @@ async def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + 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 - + 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, - namespace_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.ArmDisasterRecoveryListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ArmDisasterRecovery"]: """Gets all Alias(Disaster Recovery configurations). - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: An iterator like instance of either ArmDisasterRecovery 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 + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.ArmDisasterRecovery] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ArmDisasterRecoveryListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -161,16 +236,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -186,10 +256,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -200,49 +268,117 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 + @overload async def create_or_update( self, resource_group_name: str, namespace_name: str, alias: str, parameters: _models.ArmDisasterRecovery, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.ArmDisasterRecovery + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ArmDisasterRecovery or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.ArmDisasterRecovery or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ArmDisasterRecovery, or the result of cls(response) + :return: ArmDisasterRecovery or None or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.ArmDisasterRecovery or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: Union[_models.ArmDisasterRecovery, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). Is + either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.ArmDisasterRecovery or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ArmDisasterRecovery or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.ArmDisasterRecovery or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ArmDisasterRecovery]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ArmDisasterRecovery]] - _json = self._serialize.body(parameters, 'ArmDisasterRecovery') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ArmDisasterRecovery") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -252,7 +388,8 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -260,10 +397,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -273,56 +409,48 @@ async def create_or_update( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ArmDisasterRecovery', pipeline_response) + 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 - + 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, - alias: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -330,10 +458,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -344,49 +471,41 @@ async def delete( # pylint: disable=inconsistent-return-statements 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, - namespace_name: str, - alias: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :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) + :return: ArmDisasterRecovery or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.ArmDisasterRecovery - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ArmDisasterRecovery] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ArmDisasterRecovery] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -394,10 +513,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -405,57 +523,49 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ArmDisasterRecovery', pipeline_response) + 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 - + 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, - alias: str, - **kwargs: Any + self, 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. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.break_pairing.metadata["url"], headers=_headers, params=_params, ) @@ -463,10 +573,9 @@ async def break_pairing( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -477,50 +586,118 @@ async def break_pairing( # pylint: disable=inconsistent-return-statements 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 - @distributed_trace_async + @overload async def fail_over( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, alias: str, parameters: Optional[_models.FailoverProperties] = None, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :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 content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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: + """ + + @overload + async def fail_over( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Default value is None. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace_async + async def fail_over( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: Optional[Union[_models.FailoverProperties, IO]] = 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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). Is + either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.FailoverProperties or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - if parameters is not None: - _json = self._serialize.body(parameters, 'FailoverProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "FailoverProperties") + else: + _json = None request = build_fail_over_request( resource_group_name=resource_group_name, @@ -530,7 +707,8 @@ async def fail_over( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, json=_json, - template_url=self.fail_over.metadata['url'], + content=_content, + template_url=self.fail_over.metadata["url"], headers=_headers, params=_params, ) @@ -538,10 +716,9 @@ async def fail_over( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -552,52 +729,45 @@ async def fail_over( # pylint: disable=inconsistent-return-statements 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, - namespace_name: str, - alias: str, - **kwargs: Any - ) -> AsyncIterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, alias: str, **kwargs: Any + ) -> AsyncIterable["_models.SBAuthorizationRule"]: """Gets the authorization rules for a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :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) + :return: An iterator like instance of either SBAuthorizationRule 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 + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) @@ -605,17 +775,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -631,10 +795,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -645,48 +807,38 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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, - namespace_name: str, - alias: str, - authorization_rule_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -694,7 +846,7 @@ async def get_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -702,10 +854,9 @@ async def get_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -713,52 +864,43 @@ async def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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, - namespace_name: str, - alias: str, - authorization_rule_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -766,7 +908,7 @@ async def list_keys( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -774,10 +916,9 @@ async def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -785,12 +926,11 @@ async def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 - + 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 3a22807df094..b856a89e3981 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 @@ -7,9 +7,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +27,11 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._event_hubs_operations import build_list_by_namespace_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class EventHubsOperations: """ .. warning:: @@ -42,45 +51,40 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_by_namespace( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.EventHubListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Eventhub"]: """Gets all the Event Hubs in a service bus Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: An iterator like instance of either Eventhub or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.EventHubListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.Eventhub] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.EventHubListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_by_namespace.metadata["url"], headers=_headers, params=_params, ) @@ -88,16 +92,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -113,10 +112,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -127,8 +124,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 e0e6603c1964..a35652688a9c 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 @@ -6,10 +6,17 @@ # 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, Optional, TypeVar, Union, cast +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +29,19 @@ 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') +from ...operations._migration_configs_operations import ( + build_complete_migration_request, + build_create_and_start_migration_request, + 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]] + class MigrationConfigsOperations: """ .. warning:: @@ -45,46 +61,41 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.MigrationConfigListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.MigrationConfigProperties"]: """Gets all migrationConfigurations. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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 + :return: An iterator like instance of either MigrationConfigProperties 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 + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigProperties] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MigrationConfigListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -92,16 +103,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -117,10 +123,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -131,35 +135,37 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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, resource_group_name: str, namespace_name: str, config_name: Union[str, "_models.MigrationConfigurationName"], - parameters: _models.MigrationConfigProperties, + parameters: Union[_models.MigrationConfigProperties, IO], **kwargs: Any ) -> Optional[_models.MigrationConfigProperties]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.MigrationConfigProperties]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.MigrationConfigProperties]] - _json = self._serialize.body(parameters, 'MigrationConfigProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "MigrationConfigProperties") - request = build_create_and_start_migration_request_initial( + request = build_create_and_start_migration_request( resource_group_name=resource_group_name, namespace_name=namespace_name, config_name=config_name, @@ -167,7 +173,8 @@ async def _create_and_start_migration_initial( api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_and_start_migration_initial.metadata['url'], + content=_content, + template_url=self._create_and_start_migration_initial.metadata["url"], headers=_headers, params=_params, ) @@ -175,27 +182,108 @@ async def _create_and_start_migration_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) + 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 + _create_and_start_migration_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore + @overload + async def begin_create_and_start_migration( + self, + resource_group_name: str, + namespace_name: str, + config_name: Union[str, "_models.MigrationConfigurationName"], + parameters: _models.MigrationConfigProperties, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> 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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param config_name: The configuration name. Should always be "$default". "$default" Required. + :type config_name: str or + ~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigurationName + :param parameters: Parameters required to create Migration Configuration. Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. + :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: + """ + + @overload + async def begin_create_and_start_migration( + self, + resource_group_name: str, + namespace_name: str, + config_name: Union[str, "_models.MigrationConfigurationName"], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> 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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param config_name: The configuration name. Should always be "$default". "$default" Required. + :type config_name: str or + ~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigurationName + :param parameters: Parameters required to create Migration Configuration. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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: + """ @distributed_trace_async async def begin_create_and_start_migration( @@ -203,21 +291,26 @@ async def begin_create_and_start_migration( resource_group_name: str, namespace_name: str, config_name: Union[str, "_models.MigrationConfigurationName"], - parameters: _models.MigrationConfigProperties, + parameters: Union[_models.MigrationConfigProperties, IO], **kwargs: Any ) -> 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigurationName - :param parameters: Parameters required to create Migration Configuration. + :param parameters: Parameters required to create Migration Configuration. Is either a model + type or a IO type. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigProperties + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -230,20 +323,17 @@ async def begin_create_and_start_migration( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigProperties] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.MigrationConfigProperties] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MigrationConfigProperties] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + 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( # type: ignore resource_group_name=resource_group_name, @@ -252,39 +342,35 @@ async def begin_create_and_start_migration( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) + deserialized = self._deserialize("MigrationConfigProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, 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 + deserialization_callback=get_long_running_output, ) 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 + begin_create_and_start_migration.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -296,37 +382,34 @@ async def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes a MigrationConfiguration. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -334,10 +417,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -348,8 +430,7 @@ async def delete( # pylint: disable=inconsistent-return-statements 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( @@ -361,37 +442,34 @@ async def get( ) -> _models.MigrationConfigProperties: """Retrieves Migration Config. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :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) + :return: MigrationConfigProperties or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MigrationConfigProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MigrationConfigProperties] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -399,10 +477,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -410,15 +487,14 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) + 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 - + 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 @@ -432,37 +508,34 @@ async def complete_migration( # pylint: disable=inconsistent-return-statements 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.complete_migration.metadata["url"], headers=_headers, params=_params, ) @@ -470,10 +543,9 @@ async def complete_migration( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -484,8 +556,7 @@ async def complete_migration( # pylint: disable=inconsistent-return-statements 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 @distributed_trace_async async def revert( # pylint: disable=inconsistent-return-statements @@ -497,37 +568,34 @@ async def revert( # pylint: disable=inconsistent-return-statements ) -> None: """This operation reverts Migration. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.revert.metadata["url"], headers=_headers, params=_params, ) @@ -535,10 +603,9 @@ async def revert( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -549,5 +616,4 @@ async def revert( # pylint: disable=inconsistent-return-statements 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 9f0518438612..096829b870d4 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 @@ -6,10 +6,17 @@ # 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, Optional, TypeVar, Union, cast +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +29,38 @@ 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') +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, + build_create_or_update_virtual_network_rule_request, + build_delete_authorization_rule_request, + build_delete_ip_filter_rule_request, + build_delete_request, + 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: # pylint: disable=too-many-public-methods """ .. warning:: @@ -45,46 +80,40 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_ip_filter_rules( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.IpFilterRuleListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.IpFilterRule"]: """Gets a list of IP Filter rules for a Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: An iterator like instance of either IpFilterRule 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 + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.IpFilterRule] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.IpFilterRuleListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_ip_filter_rules.metadata["url"], headers=_headers, params=_params, ) @@ -92,16 +121,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -117,10 +141,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -131,49 +153,114 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 + @overload async def create_or_update_ip_filter_rule( self, resource_group_name: str, namespace_name: str, ip_filter_rule_name: str, parameters: _models.IpFilterRule, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param ip_filter_rule_name: The IP Filter Rule name. + :param ip_filter_rule_name: The IP Filter Rule name. Required. :type ip_filter_rule_name: str - :param parameters: The Namespace IpFilterRule. + :param parameters: The Namespace IpFilterRule. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.IpFilterRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IpFilterRule, or the result of cls(response) + :return: IpFilterRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.IpFilterRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + async def create_or_update_ip_filter_rule( + self, + resource_group_name: str, + namespace_name: str, + ip_filter_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param ip_filter_rule_name: The IP Filter Rule name. Required. + :type ip_filter_rule_name: str + :param parameters: The Namespace IpFilterRule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2018_01_01_preview.models.IpFilterRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_ip_filter_rule( + self, + resource_group_name: str, + namespace_name: str, + ip_filter_rule_name: str, + parameters: Union[_models.IpFilterRule, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param ip_filter_rule_name: The IP Filter Rule name. Required. + :type ip_filter_rule_name: str + :param parameters: The Namespace IpFilterRule. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.IpFilterRule or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2018_01_01_preview.models.IpFilterRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.IpFilterRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IpFilterRule] - _json = self._serialize.body(parameters, 'IpFilterRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "IpFilterRule") request = build_create_or_update_ip_filter_rule_request( resource_group_name=resource_group_name, @@ -183,7 +270,8 @@ async def create_or_update_ip_filter_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_ip_filter_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_ip_filter_rule.metadata["url"], headers=_headers, params=_params, ) @@ -191,10 +279,9 @@ async def create_or_update_ip_filter_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -202,56 +289,48 @@ async def create_or_update_ip_filter_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('IpFilterRule', pipeline_response) + 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 - + 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, - ip_filter_rule_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param ip_filter_rule_name: The IP Filter Rule name. + :param ip_filter_rule_name: The IP Filter Rule name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.delete_ip_filter_rule.metadata["url"], headers=_headers, params=_params, ) @@ -259,10 +338,9 @@ async def delete_ip_filter_rule( # pylint: disable=inconsistent-return-statemen request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -273,49 +351,41 @@ async def delete_ip_filter_rule( # pylint: disable=inconsistent-return-statemen 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, - namespace_name: str, - ip_filter_rule_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param ip_filter_rule_name: The IP Filter Rule name. + :param ip_filter_rule_name: The IP Filter Rule name. Required. :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) + :return: IpFilterRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.IpFilterRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.IpFilterRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IpFilterRule] - 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'], + template_url=self.get_ip_filter_rule.metadata["url"], headers=_headers, params=_params, ) @@ -323,10 +393,9 @@ async def get_ip_filter_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -334,47 +403,41 @@ async def get_ip_filter_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('IpFilterRule', pipeline_response) + 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 - + 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 - ) -> AsyncIterable[_models.SBNamespaceListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.SBNamespace"]: """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) + :return: An iterator like instance of either SBNamespace 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 + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespace] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespaceListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -382,14 +445,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -405,10 +465,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -419,47 +477,39 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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, - **kwargs: Any - ) -> AsyncIterable[_models.SBNamespaceListResult]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.SBNamespace"]: """Gets the available namespaces within a resource group. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :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) + :return: An iterator like instance of either SBNamespace 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 + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespace] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespaceListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -467,15 +517,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -491,10 +537,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -505,41 +549,40 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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, - resource_group_name: str, - namespace_name: str, - parameters: _models.SBNamespace, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, parameters: Union[_models.SBNamespace, IO], **kwargs: Any ) -> Optional[_models.SBNamespace]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.SBNamespace]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.SBNamespace]] - _json = self._serialize.body(parameters, 'SBNamespace') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBNamespace") - request = build_create_or_update_request_initial( + request = build_create_or_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._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) @@ -547,48 +590,52 @@ async def _create_or_update_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SBNamespace', pipeline_response) + 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 - + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - @distributed_trace_async + @overload async def begin_create_or_update( self, resource_group_name: str, namespace_name: str, parameters: _models.SBNamespace, + *, + content_type: str = "application/json", **kwargs: Any ) -> 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters supplied to create a namespace resource. + :param parameters: Parameters supplied to create a namespace resource. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespace + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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 @@ -601,20 +648,86 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespace] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> 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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to create a namespace resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, resource_group_name: str, namespace_name: str, parameters: Union[_models.SBNamespace, IO], **kwargs: Any + ) -> 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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to create a namespace resource. Is either a model type + or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespace or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespace] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBNamespace] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + 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( # type: ignore resource_group_name=resource_group_name, @@ -622,64 +735,54 @@ async def begin_create_or_update( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, 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 + deserialization_callback=get_long_running_output, ) 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 + 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, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_request_initial( + request = build_delete_request( 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'], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) @@ -687,35 +790,29 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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_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 @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete(self, resource_group_name: str, namespace_name: str, **kwargs: Any) -> 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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. @@ -727,92 +824,77 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + 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( # type: ignore resource_group_name=resource_group_name, namespace_name=namespace_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, 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 + deserialization_callback=get_long_running_output, ) 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 + 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, - namespace_name: str, - **kwargs: Any - ) -> _models.SBNamespace: + async def get(self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: SBNamespace or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespace - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespace] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBNamespace] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -820,10 +902,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -831,51 +912,115 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBNamespace', pipeline_response) + 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 + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + namespace_name: str, + parameters: _models.SBNamespaceUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> 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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to update a namespace resource. Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespaceUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBNamespace or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespace or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def update( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> 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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to update a namespace resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBNamespace or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespace or None + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def update( self, resource_group_name: str, namespace_name: str, - parameters: _models.SBNamespaceUpdateParameters, + parameters: Union[_models.SBNamespaceUpdateParameters, IO], **kwargs: Any ) -> 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters supplied to update a namespace resource. + :param parameters: Parameters supplied to update a namespace resource. Is either a model type + or a IO type. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespaceUpdateParameters + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBNamespace, or the result of cls(response) + :return: SBNamespace or None or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespace or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.SBNamespace]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.SBNamespace]] - _json = self._serialize.body(parameters, 'SBNamespaceUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBNamespaceUpdateParameters") request = build_update_request( resource_group_name=resource_group_name, @@ -884,7 +1029,8 @@ async def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -892,10 +1038,9 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -905,58 +1050,52 @@ async def update( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SBNamespace', pipeline_response) + 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 - + 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, - namespace_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.VirtualNetworkRuleListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.VirtualNetworkRule"]: """Gets a list of VirtualNetwork rules for a Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: An iterator like instance of either VirtualNetworkRule 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 + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.VirtualNetworkRule] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualNetworkRuleListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_virtual_network_rules.metadata["url"], headers=_headers, params=_params, ) @@ -964,16 +1103,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -989,10 +1123,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1003,49 +1135,115 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 + @overload async def create_or_update_virtual_network_rule( self, resource_group_name: str, namespace_name: str, virtual_network_rule_name: str, parameters: _models.VirtualNetworkRule, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param virtual_network_rule_name: The Virtual Network Rule name. + :param virtual_network_rule_name: The Virtual Network Rule name. Required. :type virtual_network_rule_name: str - :param parameters: The Namespace VirtualNetworkRule. + :param parameters: The Namespace VirtualNetworkRule. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.VirtualNetworkRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: VirtualNetworkRule, or the result of cls(response) + :return: VirtualNetworkRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.VirtualNetworkRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + async def create_or_update_virtual_network_rule( + self, + resource_group_name: str, + namespace_name: str, + virtual_network_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param virtual_network_rule_name: The Virtual Network Rule name. Required. + :type virtual_network_rule_name: str + :param parameters: The Namespace VirtualNetworkRule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2018_01_01_preview.models.VirtualNetworkRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_virtual_network_rule( + self, + resource_group_name: str, + namespace_name: str, + virtual_network_rule_name: str, + parameters: Union[_models.VirtualNetworkRule, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param virtual_network_rule_name: The Virtual Network Rule name. Required. + :type virtual_network_rule_name: str + :param parameters: The Namespace VirtualNetworkRule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.VirtualNetworkRule or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2018_01_01_preview.models.VirtualNetworkRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualNetworkRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.VirtualNetworkRule] - _json = self._serialize.body(parameters, 'VirtualNetworkRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "VirtualNetworkRule") request = build_create_or_update_virtual_network_rule_request( resource_group_name=resource_group_name, @@ -1055,7 +1253,8 @@ async def create_or_update_virtual_network_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_virtual_network_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_virtual_network_rule.metadata["url"], headers=_headers, params=_params, ) @@ -1063,10 +1262,9 @@ async def create_or_update_virtual_network_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1074,56 +1272,48 @@ async def create_or_update_virtual_network_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('VirtualNetworkRule', pipeline_response) + 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 - + 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, - virtual_network_rule_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param virtual_network_rule_name: The Virtual Network Rule name. + :param virtual_network_rule_name: The Virtual Network Rule name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.delete_virtual_network_rule.metadata["url"], headers=_headers, params=_params, ) @@ -1131,10 +1321,9 @@ async def delete_virtual_network_rule( # pylint: disable=inconsistent-return-st request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1145,49 +1334,41 @@ async def delete_virtual_network_rule( # pylint: disable=inconsistent-return-st 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, - namespace_name: str, - virtual_network_rule_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param virtual_network_rule_name: The Virtual Network Rule name. + :param virtual_network_rule_name: The Virtual Network Rule name. Required. :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) + :return: VirtualNetworkRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.VirtualNetworkRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualNetworkRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.VirtualNetworkRule] - 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'], + template_url=self.get_virtual_network_rule.metadata["url"], headers=_headers, params=_params, ) @@ -1195,10 +1376,9 @@ async def get_virtual_network_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1206,55 +1386,49 @@ async def get_virtual_network_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('VirtualNetworkRule', pipeline_response) + 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 - + 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, - namespace_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SBAuthorizationRule"]: """Gets the authorization rules for a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: An iterator like instance of either SBAuthorizationRule 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 + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) @@ -1262,16 +1436,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -1287,10 +1456,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1301,49 +1468,115 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 + @overload async def create_or_update_authorization_rule( self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, parameters: _models.SBAuthorizationRule, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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.v2018_01_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace_async + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: Union[_models.SBAuthorizationRule, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2018_01_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - _json = self._serialize.body(parameters, 'SBAuthorizationRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBAuthorizationRule") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -1353,7 +1586,8 @@ async def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -1361,10 +1595,9 @@ async def create_or_update_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1372,56 +1605,48 @@ async def create_or_update_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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, - authorization_rule_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -1429,10 +1654,9 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1443,49 +1667,41 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat 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, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - 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'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -1493,10 +1709,9 @@ async def get_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1504,56 +1719,48 @@ async def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - 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'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1561,10 +1768,9 @@ async def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1572,54 +1778,122 @@ async def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys"} # type: ignore - - @distributed_trace_async + @overload async def regenerate_keys( self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, parameters: _models.RegenerateAccessKeyParameters, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.RegenerateAccessKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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.v2018_01_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2018_01_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateAccessKeyParameters, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: + ~azure.mgmt.servicebus.v2018_01_01_preview.models.RegenerateAccessKeyParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateAccessKeyParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -1629,7 +1903,8 @@ async def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1637,10 +1912,9 @@ async def regenerate_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1648,51 +1922,91 @@ async def regenerate_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 + regenerate_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore + @overload + async def check_name_availability( + self, parameters: _models.CheckNameAvailability, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param parameters: Parameters to check availability of the given namespace name. Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.CheckNameAvailability + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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.v2018_01_01_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param parameters: Parameters to check availability of the given namespace name. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :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.v2018_01_01_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def check_name_availability( - self, - parameters: _models.CheckNameAvailability, - **kwargs: Any + self, parameters: Union[_models.CheckNameAvailability, IO], **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Check the give namespace name availability. - :param parameters: Parameters to check availability of the given namespace name. - :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.CheckNameAvailability + :param parameters: Parameters to check availability of the given namespace name. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.CheckNameAvailability or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameAvailabilityResult, or the result of cls(response) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResult] - _json = self._serialize.body(parameters, 'CheckNameAvailability') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _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'], + content=_content, + template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) @@ -1700,10 +2014,9 @@ async def check_name_availability( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1711,50 +2024,110 @@ async def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + 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 - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability"} # type: ignore - @distributed_trace_async + @overload async def create_or_update_network_rule_set( self, resource_group_name: str, namespace_name: str, parameters: _models.NetworkRuleSet, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.NetworkRuleSet: """Create or update NetworkRuleSet for a Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: The Namespace IpFilterRule. + :param parameters: The Namespace IpFilterRule. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.NetworkRuleSet + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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.v2018_01_01_preview.models.NetworkRuleSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_network_rule_set( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NetworkRuleSet: + """Create or update NetworkRuleSet for a Namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: The Namespace IpFilterRule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2018_01_01_preview.models.NetworkRuleSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_network_rule_set( + self, + resource_group_name: str, + namespace_name: str, + parameters: Union[_models.NetworkRuleSet, IO], + **kwargs: Any + ) -> _models.NetworkRuleSet: + """Create or update NetworkRuleSet for a Namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: The Namespace IpFilterRule. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.NetworkRuleSet or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: NetworkRuleSet, or the result of cls(response) + :return: NetworkRuleSet or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.NetworkRuleSet - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkRuleSet] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.NetworkRuleSet] - _json = self._serialize.body(parameters, 'NetworkRuleSet') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "NetworkRuleSet") request = build_create_or_update_network_rule_set_request( resource_group_name=resource_group_name, @@ -1763,7 +2136,8 @@ async def create_or_update_network_rule_set( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_network_rule_set.metadata['url'], + content=_content, + template_url=self.create_or_update_network_rule_set.metadata["url"], headers=_headers, params=_params, ) @@ -1771,10 +2145,9 @@ async def create_or_update_network_rule_set( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1782,52 +2155,45 @@ async def create_or_update_network_rule_set( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('NetworkRuleSet', pipeline_response) + 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 - + 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, - namespace_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: NetworkRuleSet or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.NetworkRuleSet - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkRuleSet] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.NetworkRuleSet] - 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'], + template_url=self.get_network_rule_set.metadata["url"], headers=_headers, params=_params, ) @@ -1835,10 +2201,9 @@ async def get_network_rule_set( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1846,55 +2211,49 @@ async def get_network_rule_set( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('NetworkRuleSet', pipeline_response) + 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 - + 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, - namespace_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.NetworkRuleSetListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.NetworkRuleSet"]: """Gets list of NetworkRuleSet for a Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: An iterator like instance of either NetworkRuleSet 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 + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.NetworkRuleSet] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkRuleSetListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_network_rule_sets.metadata["url"], headers=_headers, params=_params, ) @@ -1902,16 +2261,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -1927,10 +2281,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1941,46 +2293,106 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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_async + @overload async def migrate( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, parameters: _models.SBNamespaceMigrate, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters supplied to migrate namespace type. + :param parameters: Parameters supplied to migrate namespace type. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespaceMigrate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + async def migrate( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to migrate namespace type. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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: + """ + + @distributed_trace_async + async def migrate( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + namespace_name: str, + parameters: Union[_models.SBNamespaceMigrate, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to migrate namespace type. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespaceMigrate or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(parameters, 'SBNamespaceMigrate') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBNamespaceMigrate") request = build_migrate_request( resource_group_name=resource_group_name, @@ -1989,7 +2401,8 @@ async def migrate( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, json=_json, - template_url=self.migrate.metadata['url'], + content=_content, + template_url=self.migrate.metadata["url"], headers=_headers, params=_params, ) @@ -1997,10 +2410,9 @@ async def migrate( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -2011,5 +2423,4 @@ async def migrate( # pylint: disable=inconsistent-return-statements 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 f8ab56066078..849e773e4a74 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 @@ -7,9 +7,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +27,11 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class Operations: """ .. warning:: @@ -42,36 +51,31 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.OperationListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """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) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -79,13 +83,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -101,10 +103,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -115,8 +115,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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/_patch.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_patch.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/aio/operations/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. 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 03b00dcbcaaf..6ae79d115b7c 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 @@ -7,9 +7,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +27,11 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._premium_messaging_regions_operations import build_list_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class PremiumMessagingRegionsOperations: """ .. warning:: @@ -42,38 +51,33 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.PremiumMessagingRegionsListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.PremiumMessagingRegions"]: """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 + :return: An iterator like instance of either PremiumMessagingRegions 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 + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.PremiumMessagingRegions] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PremiumMessagingRegionsListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -81,14 +85,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -104,10 +105,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -118,8 +117,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 1e16f39f953a..00bffce7f271 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 @@ -6,10 +6,17 @@ # 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, Optional, TypeVar, Union, cast +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +29,17 @@ 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') +from ...operations._private_endpoint_connections_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class PrivateEndpointConnectionsOperations: """ .. warning:: @@ -45,46 +59,41 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.PrivateEndpointConnectionListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PrivateEndpointConnection"]: """Gets the available PrivateEndpointConnections within a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: An iterator like instance of either PrivateEndpointConnection 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 + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnectionListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -92,16 +101,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -117,10 +121,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -131,60 +133,129 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 + @overload async def create_or_update( self, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, parameters: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.PrivateEndpointConnection: """Creates or updates PrivateEndpointConnections of service namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param private_endpoint_connection_name: The PrivateEndpointConnection name. + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. :type private_endpoint_connection_name: str :param parameters: Parameters supplied to update Status of PrivateEndPoint Connection to - namespace resource. + namespace resource. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.PrivateEndpointConnection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateEndpointConnection, or the result of cls(response) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Creates or updates PrivateEndpointConnections of service namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. + :type private_endpoint_connection_name: str + :param parameters: Parameters supplied to update Status of PrivateEndPoint Connection to + namespace resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2018_01_01_preview.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + parameters: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Creates or updates PrivateEndpointConnections of service namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. + :type private_endpoint_connection_name: str + :param parameters: Parameters supplied to update Status of PrivateEndPoint Connection to + namespace resource. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.PrivateEndpointConnection + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2018_01_01_preview.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - _json = self._serialize.body(parameters, 'PrivateEndpointConnection') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _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, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -192,10 +263,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -204,45 +274,37 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + 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 - + 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, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_request_initial( + request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, - subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) @@ -250,37 +312,32 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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_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 @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes an existing Private Endpoint Connection. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param private_endpoint_connection_name: The PrivateEndpointConnection name. + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. :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. @@ -292,97 +349,83 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + 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( # type: ignore 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, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, 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 + deserialization_callback=get_long_running_output, ) 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 + 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, - namespace_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param private_endpoint_connection_name: The PrivateEndpointConnection name. + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. :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) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -390,10 +433,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -401,12 +443,11 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + 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 - + 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 69a99ba81b3c..9c1a1613ae68 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 @@ -8,7 +8,13 @@ # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Optional, TypeVar -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -19,9 +25,11 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._private_link_resources_operations import build_get_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class PrivateLinkResourcesOperations: """ .. warning:: @@ -41,43 +49,36 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async async def get( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: PrivateLinkResourcesListResult or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.PrivateLinkResourcesListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourcesListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResourcesListResult] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -85,10 +86,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -96,12 +96,11 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateLinkResourcesListResult', pipeline_response) + 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 - + 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 b62f75b67b4b..0c8138362be4 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 @@ -6,10 +6,17 @@ # 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, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +27,23 @@ 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') +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]] + class QueuesOperations: """ .. warning:: @@ -43,50 +63,43 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, queue_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SBAuthorizationRule"]: """Gets all authorization rules for a queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :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) + :return: An iterator like instance of either SBAuthorizationRule 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 + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) @@ -94,17 +107,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -120,10 +127,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -134,13 +139,11 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 + @overload async def create_or_update_authorization_rule( self, resource_group_name: str, @@ -148,38 +151,112 @@ async def create_or_update_authorization_rule( queue_name: str, authorization_rule_name: str, parameters: _models.SBAuthorizationRule, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBAuthorizationRule: """Creates an authorization rule for a queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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.v2018_01_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for a queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace_async + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: Union[_models.SBAuthorizationRule, IO], + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for a queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2018_01_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - _json = self._serialize.body(parameters, 'SBAuthorizationRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBAuthorizationRule") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -190,7 +267,8 @@ async def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -198,10 +276,9 @@ async def create_or_update_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -209,15 +286,14 @@ async def create_or_update_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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 @@ -230,31 +306,28 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat ) -> None: """Deletes a queue authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -262,7 +335,7 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_authorization_rule.metadata['url'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -270,10 +343,9 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -284,8 +356,7 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat 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( @@ -298,31 +369,28 @@ async def get_authorization_rule( ) -> _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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -330,7 +398,7 @@ async def get_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -338,10 +406,9 @@ async def get_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -349,15 +416,14 @@ async def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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( @@ -370,31 +436,28 @@ async def list_keys( ) -> _models.AccessKeys: """Primary and secondary connection strings to the queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -402,7 +465,7 @@ async def list_keys( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -410,10 +473,9 @@ async def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -421,17 +483,16 @@ async def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 - + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore - @distributed_trace_async + @overload async def regenerate_keys( self, resource_group_name: str, @@ -439,39 +500,114 @@ async def regenerate_keys( queue_name: str, authorization_rule_name: str, parameters: _models.RegenerateAccessKeyParameters, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.RegenerateAccessKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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.v2018_01_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2018_01_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateAccessKeyParameters, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: + ~azure.mgmt.servicebus.v2018_01_01_preview.models.RegenerateAccessKeyParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateAccessKeyParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -482,7 +618,8 @@ async def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) @@ -490,10 +627,9 @@ async def regenerate_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -501,15 +637,14 @@ async def regenerate_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 - + 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( @@ -519,12 +654,12 @@ def list_by_namespace( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable[_models.SBQueueListResult]: + ) -> AsyncIterable["_models.SBQueue"]: """Gets the queues within a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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 @@ -534,32 +669,31 @@ def list_by_namespace( 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) + :return: An iterator like instance of either SBQueue or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBQueueListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBQueue] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBQueueListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + api_version=api_version, + template_url=self.list_by_namespace.metadata["url"], headers=_headers, params=_params, ) @@ -567,18 +701,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -594,10 +721,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -608,49 +733,115 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 + @overload async def create_or_update( self, resource_group_name: str, namespace_name: str, queue_name: str, parameters: _models.SBQueue, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param parameters: Parameters supplied to create or update a queue resource. + :param parameters: Parameters supplied to create or update a queue resource. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBQueue + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBQueue, or the result of cls(response) + :return: SBQueue or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param parameters: Parameters supplied to create or update a queue resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2018_01_01_preview.models.SBQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + parameters: Union[_models.SBQueue, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param parameters: Parameters supplied to create or update a queue resource. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBQueue or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2018_01_01_preview.models.SBQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBQueue] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBQueue] - _json = self._serialize.body(parameters, 'SBQueue') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBQueue") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -660,7 +851,8 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -668,10 +860,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -679,56 +870,48 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBQueue', pipeline_response) + 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 - + 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, - queue_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -736,10 +919,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -750,49 +932,41 @@ async def delete( # pylint: disable=inconsistent-return-statements 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, - namespace_name: str, - queue_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :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) + :return: SBQueue or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBQueue] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBQueue] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -800,10 +974,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -811,12 +984,11 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBQueue', pipeline_response) + 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 - + 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 f946843d4e8b..1d6f88bd14e5 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 @@ -7,9 +7,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +27,11 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._regions_operations import build_list_by_sku_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class RegionsOperations: """ .. warning:: @@ -42,42 +51,36 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list_by_sku( - self, - sku: str, - **kwargs: Any - ) -> AsyncIterable[_models.PremiumMessagingRegionsListResult]: + def list_by_sku(self, sku: str, **kwargs: Any) -> AsyncIterable["_models.PremiumMessagingRegions"]: """Gets the available Regions for a given sku. - :param sku: The sku type. + :param sku: The sku type. Required. :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 + :return: An iterator like instance of either PremiumMessagingRegions 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 + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.PremiumMessagingRegions] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PremiumMessagingRegionsListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_sku_request( - subscription_id=self._config.subscription_id, sku=sku, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_sku.metadata['url'], + template_url=self.list_by_sku.metadata["url"], headers=_headers, params=_params, ) @@ -85,15 +88,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_sku_request( - subscription_id=self._config.subscription_id, - sku=sku, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -109,10 +108,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -123,8 +120,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 77b438181854..4301b030de87 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 @@ -6,10 +6,17 @@ # 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, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +27,17 @@ 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') +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]] + class RulesOperations: """ .. warning:: @@ -43,7 +57,6 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_by_subscriptions( self, @@ -54,16 +67,16 @@ def list_by_subscriptions( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable[_models.RuleListResult]: + ) -> AsyncIterable["_models.Rule"]: """List all the rules within given topic-subscription. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :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 @@ -73,34 +86,33 @@ def list_by_subscriptions( 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) + :return: An iterator like instance of either Rule or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.RuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.Rule] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.RuleListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + api_version=api_version, + template_url=self.list_by_subscriptions.metadata["url"], headers=_headers, params=_params, ) @@ -108,20 +120,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -137,10 +140,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -151,13 +152,11 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 + @overload async def create_or_update( self, resource_group_name: str, @@ -166,40 +165,120 @@ async def create_or_update( subscription_name: str, rule_name: str, parameters: _models.Rule, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param rule_name: The rule name. + :param rule_name: The rule name. Required. :type rule_name: str - :param parameters: Parameters supplied to create a rule. + :param parameters: Parameters supplied to create a rule. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.Rule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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.v2018_01_01_preview.models.Rule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param rule_name: The rule name. Required. + :type rule_name: str + :param parameters: Parameters supplied to create a rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2018_01_01_preview.models.Rule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + parameters: Union[_models.Rule, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param rule_name: The rule name. Required. + :type rule_name: str + :param parameters: Parameters supplied to create a rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.Rule or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Rule, or the result of cls(response) + :return: Rule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.Rule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Rule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Rule] - _json = self._serialize.body(parameters, 'Rule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Rule") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -211,7 +290,8 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -219,10 +299,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -230,15 +309,14 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Rule', pipeline_response) + 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 - + 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 @@ -252,33 +330,30 @@ async def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes an existing rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param rule_name: The rule name. + :param rule_name: The rule name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -287,7 +362,7 @@ async def delete( # pylint: disable=inconsistent-return-statements rule_name=rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -295,10 +370,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -309,8 +383,7 @@ async def delete( # pylint: disable=inconsistent-return-statements 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( @@ -324,33 +397,30 @@ async def get( ) -> _models.Rule: """Retrieves the description for the specified rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param rule_name: The rule name. + :param rule_name: The rule name. Required. :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) + :return: Rule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.Rule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Rule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Rule] - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -359,7 +429,7 @@ async def get( rule_name=rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -367,10 +437,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -378,12 +447,11 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Rule', pipeline_response) + 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 - + 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 5c61d6d6e7f8..847683618bcf 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 @@ -6,10 +6,17 @@ # 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, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +27,17 @@ 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') +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]] + class SubscriptionsOperations: """ .. warning:: @@ -43,7 +57,6 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_by_topic( self, @@ -53,14 +66,14 @@ def list_by_topic( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable[_models.SBSubscriptionListResult]: + ) -> AsyncIterable["_models.SBSubscription"]: """List all the subscriptions under a specified topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :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 @@ -70,34 +83,32 @@ def list_by_topic( 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) + :return: An iterator like instance of either SBSubscription 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 + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBSubscription] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBSubscriptionListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + api_version=api_version, + template_url=self.list_by_topic.metadata["url"], headers=_headers, params=_params, ) @@ -105,19 +116,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -133,10 +136,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -147,13 +148,11 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 + @overload async def create_or_update( self, resource_group_name: str, @@ -161,38 +160,112 @@ async def create_or_update( topic_name: str, subscription_name: str, parameters: _models.SBSubscription, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBSubscription: """Creates a topic subscription. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param parameters: Parameters supplied to create a subscription resource. + :param parameters: Parameters supplied to create a subscription resource. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBSubscription + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBSubscription, or the result of cls(response) + :return: SBSubscription or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBSubscription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBSubscription: + """Creates a topic subscription. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param parameters: Parameters supplied to create a subscription resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2018_01_01_preview.models.SBSubscription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + parameters: Union[_models.SBSubscription, IO], + **kwargs: Any + ) -> _models.SBSubscription: + """Creates a topic subscription. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param parameters: Parameters supplied to create a subscription resource. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBSubscription or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2018_01_01_preview.models.SBSubscription + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBSubscription] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBSubscription] - _json = self._serialize.body(parameters, 'SBSubscription') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBSubscription") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -203,7 +276,8 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -211,10 +285,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -222,52 +295,43 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBSubscription', pipeline_response) + 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 - + 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, - topic_name: str, - subscription_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -275,7 +339,7 @@ async def delete( # pylint: disable=inconsistent-return-statements subscription_name=subscription_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -283,10 +347,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -297,45 +360,36 @@ async def delete( # pylint: disable=inconsistent-return-statements 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, - namespace_name: str, - topic_name: str, - subscription_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :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) + :return: SBSubscription or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBSubscription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBSubscription] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBSubscription] - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -343,7 +397,7 @@ async def get( subscription_name=subscription_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -351,10 +405,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -362,12 +415,11 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBSubscription', pipeline_response) + 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 - + 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 e1551fb4e9f6..a6ee8799d0e9 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 @@ -6,10 +6,17 @@ # 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, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +27,23 @@ 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') +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]] + class TopicsOperations: """ .. warning:: @@ -43,50 +63,43 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, topic_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SBAuthorizationRule"]: """Gets authorization rules for a topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :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) + :return: An iterator like instance of either SBAuthorizationRule 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 + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) @@ -94,17 +107,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -120,10 +127,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -134,13 +139,11 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 + @overload async def create_or_update_authorization_rule( self, resource_group_name: str, @@ -148,38 +151,112 @@ async def create_or_update_authorization_rule( topic_name: str, authorization_rule_name: str, parameters: _models.SBAuthorizationRule, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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.v2018_01_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace_async + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: Union[_models.SBAuthorizationRule, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2018_01_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - _json = self._serialize.body(parameters, 'SBAuthorizationRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBAuthorizationRule") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -190,7 +267,8 @@ async def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -198,10 +276,9 @@ async def create_or_update_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -209,15 +286,14 @@ async def create_or_update_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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( @@ -230,31 +306,28 @@ async def get_authorization_rule( ) -> _models.SBAuthorizationRule: """Returns the specified authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -262,7 +335,7 @@ async def get_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -270,10 +343,9 @@ async def get_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -281,15 +353,14 @@ async def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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 @@ -302,31 +373,28 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat ) -> None: """Deletes a topic authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -334,7 +402,7 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_authorization_rule.metadata['url'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -342,10 +410,9 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -356,8 +423,7 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat 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( @@ -370,31 +436,28 @@ async def list_keys( ) -> _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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -402,7 +465,7 @@ async def list_keys( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -410,10 +473,9 @@ async def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -421,17 +483,16 @@ async def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 - + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore - @distributed_trace_async + @overload async def regenerate_keys( self, resource_group_name: str, @@ -439,39 +500,114 @@ async def regenerate_keys( topic_name: str, authorization_rule_name: str, parameters: _models.RegenerateAccessKeyParameters, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.RegenerateAccessKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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.v2018_01_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2018_01_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateAccessKeyParameters, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: + ~azure.mgmt.servicebus.v2018_01_01_preview.models.RegenerateAccessKeyParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateAccessKeyParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -482,7 +618,8 @@ async def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) @@ -490,10 +627,9 @@ async def regenerate_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -501,15 +637,14 @@ async def regenerate_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 - + 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( @@ -519,12 +654,12 @@ def list_by_namespace( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable[_models.SBTopicListResult]: + ) -> AsyncIterable["_models.SBTopic"]: """Gets all the topics in a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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 @@ -534,32 +669,31 @@ def list_by_namespace( 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) + :return: An iterator like instance of either SBTopic or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBTopicListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBTopic] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBTopicListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + api_version=api_version, + template_url=self.list_by_namespace.metadata["url"], headers=_headers, params=_params, ) @@ -567,18 +701,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -594,10 +721,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -608,49 +733,115 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 + @overload async def create_or_update( self, resource_group_name: str, namespace_name: str, topic_name: str, parameters: _models.SBTopic, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBTopic: """Creates a topic in the specified namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param parameters: Parameters supplied to create a topic resource. + :param parameters: Parameters supplied to create a topic resource. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBTopic + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBTopic, or the result of cls(response) + :return: SBTopic or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBTopic - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBTopic: + """Creates a topic in the specified namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param parameters: Parameters supplied to create a topic resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2018_01_01_preview.models.SBTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + parameters: Union[_models.SBTopic, IO], + **kwargs: Any + ) -> _models.SBTopic: + """Creates a topic in the specified namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param parameters: Parameters supplied to create a topic resource. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBTopic or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2018_01_01_preview.models.SBTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBTopic] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBTopic] - _json = self._serialize.body(parameters, 'SBTopic') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBTopic") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -660,7 +851,8 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -668,10 +860,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -679,56 +870,48 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBTopic', pipeline_response) + 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 - + 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, - topic_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -736,10 +919,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -750,49 +932,41 @@ async def delete( # pylint: disable=inconsistent-return-statements 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, - namespace_name: str, - topic_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :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) + :return: SBTopic or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBTopic - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBTopic] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBTopic] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -800,10 +974,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -811,12 +984,11 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBTopic', pipeline_response) + 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 - + 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 4f7e18adf2a1..e2740374a7df 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 @@ -70,110 +70,108 @@ from ._models_py3 import VirtualNetworkRule from ._models_py3 import VirtualNetworkRuleListResult - -from ._service_bus_management_client_enums import ( - AccessRights, - DefaultAction, - EncodingCaptureDescription, - EndPointProvisioningState, - EntityStatus, - FilterType, - IPAction, - KeyType, - MigrationConfigurationName, - NameSpaceType, - NetworkRuleIPAction, - PrivateLinkConnectionStatus, - ProvisioningStateDR, - RoleDisasterRecovery, - SkuName, - SkuTier, - UnavailableReason, -) +from ._service_bus_management_client_enums import AccessRights +from ._service_bus_management_client_enums import DefaultAction +from ._service_bus_management_client_enums import EncodingCaptureDescription +from ._service_bus_management_client_enums import EndPointProvisioningState +from ._service_bus_management_client_enums import EntityStatus +from ._service_bus_management_client_enums import FilterType +from ._service_bus_management_client_enums import IPAction +from ._service_bus_management_client_enums import KeyType +from ._service_bus_management_client_enums import MigrationConfigurationName +from ._service_bus_management_client_enums import NameSpaceType +from ._service_bus_management_client_enums import NetworkRuleIPAction +from ._service_bus_management_client_enums import PrivateLinkConnectionStatus +from ._service_bus_management_client_enums import ProvisioningStateDR +from ._service_bus_management_client_enums import RoleDisasterRecovery +from ._service_bus_management_client_enums import SkuName +from ._service_bus_management_client_enums import SkuTier +from ._service_bus_management_client_enums import UnavailableReason from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'AccessKeys', - 'Action', - 'ArmDisasterRecovery', - 'ArmDisasterRecoveryListResult', - 'CaptureDescription', - 'CheckNameAvailability', - 'CheckNameAvailabilityResult', - 'ConnectionState', - 'CorrelationFilter', - 'Destination', - 'Encryption', - 'ErrorAdditionalInfo', - 'ErrorResponse', - 'ErrorResponseError', - 'EventHubListResult', - 'Eventhub', - 'FailoverProperties', - 'Identity', - 'IpFilterRule', - 'IpFilterRuleListResult', - 'KeyVaultProperties', - 'MessageCountDetails', - 'MigrationConfigListResult', - 'MigrationConfigProperties', - 'NWRuleSetIpRules', - 'NWRuleSetVirtualNetworkRules', - 'NetworkRuleSet', - 'NetworkRuleSetListResult', - 'Operation', - 'OperationDisplay', - 'OperationListResult', - 'PremiumMessagingRegions', - 'PremiumMessagingRegionsListResult', - 'PremiumMessagingRegionsProperties', - 'PrivateEndpoint', - 'PrivateEndpointConnection', - 'PrivateEndpointConnectionListResult', - 'PrivateLinkResource', - 'PrivateLinkResourcesListResult', - 'RegenerateAccessKeyParameters', - 'Resource', - 'ResourceNamespacePatch', - 'Rule', - 'RuleListResult', - 'SBAuthorizationRule', - 'SBAuthorizationRuleListResult', - 'SBNamespace', - 'SBNamespaceListResult', - 'SBNamespaceMigrate', - 'SBNamespaceUpdateParameters', - 'SBQueue', - 'SBQueueListResult', - 'SBSku', - 'SBSubscription', - 'SBSubscriptionListResult', - 'SBTopic', - 'SBTopicListResult', - 'SqlFilter', - 'SqlRuleAction', - 'Subnet', - 'TrackedResource', - 'VirtualNetworkRule', - 'VirtualNetworkRuleListResult', - 'AccessRights', - 'DefaultAction', - 'EncodingCaptureDescription', - 'EndPointProvisioningState', - 'EntityStatus', - 'FilterType', - 'IPAction', - 'KeyType', - 'MigrationConfigurationName', - 'NameSpaceType', - 'NetworkRuleIPAction', - 'PrivateLinkConnectionStatus', - 'ProvisioningStateDR', - 'RoleDisasterRecovery', - 'SkuName', - 'SkuTier', - 'UnavailableReason', + "AccessKeys", + "Action", + "ArmDisasterRecovery", + "ArmDisasterRecoveryListResult", + "CaptureDescription", + "CheckNameAvailability", + "CheckNameAvailabilityResult", + "ConnectionState", + "CorrelationFilter", + "Destination", + "Encryption", + "ErrorAdditionalInfo", + "ErrorResponse", + "ErrorResponseError", + "EventHubListResult", + "Eventhub", + "FailoverProperties", + "Identity", + "IpFilterRule", + "IpFilterRuleListResult", + "KeyVaultProperties", + "MessageCountDetails", + "MigrationConfigListResult", + "MigrationConfigProperties", + "NWRuleSetIpRules", + "NWRuleSetVirtualNetworkRules", + "NetworkRuleSet", + "NetworkRuleSetListResult", + "Operation", + "OperationDisplay", + "OperationListResult", + "PremiumMessagingRegions", + "PremiumMessagingRegionsListResult", + "PremiumMessagingRegionsProperties", + "PrivateEndpoint", + "PrivateEndpointConnection", + "PrivateEndpointConnectionListResult", + "PrivateLinkResource", + "PrivateLinkResourcesListResult", + "RegenerateAccessKeyParameters", + "Resource", + "ResourceNamespacePatch", + "Rule", + "RuleListResult", + "SBAuthorizationRule", + "SBAuthorizationRuleListResult", + "SBNamespace", + "SBNamespaceListResult", + "SBNamespaceMigrate", + "SBNamespaceUpdateParameters", + "SBQueue", + "SBQueueListResult", + "SBSku", + "SBSubscription", + "SBSubscriptionListResult", + "SBTopic", + "SBTopicListResult", + "SqlFilter", + "SqlRuleAction", + "Subnet", + "TrackedResource", + "VirtualNetworkRule", + "VirtualNetworkRuleListResult", + "AccessRights", + "DefaultAction", + "EncodingCaptureDescription", + "EndPointProvisioningState", + "EntityStatus", + "FilterType", + "IPAction", + "KeyType", + "MigrationConfigurationName", + "NameSpaceType", + "NetworkRuleIPAction", + "PrivateLinkConnectionStatus", + "ProvisioningStateDR", + "RoleDisasterRecovery", + "SkuName", + "SkuTier", + "UnavailableReason", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() 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 13873fc55731..da1966259c83 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 @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -9,15 +10,14 @@ import datetime from typing import Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - import __init__ as _models + from .. import models as _models -class AccessKeys(msrest.serialization.Model): +class AccessKeys(_serialization.Model): """Namespace/ServiceBus Connection String. Variables are only populated by the server, and will be ignored when sending a request. @@ -45,32 +45,28 @@ class AccessKeys(msrest.serialization.Model): """ _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}, + "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) + "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().__init__(**kwargs) self.primary_connection_string = None self.secondary_connection_string = None self.alias_primary_connection_string = None @@ -80,7 +76,7 @@ def __init__( self.key_name = None -class Action(msrest.serialization.Model): +class Action(_serialization.Model): """Represents the filter actions which are allowed for the transformation of a message that have been matched by a filter expression. :ivar sql_expression: SQL expression. e.g. MyProperty='ABC'. @@ -94,9 +90,9 @@ class Action(msrest.serialization.Model): """ _attribute_map = { - 'sql_expression': {'key': 'sqlExpression', 'type': 'str'}, - 'compatibility_level': {'key': 'compatibilityLevel', 'type': 'int'}, - 'requires_preprocessing': {'key': 'requiresPreprocessing', 'type': 'bool'}, + "sql_expression": {"key": "sqlExpression", "type": "str"}, + "compatibility_level": {"key": "compatibilityLevel", "type": "int"}, + "requires_preprocessing": {"key": "requiresPreprocessing", "type": "bool"}, } def __init__( @@ -104,7 +100,7 @@ def __init__( *, sql_expression: Optional[str] = None, compatibility_level: Optional[int] = None, - requires_preprocessing: Optional[bool] = True, + requires_preprocessing: bool = True, **kwargs ): """ @@ -117,13 +113,13 @@ def __init__( preprocessing. :paramtype requires_preprocessing: bool """ - super(Action, self).__init__(**kwargs) + super().__init__(**kwargs) self.sql_expression = sql_expression self.compatibility_level = compatibility_level self.requires_preprocessing = requires_preprocessing -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """The Resource definition for other than namespace. Variables are only populated by the server, and will be ignored when sending a request. @@ -137,24 +133,20 @@ class Resource(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "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'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Resource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -173,11 +165,11 @@ class ArmDisasterRecovery(Resource): :vartype type: str :ivar provisioning_state: Provisioning state of the Alias(Disaster Recovery configuration) - possible values 'Accepted' or 'Succeeded' or 'Failed'. Known values are: "Accepted", - "Succeeded", "Failed". + "Succeeded", and "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 + :vartype pending_replication_operations_count: int :ivar partner_namespace: ARM Id of the Primary/Secondary eventhub namespace name, which is part of GEO DR pairing. :vartype partner_namespace: str @@ -185,37 +177,31 @@ class ArmDisasterRecovery(Resource): pairing. :vartype alternate_name: str :ivar role: role of namespace in GEO DR - possible values 'Primary' or 'PrimaryNotReplicating' - or 'Secondary'. Known values are: "Primary", "PrimaryNotReplicating", "Secondary". + or 'Secondary'. Known values are: "Primary", "PrimaryNotReplicating", and "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}, + "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'}, + "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": "int"}, + "partner_namespace": {"key": "properties.partnerNamespace", "type": "str"}, + "alternate_name": {"key": "properties.alternateName", "type": "str"}, + "role": {"key": "properties.role", "type": "str"}, } - def __init__( - self, - *, - partner_namespace: Optional[str] = None, - alternate_name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, partner_namespace: Optional[str] = None, 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. @@ -224,7 +210,7 @@ def __init__( pairing. :paramtype alternate_name: str """ - super(ArmDisasterRecovery, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.pending_replication_operations_count = None self.partner_namespace = partner_namespace @@ -232,7 +218,7 @@ def __init__( self.role = None -class ArmDisasterRecoveryListResult(msrest.serialization.Model): +class ArmDisasterRecoveryListResult(_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. @@ -245,36 +231,31 @@ class ArmDisasterRecoveryListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ArmDisasterRecovery]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ArmDisasterRecovery]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.ArmDisasterRecovery"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.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) + super().__init__(**kwargs) self.value = value self.next_link = None -class CaptureDescription(msrest.serialization.Model): +class CaptureDescription(_serialization.Model): """Properties to configure capture description for eventhub. :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. - Known values are: "Avro", "AvroDeflate". + Known values are: "Avro" and "AvroDeflate". :vartype encoding: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.EncodingCaptureDescription :ivar interval_in_seconds: The time window allows you to set the frequency with which the @@ -289,16 +270,16 @@ class CaptureDescription(msrest.serialization.Model): """ _validation = { - 'interval_in_seconds': {'maximum': 900, 'minimum': 60}, - 'size_limit_in_bytes': {'maximum': 524288000, 'minimum': 10485760}, + "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'}, + "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__( @@ -315,7 +296,7 @@ def __init__( :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. Known values are: "Avro", "AvroDeflate". + description. Known values are: "Avro" and "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 @@ -328,7 +309,7 @@ def __init__( Blob Names). :paramtype destination: ~azure.mgmt.servicebus.v2018_01_01_preview.models.Destination """ - super(CaptureDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.encoding = encoding self.interval_in_seconds = interval_in_seconds @@ -336,42 +317,37 @@ def __init__( self.destination = destination -class CheckNameAvailability(msrest.serialization.Model): +class CheckNameAvailability(_serialization.Model): """Description of a Check Name availability request properties. All required parameters must be populated in order to send to Azure. - :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. + :ivar name: 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. Required. :vartype name: str """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - name: str, - **kwargs - ): + def __init__(self, *, 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. + :keyword name: 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. Required. :paramtype name: str """ - super(CheckNameAvailability, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class CheckNameAvailabilityResult(msrest.serialization.Model): +class CheckNameAvailabilityResult(_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. @@ -382,19 +358,19 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): available; otherwise, false. :vartype name_available: bool :ivar reason: The reason for unavailability of a namespace. Known values are: "None", - "InvalidName", "SubscriptionIsDisabled", "NameInUse", "NameInLockdown", + "InvalidName", "SubscriptionIsDisabled", "NameInUse", "NameInLockdown", and "TooManyNamespaceInCurrentSubscription". :vartype reason: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.UnavailableReason """ _validation = { - 'message': {'readonly': True}, + "message": {"readonly": True}, } _attribute_map = { - 'message': {'key': 'message', 'type': 'str'}, - 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, - 'reason': {'key': 'reason', 'type': 'str'}, + "message": {"key": "message", "type": "str"}, + "name_available": {"key": "nameAvailable", "type": "bool"}, + "reason": {"key": "reason", "type": "str"}, } def __init__( @@ -409,21 +385,21 @@ def __init__( available; otherwise, false. :paramtype name_available: bool :keyword reason: The reason for unavailability of a namespace. Known values are: "None", - "InvalidName", "SubscriptionIsDisabled", "NameInUse", "NameInLockdown", + "InvalidName", "SubscriptionIsDisabled", "NameInUse", "NameInLockdown", and "TooManyNamespaceInCurrentSubscription". :paramtype reason: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.UnavailableReason """ - super(CheckNameAvailabilityResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.message = None self.name_available = name_available self.reason = reason -class ConnectionState(msrest.serialization.Model): +class ConnectionState(_serialization.Model): """ConnectionState information. :ivar status: Status of the connection. Known values are: "Pending", "Approved", "Rejected", - "Disconnected". + and "Disconnected". :vartype status: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.PrivateLinkConnectionStatus :ivar description: Description of the connection state. @@ -431,8 +407,8 @@ class ConnectionState(msrest.serialization.Model): """ _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "status": {"key": "status", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -444,18 +420,18 @@ def __init__( ): """ :keyword status: Status of the connection. Known values are: "Pending", "Approved", "Rejected", - "Disconnected". + and "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) + super().__init__(**kwargs) self.status = status self.description = description -class CorrelationFilter(msrest.serialization.Model): +class CorrelationFilter(_serialization.Model): """Represents the correlation filter expression. :ivar properties: dictionary object for custom filters. @@ -482,16 +458,16 @@ class CorrelationFilter(msrest.serialization.Model): """ _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'}, + "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__( @@ -506,7 +482,7 @@ def __init__( session_id: Optional[str] = None, reply_to_session_id: Optional[str] = None, content_type: Optional[str] = None, - requires_preprocessing: Optional[bool] = True, + requires_preprocessing: bool = True, **kwargs ): """ @@ -532,7 +508,7 @@ def __init__( preprocessing. :paramtype requires_preprocessing: bool """ - super(CorrelationFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.correlation_id = correlation_id self.message_id = message_id @@ -545,7 +521,7 @@ def __init__( self.requires_preprocessing = requires_preprocessing -class Destination(msrest.serialization.Model): +class Destination(_serialization.Model): """Capture storage details for capture description. :ivar name: Name for capture destination. @@ -562,10 +538,10 @@ class Destination(msrest.serialization.Model): """ _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'}, + "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__( @@ -590,52 +566,50 @@ def __init__( the parameters (Namespace,EventHub .. etc) are mandatory irrespective of order. :paramtype archive_name_format: str """ - super(Destination, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.storage_account_resource_id = storage_account_resource_id self.blob_container = blob_container self.archive_name_format = archive_name_format -class Encryption(msrest.serialization.Model): +class Encryption(_serialization.Model): """Properties to configure Encryption. :ivar key_vault_properties: Properties of KeyVault. :vartype key_vault_properties: ~azure.mgmt.servicebus.v2018_01_01_preview.models.KeyVaultProperties - :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 + :ivar key_source: Enumerates the possible value of keySource for Encryption. Default value is "Microsoft.KeyVault". :vartype key_source: str """ _attribute_map = { - 'key_vault_properties': {'key': 'keyVaultProperties', 'type': 'KeyVaultProperties'}, - 'key_source': {'key': 'keySource', 'type': 'str'}, + "key_vault_properties": {"key": "keyVaultProperties", "type": "KeyVaultProperties"}, + "key_source": {"key": "keySource", "type": "str"}, } def __init__( self, *, key_vault_properties: Optional["_models.KeyVaultProperties"] = None, - key_source: Optional[str] = "Microsoft.KeyVault", + key_source: 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". + :keyword key_source: Enumerates the possible value of keySource for Encryption. Default value + is "Microsoft.KeyVault". :paramtype key_source: str """ - super(Encryption, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_vault_properties = key_vault_properties self.key_source = key_source -class ErrorAdditionalInfo(msrest.serialization.Model): +class ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. Variables are only populated by the server, and will be ignored when sending a request. @@ -643,31 +617,27 @@ class ErrorAdditionalInfo(msrest.serialization.Model): :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. - :vartype info: any + :vartype info: JSON """ _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, + "type": {"readonly": True}, + "info": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorAdditionalInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.info = None -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """The resource management error response. :ivar error: The error object. @@ -675,24 +645,19 @@ class ErrorResponse(msrest.serialization.Model): """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponseError'}, + "error": {"key": "error", "type": "ErrorResponseError"}, } - def __init__( - self, - *, - error: Optional["_models.ErrorResponseError"] = None, - **kwargs - ): + def __init__(self, *, error: Optional["_models.ErrorResponseError"] = None, **kwargs): """ :keyword error: The error object. :paramtype error: ~azure.mgmt.servicebus.v2018_01_01_preview.models.ErrorResponseError """ - super(ErrorResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error -class ErrorResponseError(msrest.serialization.Model): +class ErrorResponseError(_serialization.Model): """The error object. Variables are only populated by the server, and will be ignored when sending a request. @@ -711,28 +676,24 @@ class ErrorResponseError(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, + "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]'}, + "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) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.message = None self.target = None @@ -759,13 +720,13 @@ class Eventhub(Resource): :vartype updated_at: ~datetime.datetime :ivar message_retention_in_days: Number of days to retain the events for this Event Hub, value should be 1 to 7 days. - :vartype message_retention_in_days: long + :vartype message_retention_in_days: int :ivar partition_count: Number of partitions created for the Event Hub, allowed values are from 1 to 32 partitions. - :vartype partition_count: long + :vartype partition_count: int :ivar status: Enumerates the possible values for the status of a Event Hub. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", "Deleting", - "Renaming", "Unknown". + "Renaming", and "Unknown". :vartype status: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.EntityStatus :ivar capture_description: Properties of capture description. :vartype capture_description: @@ -773,27 +734,27 @@ class Eventhub(Resource): """ _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}, + "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'}, + "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": "int"}, + "partition_count": {"key": "properties.partitionCount", "type": "int"}, + "status": {"key": "properties.status", "type": "str"}, + "capture_description": {"key": "properties.captureDescription", "type": "CaptureDescription"}, } def __init__( @@ -808,19 +769,19 @@ def __init__( """ :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 + :paramtype message_retention_in_days: int :keyword partition_count: Number of partitions created for the Event Hub, allowed values are from 1 to 32 partitions. - :paramtype partition_count: long + :paramtype partition_count: int :keyword status: Enumerates the possible values for the status of a Event Hub. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". + "Deleting", "Renaming", and "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) + super().__init__(**kwargs) self.partition_ids = None self.created_at = None self.updated_at = None @@ -830,7 +791,7 @@ def __init__( self.capture_description = capture_description -class EventHubListResult(msrest.serialization.Model): +class EventHubListResult(_serialization.Model): """The result of the List EventHubs operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -843,30 +804,25 @@ class EventHubListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Eventhub]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Eventhub]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.Eventhub"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.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) + super().__init__(**kwargs) self.value = value self.next_link = None -class FailoverProperties(msrest.serialization.Model): +class FailoverProperties(_serialization.Model): """Safe failover is to indicate the service should wait for pending replication to finish before switching to the secondary. :ivar is_safe_failover: Safe failover is to indicate the service should wait for pending @@ -875,25 +831,20 @@ class FailoverProperties(msrest.serialization.Model): """ _attribute_map = { - 'is_safe_failover': {'key': 'properties.IsSafeFailover', 'type': 'bool'}, + "is_safe_failover": {"key": "properties.IsSafeFailover", "type": "bool"}, } - def __init__( - self, - *, - is_safe_failover: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, 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) + super().__init__(**kwargs) self.is_safe_failover = is_safe_failover -class Identity(msrest.serialization.Model): +class Identity(_serialization.Model): """Properties to configure Identity for Bring your Own Keys. :ivar principal_id: ObjectId from the KeyVault. @@ -901,15 +852,14 @@ class Identity(msrest.serialization.Model): :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". + 'SystemAssigned'. Default value is "SystemAssigned". :vartype type: str """ _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, } def __init__( @@ -917,7 +867,7 @@ def __init__( *, principal_id: Optional[str] = None, tenant_id: Optional[str] = None, - type: Optional[str] = "SystemAssigned", + type: str = "SystemAssigned", **kwargs ): """ @@ -926,11 +876,10 @@ def __init__( :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". + 'SystemAssigned'. Default value is "SystemAssigned". :paramtype type: str """ - super(Identity, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = principal_id self.tenant_id = tenant_id self.type = type @@ -949,25 +898,25 @@ class IpFilterRule(Resource): :vartype type: str :ivar ip_mask: IP Mask. :vartype ip_mask: str - :ivar action: The IP Filter Action. Known values are: "Accept", "Reject". + :ivar action: The IP Filter Action. Known values are: "Accept" and "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 = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "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'}, + "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__( @@ -981,18 +930,18 @@ def __init__( """ :keyword ip_mask: IP Mask. :paramtype ip_mask: str - :keyword action: The IP Filter Action. Known values are: "Accept", "Reject". + :keyword action: The IP Filter Action. Known values are: "Accept" and "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) + super().__init__(**kwargs) self.ip_mask = ip_mask self.action = action self.filter_name = filter_name -class IpFilterRuleListResult(msrest.serialization.Model): +class IpFilterRuleListResult(_serialization.Model): """The response from the List namespace operation. :ivar value: Result of the List IpFilter Rules operation. @@ -1003,16 +952,12 @@ class IpFilterRuleListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[IpFilterRule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[IpFilterRule]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.IpFilterRule"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.IpFilterRule"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Result of the List IpFilter Rules operation. @@ -1021,12 +966,12 @@ def __init__( list of IpFilter Rules. :paramtype next_link: str """ - super(IpFilterRuleListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class KeyVaultProperties(msrest.serialization.Model): +class KeyVaultProperties(_serialization.Model): """Properties to configure keyVault Properties. :ivar key_name: Name of the Key from KeyVault. @@ -1036,69 +981,59 @@ class KeyVaultProperties(msrest.serialization.Model): """ _attribute_map = { - 'key_name': {'key': 'keyName', 'type': 'str'}, - 'key_vault_uri': {'key': 'keyVaultUri', 'type': 'str'}, + "key_name": {"key": "keyName", "type": "str"}, + "key_vault_uri": {"key": "keyVaultUri", "type": "str"}, } - def __init__( - self, - *, - key_name: Optional[str] = None, - key_vault_uri: Optional[str] = None, - **kwargs - ): + def __init__(self, *, key_name: Optional[str] = None, 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) + super().__init__(**kwargs) self.key_name = key_name self.key_vault_uri = key_vault_uri -class MessageCountDetails(msrest.serialization.Model): +class MessageCountDetails(_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 + :vartype active_message_count: int :ivar dead_letter_message_count: Number of messages that are dead lettered. - :vartype dead_letter_message_count: long + :vartype dead_letter_message_count: int :ivar scheduled_message_count: Number of scheduled messages. - :vartype scheduled_message_count: long + :vartype scheduled_message_count: int :ivar transfer_message_count: Number of messages transferred to another queue, topic, or subscription. - :vartype transfer_message_count: long + :vartype transfer_message_count: int :ivar transfer_dead_letter_message_count: Number of messages transferred into dead letters. - :vartype transfer_dead_letter_message_count: long + :vartype transfer_dead_letter_message_count: int """ _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}, + "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'}, + "active_message_count": {"key": "activeMessageCount", "type": "int"}, + "dead_letter_message_count": {"key": "deadLetterMessageCount", "type": "int"}, + "scheduled_message_count": {"key": "scheduledMessageCount", "type": "int"}, + "transfer_message_count": {"key": "transferMessageCount", "type": "int"}, + "transfer_dead_letter_message_count": {"key": "transferDeadLetterMessageCount", "type": "int"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(MessageCountDetails, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.active_message_count = None self.dead_letter_message_count = None self.scheduled_message_count = None @@ -1106,7 +1041,7 @@ def __init__( self.transfer_dead_letter_message_count = None -class MigrationConfigListResult(msrest.serialization.Model): +class MigrationConfigListResult(_serialization.Model): """The result of the List migrationConfigurations operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -1120,26 +1055,21 @@ class MigrationConfigListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[MigrationConfigProperties]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[MigrationConfigProperties]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.MigrationConfigProperties"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.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) + super().__init__(**kwargs) self.value = value self.next_link = None @@ -1158,7 +1088,7 @@ class MigrationConfigProperties(Resource): :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 + :vartype pending_replication_operations_count: int :ivar target_namespace: Existing premium Namespace ARM Id name which has no entities, will be used for migration. :vartype target_namespace: str @@ -1170,32 +1100,26 @@ class MigrationConfigProperties(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'pending_replication_operations_count': {'readonly': True}, - 'migration_state': {'readonly': True}, + "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'}, + "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": "int"}, + "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, - *, - target_namespace: Optional[str] = None, - post_migration_name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, target_namespace: Optional[str] = None, 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. @@ -1203,7 +1127,7 @@ def __init__( :keyword post_migration_name: Name to access Standard Namespace after migration. :paramtype post_migration_name: str """ - super(MigrationConfigProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.pending_replication_operations_count = None self.target_namespace = target_namespace @@ -1222,7 +1146,8 @@ class NetworkRuleSet(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :ivar default_action: Default Action for Network Rule Set. Known values are: "Allow", "Deny". + :ivar default_action: Default Action for Network Rule Set. Known values are: "Allow" and + "Deny". :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: @@ -1232,18 +1157,18 @@ class NetworkRuleSet(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "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]'}, + "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__( @@ -1255,7 +1180,7 @@ def __init__( **kwargs ): """ - :keyword default_action: Default Action for Network Rule Set. Known values are: "Allow", + :keyword default_action: Default Action for Network Rule Set. Known values are: "Allow" and "Deny". :paramtype default_action: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.DefaultAction @@ -1265,13 +1190,13 @@ def __init__( :keyword ip_rules: List of IpRules. :paramtype ip_rules: list[~azure.mgmt.servicebus.v2018_01_01_preview.models.NWRuleSetIpRules] """ - super(NetworkRuleSet, self).__init__(**kwargs) + super().__init__(**kwargs) self.default_action = default_action self.virtual_network_rules = virtual_network_rules self.ip_rules = ip_rules -class NetworkRuleSetListResult(msrest.serialization.Model): +class NetworkRuleSetListResult(_serialization.Model): """The response of the List NetworkRuleSet operation. :ivar value: Result of the List NetworkRuleSet operation. @@ -1282,16 +1207,12 @@ class NetworkRuleSetListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[NetworkRuleSet]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[NetworkRuleSet]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.NetworkRuleSet"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.NetworkRuleSet"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Result of the List NetworkRuleSet operation. @@ -1300,44 +1221,40 @@ def __init__( list of NetworkRuleSet. :paramtype next_link: str """ - super(NetworkRuleSetListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class NWRuleSetIpRules(msrest.serialization.Model): +class NWRuleSetIpRules(_serialization.Model): """Description of NetWorkRuleSet - IpRules resource. :ivar ip_mask: IP Mask. :vartype ip_mask: str - :ivar action: The IP Filter Action. Known values are: "Allow". Default value: "Allow". + :ivar action: The IP Filter Action. "Allow" :vartype 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'}, + "ip_mask": {"key": "ipMask", "type": "str"}, + "action": {"key": "action", "type": "str"}, } def __init__( - self, - *, - ip_mask: Optional[str] = None, - action: Optional[Union[str, "_models.NetworkRuleIPAction"]] = "Allow", - **kwargs + self, *, ip_mask: Optional[str] = None, action: Union[str, "_models.NetworkRuleIPAction"] = "Allow", **kwargs ): """ :keyword ip_mask: IP Mask. :paramtype ip_mask: str - :keyword action: The IP Filter Action. Known values are: "Allow". Default value: "Allow". + :keyword action: The IP Filter Action. "Allow" :paramtype action: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.NetworkRuleIPAction """ - super(NWRuleSetIpRules, self).__init__(**kwargs) + super().__init__(**kwargs) self.ip_mask = ip_mask self.action = action -class NWRuleSetVirtualNetworkRules(msrest.serialization.Model): +class NWRuleSetVirtualNetworkRules(_serialization.Model): """Description of VirtualNetworkRules - NetworkRules resource. :ivar subnet: Subnet properties. @@ -1348,8 +1265,8 @@ class NWRuleSetVirtualNetworkRules(msrest.serialization.Model): """ _attribute_map = { - 'subnet': {'key': 'subnet', 'type': 'Subnet'}, - 'ignore_missing_vnet_service_endpoint': {'key': 'ignoreMissingVnetServiceEndpoint', 'type': 'bool'}, + "subnet": {"key": "subnet", "type": "Subnet"}, + "ignore_missing_vnet_service_endpoint": {"key": "ignoreMissingVnetServiceEndpoint", "type": "bool"}, } def __init__( @@ -1366,12 +1283,12 @@ def __init__( VNet Service Endpoint. :paramtype ignore_missing_vnet_service_endpoint: bool """ - super(NWRuleSetVirtualNetworkRules, self).__init__(**kwargs) + super().__init__(**kwargs) self.subnet = subnet self.ignore_missing_vnet_service_endpoint = ignore_missing_vnet_service_endpoint -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """A ServiceBus REST API operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -1383,30 +1300,25 @@ class Operation(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, + "name": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, } - def __init__( - self, - *, - display: Optional["_models.OperationDisplay"] = None, - **kwargs - ): + def __init__(self, *, display: Optional["_models.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) + super().__init__(**kwargs) self.name = None self.display = display -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """The object that represents the operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -1420,30 +1332,26 @@ class OperationDisplay(msrest.serialization.Model): """ _validation = { - 'provider': {'readonly': True}, - 'resource': {'readonly': True}, - 'operation': {'readonly': True}, + "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'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(OperationDisplay, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.provider = None self.resource = None self.operation = None -class OperationListResult(msrest.serialization.Model): +class OperationListResult(_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. @@ -1456,22 +1364,18 @@ class OperationListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(OperationListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None @@ -1489,38 +1393,32 @@ class ResourceNamespacePatch(Resource): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "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}'}, + "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, - *, - location: Optional[str] = None, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs): """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(ResourceNamespacePatch, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.tags = tags @@ -1538,7 +1436,7 @@ class PremiumMessagingRegions(ResourceNamespacePatch): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar properties: :vartype properties: @@ -1546,18 +1444,18 @@ class PremiumMessagingRegions(ResourceNamespacePatch): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "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'}, + "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__( @@ -1571,17 +1469,17 @@ def __init__( """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword 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) + super().__init__(location=location, tags=tags, **kwargs) self.properties = properties -class PremiumMessagingRegionsListResult(msrest.serialization.Model): +class PremiumMessagingRegionsListResult(_serialization.Model): """The response of the List PremiumMessagingRegions operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -1594,31 +1492,26 @@ class PremiumMessagingRegionsListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[PremiumMessagingRegions]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PremiumMessagingRegions]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.PremiumMessagingRegions"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.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) + super().__init__(**kwargs) self.value = value self.next_link = None -class PremiumMessagingRegionsProperties(msrest.serialization.Model): +class PremiumMessagingRegionsProperties(_serialization.Model): """PremiumMessagingRegionsProperties. Variables are only populated by the server, and will be ignored when sending a request. @@ -1630,27 +1523,23 @@ class PremiumMessagingRegionsProperties(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'full_name': {'readonly': True}, + "code": {"readonly": True}, + "full_name": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'full_name': {'key': 'fullName', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "full_name": {"key": "fullName", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(PremiumMessagingRegionsProperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.full_name = None -class PrivateEndpoint(msrest.serialization.Model): +class PrivateEndpoint(_serialization.Model): """PrivateEndpoint information. :ivar id: The ARM identifier for Private Endpoint. @@ -1658,20 +1547,15 @@ class PrivateEndpoint(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, id: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin """ :keyword id: The ARM identifier for Private Endpoint. :paramtype id: str """ - super(PrivateEndpoint, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id @@ -1692,24 +1576,27 @@ class PrivateEndpointConnection(Resource): :vartype private_link_service_connection_state: ~azure.mgmt.servicebus.v2018_01_01_preview.models.ConnectionState :ivar provisioning_state: Provisioning state of the Private Endpoint Connection. Known values - are: "Creating", "Updating", "Deleting", "Succeeded", "Canceled", "Failed". + are: "Creating", "Updating", "Deleting", "Succeeded", "Canceled", and "Failed". :vartype provisioning_state: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.EndPointProvisioningState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "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'}, + "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__( @@ -1727,17 +1614,17 @@ def __init__( :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. Known - values are: "Creating", "Updating", "Deleting", "Succeeded", "Canceled", "Failed". + values are: "Creating", "Updating", "Deleting", "Succeeded", "Canceled", and "Failed". :paramtype provisioning_state: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.EndPointProvisioningState """ - super(PrivateEndpointConnection, self).__init__(**kwargs) + super().__init__(**kwargs) self.private_endpoint = private_endpoint self.private_link_service_connection_state = private_link_service_connection_state self.provisioning_state = provisioning_state -class PrivateEndpointConnectionListResult(msrest.serialization.Model): +class PrivateEndpointConnectionListResult(_serialization.Model): """Result of the list of all private endpoint connections operation. :ivar value: A collection of private endpoint connection resources. @@ -1748,8 +1635,8 @@ class PrivateEndpointConnectionListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateEndpointConnection]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PrivateEndpointConnection]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( @@ -1766,12 +1653,12 @@ def __init__( :keyword next_link: A link for the next page of private endpoint connection resources. :paramtype next_link: str """ - super(PrivateEndpointConnectionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class PrivateLinkResource(msrest.serialization.Model): +class PrivateLinkResource(_serialization.Model): """Information of the private link resource. :ivar id: Fully qualified identifier of the resource. @@ -1789,18 +1676,18 @@ class PrivateLinkResource(msrest.serialization.Model): """ _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]'}, + "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, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin name: Optional[str] = None, type: Optional[str] = None, group_id: Optional[str] = None, @@ -1822,7 +1709,7 @@ def __init__( :keyword required_zone_names: Required Zone Names. :paramtype required_zone_names: list[str] """ - super(PrivateLinkResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.name = name self.type = type @@ -1831,7 +1718,7 @@ def __init__( self.required_zone_names = required_zone_names -class PrivateLinkResourcesListResult(msrest.serialization.Model): +class PrivateLinkResourcesListResult(_serialization.Model): """Result of the List private link resources operation. :ivar value: A collection of private link resources. @@ -1841,16 +1728,12 @@ class PrivateLinkResourcesListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateLinkResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PrivateLinkResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.PrivateLinkResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.PrivateLinkResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: A collection of private link resources. @@ -1858,17 +1741,17 @@ def __init__( :keyword next_link: A link for the next page of private link resources. :paramtype next_link: str """ - super(PrivateLinkResourcesListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class RegenerateAccessKeyParameters(msrest.serialization.Model): +class RegenerateAccessKeyParameters(_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. - :ivar key_type: Required. The access key to regenerate. Known values are: "PrimaryKey", + :ivar key_type: The access key to regenerate. Required. Known values are: "PrimaryKey" and "SecondaryKey". :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 @@ -1877,30 +1760,24 @@ class RegenerateAccessKeyParameters(msrest.serialization.Model): """ _validation = { - 'key_type': {'required': True}, + "key_type": {"required": True}, } _attribute_map = { - 'key_type': {'key': 'keyType', 'type': 'str'}, - 'key': {'key': 'key', 'type': 'str'}, + "key_type": {"key": "keyType", "type": "str"}, + "key": {"key": "key", "type": "str"}, } - def __init__( - self, - *, - key_type: Union[str, "_models.KeyType"], - key: Optional[str] = None, - **kwargs - ): + def __init__(self, *, key_type: Union[str, "_models.KeyType"], key: Optional[str] = None, **kwargs): """ - :keyword key_type: Required. The access key to regenerate. Known values are: "PrimaryKey", + :keyword key_type: The access key to regenerate. Required. Known values are: "PrimaryKey" and "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) + super().__init__(**kwargs) self.key_type = key_type self.key = key @@ -1920,7 +1797,7 @@ class Rule(Resource): message that have been matched by a filter expression. :vartype action: ~azure.mgmt.servicebus.v2018_01_01_preview.models.Action :ivar filter_type: Filter type that is evaluated against a BrokeredMessage. Known values are: - "SqlFilter", "CorrelationFilter". + "SqlFilter" and "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 @@ -1930,19 +1807,19 @@ class Rule(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "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'}, + "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__( @@ -1959,7 +1836,7 @@ def __init__( 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. Known values - are: "SqlFilter", "CorrelationFilter". + are: "SqlFilter" and "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 @@ -1967,14 +1844,14 @@ def __init__( :paramtype correlation_filter: ~azure.mgmt.servicebus.v2018_01_01_preview.models.CorrelationFilter """ - super(Rule, self).__init__(**kwargs) + super().__init__(**kwargs) self.action = action self.filter_type = filter_type self.sql_filter = sql_filter self.correlation_filter = correlation_filter -class RuleListResult(msrest.serialization.Model): +class RuleListResult(_serialization.Model): """The response of the List rule operation. :ivar value: Result of the List Rules operation. @@ -1985,17 +1862,11 @@ class RuleListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Rule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Rule]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.Rule"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Rule"]] = None, 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] @@ -2003,7 +1874,7 @@ def __init__( list of rules. :paramtype next_link: str """ - super(RuleListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link @@ -2024,33 +1895,28 @@ class SBAuthorizationRule(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "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]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "rights": {"key": "properties.rights", "type": "[str]"}, } - def __init__( - self, - *, - rights: Optional[List[Union[str, "_models.AccessRights"]]] = None, - **kwargs - ): + def __init__(self, *, rights: Optional[List[Union[str, "_models.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) + super().__init__(**kwargs) self.rights = rights -class SBAuthorizationRuleListResult(msrest.serialization.Model): +class SBAuthorizationRuleListResult(_serialization.Model): """The response to the List Namespace operation. :ivar value: Result of the List Authorization Rules operation. @@ -2061,16 +1927,12 @@ class SBAuthorizationRuleListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SBAuthorizationRule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SBAuthorizationRule]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.SBAuthorizationRule"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.SBAuthorizationRule"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Result of the List Authorization Rules operation. @@ -2079,7 +1941,7 @@ def __init__( list of Authorization Rules. :paramtype next_link: str """ - super(SBAuthorizationRuleListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link @@ -2097,46 +1959,40 @@ class TrackedResource(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :ivar location: Required. The Geo-location where the resource lives. + :ivar location: The Geo-location where the resource lives. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "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}'}, + "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, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword location: Required. The Geo-location where the resource lives. + :keyword location: The Geo-location where the resource lives. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(TrackedResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.tags = tags -class SBNamespace(TrackedResource): +class SBNamespace(TrackedResource): # pylint: disable=too-many-instance-attributes """Description of a namespace resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2149,9 +2005,9 @@ class SBNamespace(TrackedResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :ivar location: Required. The Geo-location where the resource lives. + :ivar location: The Geo-location where the resource lives. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar sku: Properties of SKU. :vartype sku: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBSku @@ -2177,34 +2033,34 @@ class SBNamespace(TrackedResource): """ _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}, + "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'}, + "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__( @@ -2219,9 +2075,9 @@ def __init__( **kwargs ): """ - :keyword location: Required. The Geo-location where the resource lives. + :keyword location: The Geo-location where the resource lives. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword sku: Properties of SKU. :paramtype sku: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBSku @@ -2233,7 +2089,7 @@ def __init__( :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) + super().__init__(location=location, tags=tags, **kwargs) self.sku = sku self.identity = identity self.provisioning_state = None @@ -2246,7 +2102,7 @@ def __init__( self.encryption = encryption -class SBNamespaceListResult(msrest.serialization.Model): +class SBNamespaceListResult(_serialization.Model): """The response of the List Namespace operation. :ivar value: Result of the List Namespace operation. @@ -2257,16 +2113,12 @@ class SBNamespaceListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SBNamespace]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SBNamespace]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.SBNamespace"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.SBNamespace"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Result of the List Namespace operation. @@ -2275,47 +2127,42 @@ def __init__( list of Namespaces. :paramtype next_link: str """ - super(SBNamespaceListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SBNamespaceMigrate(msrest.serialization.Model): +class SBNamespaceMigrate(_serialization.Model): """Namespace Migrate Object. All required parameters must be populated in order to send to Azure. - :ivar target_namespace_type: Required. Type of namespaces. Known values are: "Messaging", - "NotificationHub", "Mixed", "EventHub", "Relay". + :ivar target_namespace_type: Type of namespaces. Required. Known values are: "Messaging", + "NotificationHub", "Mixed", "EventHub", and "Relay". :vartype target_namespace_type: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.NameSpaceType """ _validation = { - 'target_namespace_type': {'required': True}, + "target_namespace_type": {"required": True}, } _attribute_map = { - 'target_namespace_type': {'key': 'targetNamespaceType', 'type': 'str'}, + "target_namespace_type": {"key": "targetNamespaceType", "type": "str"}, } - def __init__( - self, - *, - target_namespace_type: Union[str, "_models.NameSpaceType"], - **kwargs - ): + def __init__(self, *, target_namespace_type: Union[str, "_models.NameSpaceType"], **kwargs): """ - :keyword target_namespace_type: Required. Type of namespaces. Known values are: "Messaging", - "NotificationHub", "Mixed", "EventHub", "Relay". + :keyword target_namespace_type: Type of namespaces. Required. Known values are: "Messaging", + "NotificationHub", "Mixed", "EventHub", and "Relay". :paramtype target_namespace_type: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.NameSpaceType """ - super(SBNamespaceMigrate, self).__init__(**kwargs) + super().__init__(**kwargs) self.target_namespace_type = target_namespace_type -class SBNamespaceUpdateParameters(ResourceNamespacePatch): +class SBNamespaceUpdateParameters(ResourceNamespacePatch): # pylint: disable=too-many-instance-attributes """Description of a namespace resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2328,7 +2175,7 @@ class SBNamespaceUpdateParameters(ResourceNamespacePatch): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar sku: Properties of SKU. :vartype sku: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBSku @@ -2354,33 +2201,33 @@ class SBNamespaceUpdateParameters(ResourceNamespacePatch): """ _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}, + "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'}, + "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__( @@ -2397,7 +2244,7 @@ def __init__( """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword sku: Properties of SKU. :paramtype sku: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBSku @@ -2409,7 +2256,7 @@ def __init__( :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) + super().__init__(location=location, tags=tags, **kwargs) self.sku = sku self.identity = identity self.provisioning_state = None @@ -2422,7 +2269,7 @@ def __init__( self.encryption = encryption -class SBQueue(Resource): +class SBQueue(Resource): # pylint: disable=too-many-instance-attributes """Description of queue Resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2443,9 +2290,9 @@ class SBQueue(Resource): to this queue. :vartype accessed_at: ~datetime.datetime :ivar size_in_bytes: The size of the queue, in bytes. - :vartype size_in_bytes: long + :vartype size_in_bytes: int :ivar message_count: The number of messages in the queue. - :vartype message_count: long + :vartype message_count: int :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. @@ -2474,7 +2321,7 @@ class SBQueue(Resource): :vartype max_delivery_count: int :ivar status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". + "Deleting", "Renaming", and "Unknown". :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. @@ -2495,45 +2342,48 @@ class SBQueue(Resource): """ _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}, + "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__( + "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": "int"}, + "message_count": {"key": "properties.messageCount", "type": "int"}, + "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__( # pylint: disable=too-many-locals self, *, lock_duration: Optional[datetime.timedelta] = None, @@ -2582,7 +2432,7 @@ def __init__( :paramtype max_delivery_count: int :keyword status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". + "Deleting", "Renaming", and "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. @@ -2602,7 +2452,7 @@ def __init__( message. :paramtype forward_dead_lettered_messages_to: str """ - super(SBQueue, self).__init__(**kwargs) + super().__init__(**kwargs) self.count_details = None self.created_at = None self.updated_at = None @@ -2626,7 +2476,7 @@ def __init__( self.forward_dead_lettered_messages_to = forward_dead_lettered_messages_to -class SBQueueListResult(msrest.serialization.Model): +class SBQueueListResult(_serialization.Model): """The response to the List Queues operation. :ivar value: Result of the List Queues operation. @@ -2637,17 +2487,11 @@ class SBQueueListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SBQueue]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SBQueue]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.SBQueue"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.SBQueue"]] = None, 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] @@ -2655,19 +2499,19 @@ def __init__( list of queues. :paramtype next_link: str """ - super(SBQueueListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SBSku(msrest.serialization.Model): +class SBSku(_serialization.Model): """SKU of the namespace. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Name of this SKU. Known values are: "Basic", "Standard", "Premium". + :ivar name: Name of this SKU. Required. Known values are: "Basic", "Standard", and "Premium". :vartype name: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.SkuName - :ivar tier: The billing tier of this particular SKU. Known values are: "Basic", "Standard", + :ivar tier: The billing tier of this particular SKU. Known values are: "Basic", "Standard", and "Premium". :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 @@ -2676,13 +2520,13 @@ class SBSku(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'int'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "capacity": {"key": "capacity", "type": "int"}, } def __init__( @@ -2694,22 +2538,23 @@ def __init__( **kwargs ): """ - :keyword name: Required. Name of this SKU. Known values are: "Basic", "Standard", "Premium". + :keyword name: Name of this SKU. Required. Known values are: "Basic", "Standard", and + "Premium". :paramtype name: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.SkuName :keyword tier: The billing tier of this particular SKU. Known values are: "Basic", "Standard", - "Premium". + and "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) + super().__init__(**kwargs) self.name = name self.tier = tier self.capacity = capacity -class SBSubscription(Resource): +class SBSubscription(Resource): # pylint: disable=too-many-instance-attributes """Description of subscription resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2721,7 +2566,7 @@ class SBSubscription(Resource): :ivar type: Resource type. :vartype type: str :ivar message_count: Number of messages. - :vartype message_count: long + :vartype message_count: int :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. @@ -2752,7 +2597,7 @@ class SBSubscription(Resource): :vartype max_delivery_count: int :ivar status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". + "Deleting", "Renaming", and "Unknown". :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. @@ -2767,37 +2612,43 @@ class SBSubscription(Resource): """ _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}, + "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'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "message_count": {"key": "properties.messageCount", "type": "int"}, + "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__( @@ -2840,7 +2691,7 @@ def __init__( :paramtype max_delivery_count: int :keyword status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". + "Deleting", "Renaming", and "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. @@ -2854,7 +2705,7 @@ def __init__( message. :paramtype forward_dead_lettered_messages_to: str """ - super(SBSubscription, self).__init__(**kwargs) + super().__init__(**kwargs) self.message_count = None self.created_at = None self.accessed_at = None @@ -2874,7 +2725,7 @@ def __init__( self.forward_dead_lettered_messages_to = forward_dead_lettered_messages_to -class SBSubscriptionListResult(msrest.serialization.Model): +class SBSubscriptionListResult(_serialization.Model): """The response to the List Subscriptions operation. :ivar value: Result of the List Subscriptions operation. @@ -2885,16 +2736,12 @@ class SBSubscriptionListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SBSubscription]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SBSubscription]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.SBSubscription"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.SBSubscription"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Result of the List Subscriptions operation. @@ -2903,12 +2750,12 @@ def __init__( list of subscriptions. :paramtype next_link: str """ - super(SBSubscriptionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SBTopic(Resource): +class SBTopic(Resource): # pylint: disable=too-many-instance-attributes """Description of topic resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2920,7 +2767,7 @@ class SBTopic(Resource): :ivar type: Resource type. :vartype type: str :ivar size_in_bytes: Size of the topic, in bytes. - :vartype size_in_bytes: long + :vartype size_in_bytes: int :ivar created_at: Exact time the message was created. :vartype created_at: ~datetime.datetime :ivar updated_at: The exact time the message was updated. @@ -2949,7 +2796,7 @@ class SBTopic(Resource): :vartype enable_batched_operations: bool :ivar status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". + "Deleting", "Renaming", and "Unknown". :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 @@ -2965,37 +2812,40 @@ class SBTopic(Resource): """ _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}, + "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'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "size_in_bytes": {"key": "properties.sizeInBytes", "type": "int"}, + "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__( @@ -3032,7 +2882,7 @@ def __init__( :paramtype enable_batched_operations: bool :keyword status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". + "Deleting", "Renaming", and "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 @@ -3046,7 +2896,7 @@ def __init__( topic holds a message in memory temporarily before writing it to persistent storage. :paramtype enable_express: bool """ - super(SBTopic, self).__init__(**kwargs) + super().__init__(**kwargs) self.size_in_bytes = None self.created_at = None self.updated_at = None @@ -3065,7 +2915,7 @@ def __init__( self.enable_express = enable_express -class SBTopicListResult(msrest.serialization.Model): +class SBTopicListResult(_serialization.Model): """The response to the List Topics operation. :ivar value: Result of the List Topics operation. @@ -3076,17 +2926,11 @@ class SBTopicListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SBTopic]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SBTopic]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.SBTopic"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.SBTopic"]] = None, 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] @@ -3094,12 +2938,12 @@ def __init__( list of topics. :paramtype next_link: str """ - super(SBTopicListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SqlFilter(msrest.serialization.Model): +class SqlFilter(_serialization.Model): """Represents a filter which is a composition of an expression and an action that is executed in the pub/sub pipeline. :ivar sql_expression: The SQL expression. e.g. MyProperty='ABC'. @@ -3113,21 +2957,21 @@ class SqlFilter(msrest.serialization.Model): """ _validation = { - 'compatibility_level': {'maximum': 20, 'minimum': 20}, + "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'}, + "sql_expression": {"key": "sqlExpression", "type": "str"}, + "compatibility_level": {"key": "compatibilityLevel", "type": "int"}, + "requires_preprocessing": {"key": "requiresPreprocessing", "type": "bool"}, } def __init__( self, *, sql_expression: Optional[str] = None, - compatibility_level: Optional[int] = 20, - requires_preprocessing: Optional[bool] = True, + compatibility_level: int = 20, + requires_preprocessing: bool = True, **kwargs ): """ @@ -3140,7 +2984,7 @@ def __init__( preprocessing. :paramtype requires_preprocessing: bool """ - super(SqlFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.sql_expression = sql_expression self.compatibility_level = compatibility_level self.requires_preprocessing = requires_preprocessing @@ -3160,9 +3004,9 @@ class SqlRuleAction(Action): """ _attribute_map = { - 'sql_expression': {'key': 'sqlExpression', 'type': 'str'}, - 'compatibility_level': {'key': 'compatibilityLevel', 'type': 'int'}, - 'requires_preprocessing': {'key': 'requiresPreprocessing', 'type': 'bool'}, + "sql_expression": {"key": "sqlExpression", "type": "str"}, + "compatibility_level": {"key": "compatibilityLevel", "type": "int"}, + "requires_preprocessing": {"key": "requiresPreprocessing", "type": "bool"}, } def __init__( @@ -3170,7 +3014,7 @@ def __init__( *, sql_expression: Optional[str] = None, compatibility_level: Optional[int] = None, - requires_preprocessing: Optional[bool] = True, + requires_preprocessing: bool = True, **kwargs ): """ @@ -3183,37 +3027,37 @@ def __init__( preprocessing. :paramtype requires_preprocessing: bool """ - super(SqlRuleAction, self).__init__(sql_expression=sql_expression, compatibility_level=compatibility_level, requires_preprocessing=requires_preprocessing, **kwargs) + super().__init__( + sql_expression=sql_expression, + compatibility_level=compatibility_level, + requires_preprocessing=requires_preprocessing, + **kwargs + ) -class Subnet(msrest.serialization.Model): +class Subnet(_serialization.Model): """Properties supplied for Subnet. All required parameters must be populated in order to send to Azure. - :ivar id: Required. Resource ID of Virtual Network Subnet. + :ivar id: Resource ID of Virtual Network Subnet. Required. :vartype id: str """ _validation = { - 'id': {'required': True}, + "id": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: str, - **kwargs - ): + def __init__(self, *, id: str, **kwargs): # pylint: disable=redefined-builtin """ - :keyword id: Required. Resource ID of Virtual Network Subnet. + :keyword id: Resource ID of Virtual Network Subnet. Required. :paramtype id: str """ - super(Subnet, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id @@ -3233,33 +3077,28 @@ class VirtualNetworkRule(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "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'}, + "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, - *, - virtual_network_subnet_id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, 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) + super().__init__(**kwargs) self.virtual_network_subnet_id = virtual_network_subnet_id -class VirtualNetworkRuleListResult(msrest.serialization.Model): +class VirtualNetworkRuleListResult(_serialization.Model): """The response from the List namespace operation. :ivar value: Result of the List VirtualNetwork Rules operation. @@ -3270,16 +3109,12 @@ class VirtualNetworkRuleListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[VirtualNetworkRule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[VirtualNetworkRule]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.VirtualNetworkRule"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.VirtualNetworkRule"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Result of the List VirtualNetwork Rules operation. @@ -3288,6 +3123,6 @@ def __init__( list of VirtualNetwork Rules. :paramtype next_link: str """ - super(VirtualNetworkRuleListResult, self).__init__(**kwargs) + super().__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/_patch.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/models/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/models/_patch.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/models/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. 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 cf94f7f2109d..af42f8afb68f 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 @@ -11,28 +11,29 @@ class AccessRights(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """AccessRights.""" MANAGE = "Manage" SEND = "Send" LISTEN = "Listen" + class DefaultAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Default Action for Network Rule Set - """ + """Default Action for Network Rule Set.""" ALLOW = "Allow" DENY = "Deny" + class EncodingCaptureDescription(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Enumerates the possible values for the encoding format of capture description. - """ + """Enumerates the possible values for the encoding format of capture description.""" AVRO = "Avro" AVRO_DEFLATE = "AvroDeflate" + class EndPointProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Provisioning state of the Private Endpoint Connection. - """ + """Provisioning state of the Private Endpoint Connection.""" CREATING = "Creating" UPDATING = "Updating" @@ -41,9 +42,9 @@ class EndPointProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): CANCELED = "Canceled" FAILED = "Failed" + class EntityStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Entity status. - """ + """Entity status.""" ACTIVE = "Active" DISABLED = "Disabled" @@ -55,34 +56,36 @@ class EntityStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): RENAMING = "Renaming" UNKNOWN = "Unknown" + class FilterType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Rule filter types - """ + """Rule filter types.""" SQL_FILTER = "SqlFilter" CORRELATION_FILTER = "CorrelationFilter" + class IPAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The IP Filter Action - """ + """The IP Filter Action.""" ACCEPT = "Accept" REJECT = "Reject" + class KeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The access key to regenerate. - """ + """The access key to regenerate.""" PRIMARY_KEY = "PrimaryKey" SECONDARY_KEY = "SecondaryKey" + class MigrationConfigurationName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """MigrationConfigurationName.""" _DEFAULT = "$default" + class NameSpaceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Type of namespaces - """ + """Type of namespaces.""" MESSAGING = "Messaging" NOTIFICATION_HUB = "NotificationHub" @@ -90,58 +93,60 @@ class NameSpaceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): EVENT_HUB = "EventHub" RELAY = "Relay" + class NetworkRuleIPAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The IP Filter Action - """ + """The IP Filter Action.""" ALLOW = "Allow" + class PrivateLinkConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Status of the connection. - """ + """Status of the connection.""" PENDING = "Pending" APPROVED = "Approved" REJECTED = "Rejected" DISCONNECTED = "Disconnected" + class ProvisioningStateDR(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Provisioning state of the Alias(Disaster Recovery configuration) - possible values 'Accepted' - or 'Succeeded' or 'Failed' + or 'Succeeded' or 'Failed'. """ ACCEPTED = "Accepted" SUCCEEDED = "Succeeded" FAILED = "Failed" + class RoleDisasterRecovery(str, Enum, metaclass=CaseInsensitiveEnumMeta): """role of namespace in GEO DR - possible values 'Primary' or 'PrimaryNotReplicating' or - 'Secondary' + 'Secondary'. """ PRIMARY = "Primary" PRIMARY_NOT_REPLICATING = "PrimaryNotReplicating" SECONDARY = "Secondary" + class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Name of this SKU. - """ + """Name of this SKU.""" BASIC = "Basic" STANDARD = "Standard" PREMIUM = "Premium" + class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The billing tier of this particular SKU. - """ + """The billing tier of this particular SKU.""" BASIC = "Basic" STANDARD = "Standard" PREMIUM = "Premium" + class UnavailableReason(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the reason for the unavailability of the service. - """ + """Specifies the reason for the unavailability of the service.""" NONE = "None" INVALID_NAME = "InvalidName" diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/__init__.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/__init__.py index a21798eafb6a..75b6b102d52b 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/__init__.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/__init__.py @@ -23,20 +23,21 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'NamespacesOperations', - 'PrivateEndpointConnectionsOperations', - 'PrivateLinkResourcesOperations', - 'DisasterRecoveryConfigsOperations', - 'QueuesOperations', - 'TopicsOperations', - 'EventHubsOperations', - 'MigrationConfigsOperations', - 'PremiumMessagingRegionsOperations', - 'RegionsOperations', - 'SubscriptionsOperations', - 'RulesOperations', - 'Operations', + "NamespacesOperations", + "PrivateEndpointConnectionsOperations", + "PrivateLinkResourcesOperations", + "DisasterRecoveryConfigsOperations", + "QueuesOperations", + "TopicsOperations", + "EventHubsOperations", + "MigrationConfigsOperations", + "PremiumMessagingRegionsOperations", + "RegionsOperations", + "SubscriptionsOperations", + "RulesOperations", + "Operations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() 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 0f566aa173b3..9398ed2952e6 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 @@ -6,11 +6,16 @@ # 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, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -20,343 +25,293 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") 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: Optional[_models.CheckNameAvailability] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - resource_group_name: str, - namespace_name: str, - alias: str, - subscription_id: str, - *, - json: Optional[_models.ArmDisasterRecovery] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, alias: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - namespace_name: str, - alias: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, alias: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - namespace_name: str, - alias: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, alias: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_break_pairing_request( - resource_group_name: str, - namespace_name: str, - alias: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, alias: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_fail_over_request( - resource_group_name: str, - namespace_name: str, - alias: str, - subscription_id: str, - *, - json: Optional[_models.FailoverProperties] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, alias: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_authorization_rules_request( - resource_group_name: str, - namespace_name: str, - alias: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, alias: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_authorization_rule_request( @@ -370,34 +325,35 @@ def build_get_authorization_rule_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( @@ -411,34 +367,36 @@ def build_list_keys_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class DisasterRecoveryConfigsOperations: """ @@ -459,41 +417,102 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace + @overload def check_name_availability( self, resource_group_name: str, namespace_name: str, parameters: _models.CheckNameAvailability, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Check the give namespace name availability. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters to check availability of the given namespace name. + :param parameters: Parameters to check availability of the given namespace name. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.CheckNameAvailability + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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.v2018_01_01_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters to check availability of the given namespace name. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :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.v2018_01_01_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, + resource_group_name: str, + namespace_name: str, + parameters: Union[_models.CheckNameAvailability, IO], + **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters to check availability of the given namespace name. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.CheckNameAvailability or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameAvailabilityResult, or the result of cls(response) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResult] - _json = self._serialize.body(parameters, 'CheckNameAvailability') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CheckNameAvailability") request = build_check_name_availability_request( resource_group_name=resource_group_name, @@ -502,7 +521,8 @@ def check_name_availability( api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) @@ -510,10 +530,9 @@ def check_name_availability( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -521,55 +540,49 @@ def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + 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 - + 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, - namespace_name: str, - **kwargs: Any - ) -> Iterable[_models.ArmDisasterRecoveryListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> Iterable["_models.ArmDisasterRecovery"]: """Gets all Alias(Disaster Recovery configurations). - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: An iterator like instance of either ArmDisasterRecovery 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 + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.ArmDisasterRecovery] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ArmDisasterRecoveryListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -577,16 +590,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -602,10 +610,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -616,49 +622,117 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 + @overload def create_or_update( self, resource_group_name: str, namespace_name: str, alias: str, parameters: _models.ArmDisasterRecovery, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.ArmDisasterRecovery + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ArmDisasterRecovery or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.ArmDisasterRecovery or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ArmDisasterRecovery or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.ArmDisasterRecovery or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: Union[_models.ArmDisasterRecovery, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). Is + either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.ArmDisasterRecovery or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ArmDisasterRecovery, or the result of cls(response) + :return: ArmDisasterRecovery or None or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.ArmDisasterRecovery or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ArmDisasterRecovery]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ArmDisasterRecovery]] - _json = self._serialize.body(parameters, 'ArmDisasterRecovery') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ArmDisasterRecovery") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -668,7 +742,8 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -676,10 +751,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -689,56 +763,48 @@ def create_or_update( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ArmDisasterRecovery', pipeline_response) + 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 - + 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: str, - namespace_name: str, - alias: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -746,10 +812,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -760,49 +825,41 @@ def delete( # pylint: disable=inconsistent-return-statements 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: str, - namespace_name: str, - alias: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :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) + :return: ArmDisasterRecovery or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.ArmDisasterRecovery - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ArmDisasterRecovery] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ArmDisasterRecovery] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -810,10 +867,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -821,57 +877,49 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ArmDisasterRecovery', pipeline_response) + 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 - + 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: str, - namespace_name: str, - alias: str, - **kwargs: Any + self, 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. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.break_pairing.metadata["url"], headers=_headers, params=_params, ) @@ -879,10 +927,9 @@ def break_pairing( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -893,50 +940,118 @@ def break_pairing( # pylint: disable=inconsistent-return-statements 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 - @distributed_trace + @overload def fail_over( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, alias: str, parameters: Optional[_models.FailoverProperties] = None, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :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 content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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: + """ + + @overload + def fail_over( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Default value is None. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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: + """ + + @distributed_trace + def fail_over( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: Optional[Union[_models.FailoverProperties, IO]] = 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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). Is + either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.FailoverProperties or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - if parameters is not None: - _json = self._serialize.body(parameters, 'FailoverProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "FailoverProperties") + else: + _json = None request = build_fail_over_request( resource_group_name=resource_group_name, @@ -946,7 +1061,8 @@ def fail_over( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, json=_json, - template_url=self.fail_over.metadata['url'], + content=_content, + template_url=self.fail_over.metadata["url"], headers=_headers, params=_params, ) @@ -954,10 +1070,9 @@ def fail_over( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -968,52 +1083,45 @@ def fail_over( # pylint: disable=inconsistent-return-statements 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, - namespace_name: str, - alias: str, - **kwargs: Any - ) -> Iterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, alias: str, **kwargs: Any + ) -> Iterable["_models.SBAuthorizationRule"]: """Gets the authorization rules for a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :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) + :return: An iterator like instance of either SBAuthorizationRule 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 + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) @@ -1021,17 +1129,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -1047,10 +1149,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1061,48 +1161,38 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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: str, - namespace_name: str, - alias: str, - authorization_rule_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -1110,7 +1200,7 @@ def get_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -1118,10 +1208,9 @@ def get_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1129,52 +1218,43 @@ def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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: str, - namespace_name: str, - alias: str, - authorization_rule_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -1182,7 +1262,7 @@ def list_keys( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1190,10 +1270,9 @@ def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1201,12 +1280,11 @@ def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 - + 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 1cbbff68b736..9238b1368c53 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 @@ -7,10 +7,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- 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 urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -20,48 +25,48 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class EventHubsOperations: """ @@ -82,45 +87,40 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_by_namespace( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> Iterable[_models.EventHubListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> Iterable["_models.Eventhub"]: """Gets all the Event Hubs in a service bus Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: An iterator like instance of either Eventhub or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.EventHubListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.Eventhub] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.EventHubListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_by_namespace.metadata["url"], headers=_headers, params=_params, ) @@ -128,16 +128,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -153,10 +148,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -167,8 +160,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 b08f30bed97b..33feeb068f3c 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 @@ -6,11 +6,16 @@ # 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, Iterable, Optional, TypeVar, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -22,95 +27,88 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_and_start_migration_request_initial( +def build_create_and_start_migration_request( resource_group_name: str, namespace_name: str, config_name: Union[str, "_models.MigrationConfigurationName"], subscription_id: str, - *, - json: Optional[_models.MigrationConfigProperties] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( @@ -123,33 +121,32 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( @@ -162,33 +159,32 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_complete_migration_request( @@ -201,33 +197,32 @@ def build_complete_migration_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_revert_request( @@ -240,33 +235,33 @@ def build_revert_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class MigrationConfigsOperations: """ @@ -287,46 +282,41 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> Iterable[_models.MigrationConfigListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> Iterable["_models.MigrationConfigProperties"]: """Gets all migrationConfigurations. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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 + :return: An iterator like instance of either MigrationConfigProperties 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 + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigProperties] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MigrationConfigListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -334,16 +324,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -359,10 +344,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -373,35 +356,37 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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: str, namespace_name: str, config_name: Union[str, "_models.MigrationConfigurationName"], - parameters: _models.MigrationConfigProperties, + parameters: Union[_models.MigrationConfigProperties, IO], **kwargs: Any ) -> Optional[_models.MigrationConfigProperties]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.MigrationConfigProperties]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.MigrationConfigProperties]] - _json = self._serialize.body(parameters, 'MigrationConfigProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "MigrationConfigProperties") - request = build_create_and_start_migration_request_initial( + request = build_create_and_start_migration_request( resource_group_name=resource_group_name, namespace_name=namespace_name, config_name=config_name, @@ -409,7 +394,8 @@ def _create_and_start_migration_initial( api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_and_start_migration_initial.metadata['url'], + content=_content, + template_url=self._create_and_start_migration_initial.metadata["url"], headers=_headers, params=_params, ) @@ -417,27 +403,108 @@ def _create_and_start_migration_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) + 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 + _create_and_start_migration_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore + @overload + def begin_create_and_start_migration( + self, + resource_group_name: str, + namespace_name: str, + config_name: Union[str, "_models.MigrationConfigurationName"], + parameters: _models.MigrationConfigProperties, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param config_name: The configuration name. Should always be "$default". "$default" Required. + :type config_name: str or + ~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigurationName + :param parameters: Parameters required to create Migration Configuration. Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. + :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: + """ + + @overload + def begin_create_and_start_migration( + self, + resource_group_name: str, + namespace_name: str, + config_name: Union[str, "_models.MigrationConfigurationName"], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param config_name: The configuration name. Should always be "$default". "$default" Required. + :type config_name: str or + ~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigurationName + :param parameters: Parameters required to create Migration Configuration. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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: + """ @distributed_trace def begin_create_and_start_migration( @@ -445,21 +512,26 @@ def begin_create_and_start_migration( resource_group_name: str, namespace_name: str, config_name: Union[str, "_models.MigrationConfigurationName"], - parameters: _models.MigrationConfigProperties, + parameters: Union[_models.MigrationConfigProperties, IO], **kwargs: Any ) -> LROPoller[_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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigurationName - :param parameters: Parameters required to create Migration Configuration. + :param parameters: Parameters required to create Migration Configuration. Is either a model + type or a IO type. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigProperties + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -472,20 +544,17 @@ def begin_create_and_start_migration( of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigProperties] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.MigrationConfigProperties] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MigrationConfigProperties] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + 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 = self._create_and_start_migration_initial( # type: ignore resource_group_name=resource_group_name, @@ -494,39 +563,35 @@ def begin_create_and_start_migration( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) + deserialized = self._deserialize("MigrationConfigProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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 @@ -538,37 +603,34 @@ def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes a MigrationConfiguration. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -576,10 +638,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -590,8 +651,7 @@ def delete( # pylint: disable=inconsistent-return-statements 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( @@ -603,37 +663,34 @@ def get( ) -> _models.MigrationConfigProperties: """Retrieves Migration Config. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :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) + :return: MigrationConfigProperties or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.MigrationConfigProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MigrationConfigProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MigrationConfigProperties] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -641,10 +698,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -652,15 +708,14 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) + 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 - + 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 @@ -674,37 +729,34 @@ def complete_migration( # pylint: disable=inconsistent-return-statements 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.complete_migration.metadata["url"], headers=_headers, params=_params, ) @@ -712,10 +764,9 @@ def complete_migration( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -726,8 +777,7 @@ def complete_migration( # pylint: disable=inconsistent-return-statements 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 @distributed_trace def revert( # pylint: disable=inconsistent-return-statements @@ -739,37 +789,34 @@ def revert( # pylint: disable=inconsistent-return-statements ) -> None: """This operation reverts Migration. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.revert.metadata["url"], headers=_headers, params=_params, ) @@ -777,10 +824,9 @@ def revert( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -791,5 +837,4 @@ def revert( # pylint: disable=inconsistent-return-statements 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 8cbcfe7bede7..6e1d22414eda 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 @@ -6,11 +6,16 @@ # 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, Iterable, Optional, TypeVar, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -22,1020 +27,875 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") 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 + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **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: Optional[_models.IpFilterRule] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, ip_filter_rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **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 + resource_group_name: str, namespace_name: str, ip_filter_rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **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 + resource_group_name: str, namespace_name: str, ip_filter_rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + accept = _headers.pop("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'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_resource_group_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces") # pylint: disable=line-too-long + _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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request_initial( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - *, - json: Optional[_models.SBNamespace] = None, - content: Any = None, - **kwargs: Any +def build_create_or_update_request( + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long + _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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any +def build_delete_request( + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - *, - json: Optional[_models.SBNamespaceUpdateParameters] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_list_virtual_network_rules_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **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: Optional[_models.VirtualNetworkRule] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, virtual_network_rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **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 + resource_group_name: str, namespace_name: str, virtual_network_rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **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 + resource_group_name: str, namespace_name: str, virtual_network_rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_authorization_rules_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_authorization_rule_request( - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - subscription_id: str, - *, - json: Optional[_models.SBAuthorizationRule] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, authorization_rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_authorization_rule_request( - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, authorization_rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_authorization_rule_request( - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, authorization_rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, authorization_rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_regenerate_keys_request( - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - subscription_id: str, - *, - json: Optional[_models.RegenerateAccessKeyParameters] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, authorization_rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_check_name_availability_request( - subscription_id: str, - *, - json: Optional[_models.CheckNameAvailability] = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: + +def build_check_name_availability_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_network_rule_set_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - *, - json: Optional[_models.NetworkRuleSet] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_network_rule_set_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_network_rule_sets_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_migrate_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - *, - json: Optional[_models.SBNamespaceMigrate] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + class NamespacesOperations: # pylint: disable=too-many-public-methods """ @@ -1056,46 +916,40 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_ip_filter_rules( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> Iterable[_models.IpFilterRuleListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> Iterable["_models.IpFilterRule"]: """Gets a list of IP Filter rules for a Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: An iterator like instance of either IpFilterRule 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 + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.IpFilterRule] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.IpFilterRuleListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_ip_filter_rules.metadata["url"], headers=_headers, params=_params, ) @@ -1103,16 +957,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -1128,10 +977,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1142,49 +989,114 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 + @overload def create_or_update_ip_filter_rule( self, resource_group_name: str, namespace_name: str, ip_filter_rule_name: str, parameters: _models.IpFilterRule, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param ip_filter_rule_name: The IP Filter Rule name. + :param ip_filter_rule_name: The IP Filter Rule name. Required. :type ip_filter_rule_name: str - :param parameters: The Namespace IpFilterRule. + :param parameters: The Namespace IpFilterRule. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.IpFilterRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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.v2018_01_01_preview.models.IpFilterRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_ip_filter_rule( + self, + resource_group_name: str, + namespace_name: str, + ip_filter_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param ip_filter_rule_name: The IP Filter Rule name. Required. + :type ip_filter_rule_name: str + :param parameters: The Namespace IpFilterRule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2018_01_01_preview.models.IpFilterRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_ip_filter_rule( + self, + resource_group_name: str, + namespace_name: str, + ip_filter_rule_name: str, + parameters: Union[_models.IpFilterRule, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param ip_filter_rule_name: The IP Filter Rule name. Required. + :type ip_filter_rule_name: str + :param parameters: The Namespace IpFilterRule. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.IpFilterRule or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IpFilterRule, or the result of cls(response) + :return: IpFilterRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.IpFilterRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.IpFilterRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IpFilterRule] - _json = self._serialize.body(parameters, 'IpFilterRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "IpFilterRule") request = build_create_or_update_ip_filter_rule_request( resource_group_name=resource_group_name, @@ -1194,7 +1106,8 @@ def create_or_update_ip_filter_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_ip_filter_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_ip_filter_rule.metadata["url"], headers=_headers, params=_params, ) @@ -1202,10 +1115,9 @@ def create_or_update_ip_filter_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1213,56 +1125,48 @@ def create_or_update_ip_filter_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('IpFilterRule', pipeline_response) + 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 - + 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: str, - namespace_name: str, - ip_filter_rule_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param ip_filter_rule_name: The IP Filter Rule name. + :param ip_filter_rule_name: The IP Filter Rule name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.delete_ip_filter_rule.metadata["url"], headers=_headers, params=_params, ) @@ -1270,10 +1174,9 @@ def delete_ip_filter_rule( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1284,49 +1187,41 @@ def delete_ip_filter_rule( # pylint: disable=inconsistent-return-statements 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: str, - namespace_name: str, - ip_filter_rule_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param ip_filter_rule_name: The IP Filter Rule name. + :param ip_filter_rule_name: The IP Filter Rule name. Required. :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) + :return: IpFilterRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.IpFilterRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.IpFilterRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IpFilterRule] - 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'], + template_url=self.get_ip_filter_rule.metadata["url"], headers=_headers, params=_params, ) @@ -1334,10 +1229,9 @@ def get_ip_filter_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1345,47 +1239,41 @@ def get_ip_filter_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('IpFilterRule', pipeline_response) + 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 - + 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 - ) -> Iterable[_models.SBNamespaceListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.SBNamespace"]: """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) + :return: An iterator like instance of either SBNamespace 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 + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespace] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespaceListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -1393,14 +1281,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -1416,10 +1301,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1430,47 +1313,39 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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: str, - **kwargs: Any - ) -> Iterable[_models.SBNamespaceListResult]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.SBNamespace"]: """Gets the available namespaces within a resource group. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :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) + :return: An iterator like instance of either SBNamespace 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 + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespace] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespaceListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -1478,15 +1353,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -1502,10 +1373,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1516,41 +1385,40 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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: str, - namespace_name: str, - parameters: _models.SBNamespace, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, parameters: Union[_models.SBNamespace, IO], **kwargs: Any ) -> Optional[_models.SBNamespace]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.SBNamespace]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.SBNamespace]] - _json = self._serialize.body(parameters, 'SBNamespace') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBNamespace") - request = build_create_or_update_request_initial( + request = build_create_or_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._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1558,48 +1426,121 @@ def _create_or_update_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SBNamespace', pipeline_response) + 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 - + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, namespace_name: str, parameters: _models.SBNamespace, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters supplied to create a namespace resource. + :param parameters: Parameters supplied to create a namespace resource. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespace + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. + :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: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to create a namespace resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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: + """ + + @distributed_trace + def begin_create_or_update( + self, resource_group_name: str, namespace_name: str, parameters: Union[_models.SBNamespace, IO], **kwargs: Any + ) -> LROPoller[_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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to create a namespace resource. Is either a model type + or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespace or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -1612,20 +1553,17 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespace] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespace] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBNamespace] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + 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 = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, @@ -1633,64 +1571,54 @@ def begin_create_or_update( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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: str, - namespace_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_request_initial( + request = build_delete_request( 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'], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1698,35 +1626,29 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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_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 @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, 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. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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. @@ -1738,92 +1660,77 @@ def begin_delete( # pylint: disable=inconsistent-return-statements 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + 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 = self._delete_initial( # type: ignore resource_group_name=resource_group_name, namespace_name=namespace_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> _models.SBNamespace: + def get(self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: SBNamespace or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespace - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespace] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBNamespace] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -1831,10 +1738,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1842,60 +1748,125 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBNamespace', pipeline_response) + 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 + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - - @distributed_trace + @overload def update( self, resource_group_name: str, namespace_name: str, parameters: _models.SBNamespaceUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters supplied to update a namespace resource. + :param parameters: Parameters supplied to update a namespace resource. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespaceUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBNamespace, or the result of cls(response) + :return: SBNamespace or None or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespace or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.SBNamespace]] + @overload + def update( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Optional[_models.SBNamespace]: + """Updates a service namespace. Once created, this namespace's resource manifest is immutable. + This operation is idempotent. - _json = self._serialize.body(parameters, 'SBNamespaceUpdateParameters') + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to update a namespace resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBNamespace or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespace or None + :raises ~azure.core.exceptions.HttpResponseError: + """ - request = build_update_request( - resource_group_name=resource_group_name, + @distributed_trace + def update( + self, + resource_group_name: str, + namespace_name: str, + parameters: Union[_models.SBNamespaceUpdateParameters, IO], + **kwargs: Any + ) -> 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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to update a namespace resource. Is either a model type + or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespaceUpdateParameters + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBNamespace or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespace or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.SBNamespace]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _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'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -1903,10 +1874,9 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -1916,58 +1886,52 @@ def update( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SBNamespace', pipeline_response) + 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 - + 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, - namespace_name: str, - **kwargs: Any - ) -> Iterable[_models.VirtualNetworkRuleListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> Iterable["_models.VirtualNetworkRule"]: """Gets a list of VirtualNetwork rules for a Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: An iterator like instance of either VirtualNetworkRule 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 + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.VirtualNetworkRule] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualNetworkRuleListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_virtual_network_rules.metadata["url"], headers=_headers, params=_params, ) @@ -1975,16 +1939,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -2000,10 +1959,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2014,49 +1971,115 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 + @overload def create_or_update_virtual_network_rule( self, resource_group_name: str, namespace_name: str, virtual_network_rule_name: str, parameters: _models.VirtualNetworkRule, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param virtual_network_rule_name: The Virtual Network Rule name. + :param virtual_network_rule_name: The Virtual Network Rule name. Required. :type virtual_network_rule_name: str - :param parameters: The Namespace VirtualNetworkRule. + :param parameters: The Namespace VirtualNetworkRule. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.VirtualNetworkRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: VirtualNetworkRule, or the result of cls(response) + :return: VirtualNetworkRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.VirtualNetworkRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def create_or_update_virtual_network_rule( + self, + resource_group_name: str, + namespace_name: str, + virtual_network_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param virtual_network_rule_name: The Virtual Network Rule name. Required. + :type virtual_network_rule_name: str + :param parameters: The Namespace VirtualNetworkRule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2018_01_01_preview.models.VirtualNetworkRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_virtual_network_rule( + self, + resource_group_name: str, + namespace_name: str, + virtual_network_rule_name: str, + parameters: Union[_models.VirtualNetworkRule, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param virtual_network_rule_name: The Virtual Network Rule name. Required. + :type virtual_network_rule_name: str + :param parameters: The Namespace VirtualNetworkRule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.VirtualNetworkRule or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2018_01_01_preview.models.VirtualNetworkRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualNetworkRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.VirtualNetworkRule] - _json = self._serialize.body(parameters, 'VirtualNetworkRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "VirtualNetworkRule") request = build_create_or_update_virtual_network_rule_request( resource_group_name=resource_group_name, @@ -2066,7 +2089,8 @@ def create_or_update_virtual_network_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_virtual_network_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_virtual_network_rule.metadata["url"], headers=_headers, params=_params, ) @@ -2074,10 +2098,9 @@ def create_or_update_virtual_network_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -2085,56 +2108,48 @@ def create_or_update_virtual_network_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('VirtualNetworkRule', pipeline_response) + 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 - + 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: str, - namespace_name: str, - virtual_network_rule_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param virtual_network_rule_name: The Virtual Network Rule name. + :param virtual_network_rule_name: The Virtual Network Rule name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.delete_virtual_network_rule.metadata["url"], headers=_headers, params=_params, ) @@ -2142,10 +2157,9 @@ def delete_virtual_network_rule( # pylint: disable=inconsistent-return-statemen request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -2156,49 +2170,41 @@ def delete_virtual_network_rule( # pylint: disable=inconsistent-return-statemen 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: str, - namespace_name: str, - virtual_network_rule_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param virtual_network_rule_name: The Virtual Network Rule name. + :param virtual_network_rule_name: The Virtual Network Rule name. Required. :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) + :return: VirtualNetworkRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.VirtualNetworkRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualNetworkRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.VirtualNetworkRule] - 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'], + template_url=self.get_virtual_network_rule.metadata["url"], headers=_headers, params=_params, ) @@ -2206,10 +2212,9 @@ def get_virtual_network_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -2217,55 +2222,49 @@ def get_virtual_network_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('VirtualNetworkRule', pipeline_response) + 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 - + 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, - namespace_name: str, - **kwargs: Any - ) -> Iterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> Iterable["_models.SBAuthorizationRule"]: """Gets the authorization rules for a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: An iterator like instance of either SBAuthorizationRule 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 + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) @@ -2273,16 +2272,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -2298,10 +2292,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2312,49 +2304,115 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 + @overload def create_or_update_authorization_rule( self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, parameters: _models.SBAuthorizationRule, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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.v2018_01_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: Union[_models.SBAuthorizationRule, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2018_01_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - _json = self._serialize.body(parameters, 'SBAuthorizationRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBAuthorizationRule") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -2364,7 +2422,8 @@ def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -2372,10 +2431,9 @@ def create_or_update_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -2383,56 +2441,48 @@ def create_or_update_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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: str, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -2440,10 +2490,9 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -2454,49 +2503,41 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements 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: str, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - 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'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -2504,10 +2545,9 @@ def get_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -2515,56 +2555,48 @@ def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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: str, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - 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'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -2572,10 +2604,9 @@ def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -2583,54 +2614,122 @@ def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys"} # type: ignore - - @distributed_trace + @overload def regenerate_keys( self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, parameters: _models.RegenerateAccessKeyParameters, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.RegenerateAccessKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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.v2018_01_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2018_01_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateAccessKeyParameters, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: + ~azure.mgmt.servicebus.v2018_01_01_preview.models.RegenerateAccessKeyParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateAccessKeyParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -2640,7 +2739,8 @@ def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) @@ -2648,10 +2748,9 @@ def regenerate_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -2659,51 +2758,91 @@ def regenerate_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 + regenerate_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore + + @overload + def check_name_availability( + self, parameters: _models.CheckNameAvailability, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param parameters: Parameters to check availability of the given namespace name. Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.CheckNameAvailability + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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.v2018_01_01_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + def check_name_availability( + self, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param parameters: Parameters to check availability of the given namespace name. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :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.v2018_01_01_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def check_name_availability( - self, - parameters: _models.CheckNameAvailability, - **kwargs: Any + self, parameters: Union[_models.CheckNameAvailability, IO], **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Check the give namespace name availability. - :param parameters: Parameters to check availability of the given namespace name. - :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.CheckNameAvailability + :param parameters: Parameters to check availability of the given namespace name. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.CheckNameAvailability or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameAvailabilityResult, or the result of cls(response) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResult] - _json = self._serialize.body(parameters, 'CheckNameAvailability') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _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'], + content=_content, + template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) @@ -2711,10 +2850,9 @@ def check_name_availability( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -2722,50 +2860,110 @@ def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + 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 + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability"} # type: ignore - - @distributed_trace + @overload def create_or_update_network_rule_set( self, resource_group_name: str, namespace_name: str, parameters: _models.NetworkRuleSet, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.NetworkRuleSet: """Create or update NetworkRuleSet for a Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: The Namespace IpFilterRule. + :param parameters: The Namespace IpFilterRule. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.NetworkRuleSet + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: NetworkRuleSet, or the result of cls(response) + :return: NetworkRuleSet or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.NetworkRuleSet - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def create_or_update_network_rule_set( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NetworkRuleSet: + """Create or update NetworkRuleSet for a Namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: The Namespace IpFilterRule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2018_01_01_preview.models.NetworkRuleSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_network_rule_set( + self, + resource_group_name: str, + namespace_name: str, + parameters: Union[_models.NetworkRuleSet, IO], + **kwargs: Any + ) -> _models.NetworkRuleSet: + """Create or update NetworkRuleSet for a Namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: The Namespace IpFilterRule. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.NetworkRuleSet or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2018_01_01_preview.models.NetworkRuleSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkRuleSet] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.NetworkRuleSet] - _json = self._serialize.body(parameters, 'NetworkRuleSet') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "NetworkRuleSet") request = build_create_or_update_network_rule_set_request( resource_group_name=resource_group_name, @@ -2774,7 +2972,8 @@ def create_or_update_network_rule_set( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_network_rule_set.metadata['url'], + content=_content, + template_url=self.create_or_update_network_rule_set.metadata["url"], headers=_headers, params=_params, ) @@ -2782,10 +2981,9 @@ def create_or_update_network_rule_set( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -2793,52 +2991,45 @@ def create_or_update_network_rule_set( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('NetworkRuleSet', pipeline_response) + 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 - + 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: str, - namespace_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: NetworkRuleSet or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.NetworkRuleSet - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkRuleSet] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.NetworkRuleSet] - 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'], + template_url=self.get_network_rule_set.metadata["url"], headers=_headers, params=_params, ) @@ -2846,10 +3037,9 @@ def get_network_rule_set( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -2857,55 +3047,49 @@ def get_network_rule_set( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('NetworkRuleSet', pipeline_response) + 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 - + 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, - namespace_name: str, - **kwargs: Any - ) -> Iterable[_models.NetworkRuleSetListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> Iterable["_models.NetworkRuleSet"]: """Gets list of NetworkRuleSet for a Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: An iterator like instance of either NetworkRuleSet 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 + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.NetworkRuleSet] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkRuleSetListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_network_rule_sets.metadata["url"], headers=_headers, params=_params, ) @@ -2913,16 +3097,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -2938,10 +3117,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2952,46 +3129,106 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 + @overload def migrate( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, parameters: _models.SBNamespaceMigrate, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters supplied to migrate namespace type. + :param parameters: Parameters supplied to migrate namespace type. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespaceMigrate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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: + """ + + @overload + def migrate( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to migrate namespace type. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace + def migrate( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + namespace_name: str, + parameters: Union[_models.SBNamespaceMigrate, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to migrate namespace type. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBNamespaceMigrate or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(parameters, 'SBNamespaceMigrate') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBNamespaceMigrate") request = build_migrate_request( resource_group_name=resource_group_name, @@ -3000,7 +3237,8 @@ def migrate( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, json=_json, - template_url=self.migrate.metadata['url'], + content=_content, + template_url=self.migrate.metadata["url"], headers=_headers, params=_params, ) @@ -3008,10 +3246,9 @@ def migrate( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -3022,5 +3259,4 @@ def migrate( # pylint: disable=inconsistent-return-statements 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 17015193e603..b7072c06031a 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 @@ -7,10 +7,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- 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 urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -20,38 +25,34 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +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: + +def build_list_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.ServiceBus/operations") # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class Operations: """ @@ -72,36 +73,31 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.OperationListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """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) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -109,13 +105,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -131,10 +125,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -145,8 +137,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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/_patch.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_patch.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2018_01_01_preview/operations/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. 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 a5f3e7668937..8106331930c1 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 @@ -7,10 +7,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- 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 urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -20,44 +25,41 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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: + +def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/premiumMessagingRegions") # pylint: disable=line-too-long + _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'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class PremiumMessagingRegionsOperations: """ @@ -78,38 +80,33 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.PremiumMessagingRegionsListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.PremiumMessagingRegions"]: """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 + :return: An iterator like instance of either PremiumMessagingRegions 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 + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.PremiumMessagingRegions] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PremiumMessagingRegionsListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -117,14 +114,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -140,10 +134,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -154,8 +146,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 f159fa5afd31..5930df3b5eae 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 @@ -6,11 +6,16 @@ # 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, Iterable, Optional, TypeVar, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -22,134 +27,130 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - subscription_id: str, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, - *, - json: Optional[_models.PrivateEndpointConnection] = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( +def build_delete_request( resource_group_name: str, namespace_name: str, - subscription_id: str, private_endpoint_connection_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( @@ -162,33 +163,35 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class PrivateEndpointConnectionsOperations: """ @@ -209,46 +212,41 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> Iterable[_models.PrivateEndpointConnectionListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> Iterable["_models.PrivateEndpointConnection"]: """Gets the available PrivateEndpointConnections within a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: An iterator like instance of either PrivateEndpointConnection 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 + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnectionListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -256,16 +254,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -281,10 +274,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -295,60 +286,129 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 + @overload def create_or_update( self, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, parameters: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.PrivateEndpointConnection: """Creates or updates PrivateEndpointConnections of service namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param private_endpoint_connection_name: The PrivateEndpointConnection name. + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. :type private_endpoint_connection_name: str :param parameters: Parameters supplied to update Status of PrivateEndPoint Connection to - namespace resource. + namespace resource. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.PrivateEndpointConnection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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.v2018_01_01_preview.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Creates or updates PrivateEndpointConnections of service namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. + :type private_endpoint_connection_name: str + :param parameters: Parameters supplied to update Status of PrivateEndPoint Connection to + namespace resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateEndpointConnection, or the result of cls(response) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + parameters: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Creates or updates PrivateEndpointConnections of service namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. + :type private_endpoint_connection_name: str + :param parameters: Parameters supplied to update Status of PrivateEndPoint Connection to + namespace resource. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.PrivateEndpointConnection + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2018_01_01_preview.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - _json = self._serialize.body(parameters, 'PrivateEndpointConnection') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _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, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -356,10 +416,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -368,45 +427,37 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + 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 - + 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: str, - namespace_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_request_initial( + request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, - subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) @@ -414,37 +465,32 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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_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 @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + def begin_delete( + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param private_endpoint_connection_name: The PrivateEndpointConnection name. + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. :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. @@ -456,97 +502,83 @@ def begin_delete( # pylint: disable=inconsistent-return-statements 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + 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 = self._delete_initial( # type: ignore 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, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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: str, - namespace_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param private_endpoint_connection_name: The PrivateEndpointConnection name. + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. :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) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -554,10 +586,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -565,12 +596,11 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + 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 - + 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 d1ab1a13f50e..66739799083c 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 @@ -8,9 +8,13 @@ # -------------------------------------------------------------------------- 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.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,48 +23,48 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class PrivateLinkResourcesOperations: """ @@ -81,43 +85,36 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def get( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: PrivateLinkResourcesListResult or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.PrivateLinkResourcesListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourcesListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResourcesListResult] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -125,10 +122,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -136,12 +132,11 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateLinkResourcesListResult', pipeline_response) + 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 - + 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 38a618ede0a4..576ea2937037 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 @@ -6,11 +6,16 @@ # 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, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -20,50 +25,48 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") 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 + resource_group_name: str, namespace_name: str, queue_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_authorization_rule_request( @@ -72,47 +75,43 @@ def build_create_or_update_authorization_rule_request( queue_name: str, authorization_rule_name: str, subscription_id: str, - *, - json: Optional[_models.SBAuthorizationRule] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_authorization_rule_request( @@ -126,34 +125,35 @@ def build_delete_authorization_rule_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_authorization_rule_request( @@ -167,34 +167,35 @@ def build_get_authorization_rule_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( @@ -208,34 +209,35 @@ def build_list_keys_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_regenerate_keys_request( @@ -244,47 +246,43 @@ def build_regenerate_keys_request( queue_name: str, authorization_rule_name: str, subscription_id: str, - *, - json: Optional[_models.RegenerateAccessKeyParameters] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_namespace_request( @@ -299,161 +297,141 @@ def build_list_by_namespace_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if skip is not None: - _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', maximum=1000, minimum=0) + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", maximum=1000, minimum=0) if top is not None: - _params['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - resource_group_name: str, - namespace_name: str, - queue_name: str, - subscription_id: str, - *, - json: Optional[_models.SBQueue] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, queue_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - namespace_name: str, - queue_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, queue_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - namespace_name: str, - queue_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, queue_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class QueuesOperations: """ @@ -474,50 +452,43 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - **kwargs: Any - ) -> Iterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, queue_name: str, **kwargs: Any + ) -> Iterable["_models.SBAuthorizationRule"]: """Gets all authorization rules for a queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :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) + :return: An iterator like instance of either SBAuthorizationRule 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 + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) @@ -525,17 +496,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -551,10 +516,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -565,13 +528,11 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 + @overload def create_or_update_authorization_rule( self, resource_group_name: str, @@ -579,38 +540,112 @@ def create_or_update_authorization_rule( queue_name: str, authorization_rule_name: str, parameters: _models.SBAuthorizationRule, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBAuthorizationRule: """Creates an authorization rule for a queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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.v2018_01_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for a queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: Union[_models.SBAuthorizationRule, IO], + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for a queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2018_01_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - _json = self._serialize.body(parameters, 'SBAuthorizationRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBAuthorizationRule") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -621,7 +656,8 @@ def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -629,10 +665,9 @@ def create_or_update_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -640,15 +675,14 @@ def create_or_update_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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 @@ -661,31 +695,28 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes a queue authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -693,7 +724,7 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_authorization_rule.metadata['url'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -701,10 +732,9 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -715,8 +745,7 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements 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( @@ -729,31 +758,28 @@ def get_authorization_rule( ) -> _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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -761,7 +787,7 @@ def get_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -769,10 +795,9 @@ def get_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -780,15 +805,14 @@ def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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( @@ -801,31 +825,28 @@ def list_keys( ) -> _models.AccessKeys: """Primary and secondary connection strings to the queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -833,7 +854,7 @@ def list_keys( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -841,10 +862,9 @@ def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -852,17 +872,16 @@ def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 - + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore - @distributed_trace + @overload def regenerate_keys( self, resource_group_name: str, @@ -870,39 +889,114 @@ def regenerate_keys( queue_name: str, authorization_rule_name: str, parameters: _models.RegenerateAccessKeyParameters, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.RegenerateAccessKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2018_01_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateAccessKeyParameters, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: + ~azure.mgmt.servicebus.v2018_01_01_preview.models.RegenerateAccessKeyParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2018_01_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateAccessKeyParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -913,7 +1007,8 @@ def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) @@ -921,10 +1016,9 @@ def regenerate_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -932,15 +1026,14 @@ def regenerate_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 - + 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( @@ -950,12 +1043,12 @@ def list_by_namespace( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable[_models.SBQueueListResult]: + ) -> Iterable["_models.SBQueue"]: """Gets the queues within a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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 @@ -965,32 +1058,30 @@ def list_by_namespace( 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] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either SBQueue or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBQueue] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBQueueListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + api_version=api_version, + template_url=self.list_by_namespace.metadata["url"], headers=_headers, params=_params, ) @@ -998,18 +1089,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -1025,10 +1109,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1039,49 +1121,115 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 + @overload def create_or_update( self, resource_group_name: str, namespace_name: str, queue_name: str, parameters: _models.SBQueue, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param parameters: Parameters supplied to create or update a queue resource. + :param parameters: Parameters supplied to create or update a queue resource. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBQueue + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBQueue, or the result of cls(response) + :return: SBQueue or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param parameters: Parameters supplied to create or update a queue resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2018_01_01_preview.models.SBQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + parameters: Union[_models.SBQueue, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param parameters: Parameters supplied to create or update a queue resource. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBQueue or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2018_01_01_preview.models.SBQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBQueue] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBQueue] - _json = self._serialize.body(parameters, 'SBQueue') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBQueue") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -1091,7 +1239,8 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -1099,10 +1248,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1110,56 +1258,48 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBQueue', pipeline_response) + 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 - + 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: str, - namespace_name: str, - queue_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -1167,10 +1307,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1181,49 +1320,39 @@ def delete( # pylint: disable=inconsistent-return-statements 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: str, - namespace_name: str, - queue_name: str, - **kwargs: Any - ) -> _models.SBQueue: + def get(self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :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) + :return: SBQueue or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBQueue] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBQueue] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -1231,10 +1360,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1242,12 +1370,11 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBQueue', pipeline_response) + 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 - + 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 23272e4c8cb6..c059dcfdfd17 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 @@ -7,10 +7,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- 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 urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -20,46 +25,42 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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: + +def build_list_by_sku_request(sku: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/sku/{sku}/regions") + _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), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + class RegionsOperations: """ @@ -80,42 +81,36 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list_by_sku( - self, - sku: str, - **kwargs: Any - ) -> Iterable[_models.PremiumMessagingRegionsListResult]: + def list_by_sku(self, sku: str, **kwargs: Any) -> Iterable["_models.PremiumMessagingRegions"]: """Gets the available Regions for a given sku. - :param sku: The sku type. + :param sku: The sku type. Required. :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 + :return: An iterator like instance of either PremiumMessagingRegions 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 + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.PremiumMessagingRegions] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PremiumMessagingRegionsListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_sku_request( - subscription_id=self._config.subscription_id, sku=sku, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_sku.metadata['url'], + template_url=self.list_by_sku.metadata["url"], headers=_headers, params=_params, ) @@ -123,15 +118,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_sku_request( - subscription_id=self._config.subscription_id, - sku=sku, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -147,10 +138,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -161,8 +150,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 eb30400a3be8..f8a10dca8fef 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 @@ -6,11 +6,16 @@ # 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, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -20,13 +25,16 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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_subscriptions_request( resource_group_name: str, namespace_name: str, @@ -41,38 +49,37 @@ def build_list_by_subscriptions_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if skip is not None: - _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', maximum=1000, minimum=0) + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", maximum=1000, minimum=0) if top is not None: - _params['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( @@ -82,48 +89,42 @@ def build_create_or_update_request( subscription_name: str, rule_name: str, subscription_id: str, - *, - json: Optional[_models.Rule] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( @@ -138,35 +139,34 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( @@ -181,35 +181,35 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class RulesOperations: """ @@ -230,7 +230,6 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_by_subscriptions( self, @@ -241,16 +240,16 @@ def list_by_subscriptions( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable[_models.RuleListResult]: + ) -> Iterable["_models.Rule"]: """List all the rules within given topic-subscription. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :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 @@ -260,34 +259,32 @@ def list_by_subscriptions( 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] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Rule or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.Rule] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.RuleListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + api_version=api_version, + template_url=self.list_by_subscriptions.metadata["url"], headers=_headers, params=_params, ) @@ -295,20 +292,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -324,10 +312,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -338,13 +324,11 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 + @overload def create_or_update( self, resource_group_name: str, @@ -353,40 +337,120 @@ def create_or_update( subscription_name: str, rule_name: str, parameters: _models.Rule, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param rule_name: The rule name. + :param rule_name: The rule name. Required. :type rule_name: str - :param parameters: Parameters supplied to create a rule. + :param parameters: Parameters supplied to create a rule. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.Rule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Rule, or the result of cls(response) + :return: Rule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.Rule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param rule_name: The rule name. Required. + :type rule_name: str + :param parameters: Parameters supplied to create a rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2018_01_01_preview.models.Rule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + parameters: Union[_models.Rule, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param rule_name: The rule name. Required. + :type rule_name: str + :param parameters: Parameters supplied to create a rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.Rule or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2018_01_01_preview.models.Rule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Rule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Rule] - _json = self._serialize.body(parameters, 'Rule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Rule") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -398,7 +462,8 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -406,10 +471,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -417,15 +481,14 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Rule', pipeline_response) + 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 - + 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 @@ -439,33 +502,30 @@ def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes an existing rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param rule_name: The rule name. + :param rule_name: The rule name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -474,7 +534,7 @@ def delete( # pylint: disable=inconsistent-return-statements rule_name=rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -482,10 +542,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -496,8 +555,7 @@ def delete( # pylint: disable=inconsistent-return-statements 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( @@ -511,33 +569,30 @@ def get( ) -> _models.Rule: """Retrieves the description for the specified rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param rule_name: The rule name. + :param rule_name: The rule name. Required. :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) + :return: Rule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.Rule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Rule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Rule] - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -546,7 +601,7 @@ def get( rule_name=rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -554,10 +609,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -565,12 +619,11 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Rule', pipeline_response) + 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 - + 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 2a218a0afe1a..c2ef0fd00fdc 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 @@ -6,11 +6,16 @@ # 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, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -20,13 +25,16 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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_topic_request( resource_group_name: str, namespace_name: str, @@ -40,37 +48,36 @@ def build_list_by_topic_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if skip is not None: - _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', maximum=1000, minimum=0) + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", maximum=1000, minimum=0) if top is not None: - _params['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( @@ -79,47 +86,41 @@ def build_create_or_update_request( topic_name: str, subscription_name: str, subscription_id: str, - *, - json: Optional[_models.SBSubscription] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( @@ -133,34 +134,33 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( @@ -174,34 +174,34 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class SubscriptionsOperations: """ @@ -222,7 +222,6 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_by_topic( self, @@ -232,14 +231,14 @@ def list_by_topic( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable[_models.SBSubscriptionListResult]: + ) -> Iterable["_models.SBSubscription"]: """List all the subscriptions under a specified topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :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 @@ -249,34 +248,32 @@ def list_by_topic( 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) + :return: An iterator like instance of either SBSubscription 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 + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBSubscription] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBSubscriptionListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + api_version=api_version, + template_url=self.list_by_topic.metadata["url"], headers=_headers, params=_params, ) @@ -284,19 +281,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -312,10 +301,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -326,13 +313,11 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 + @overload def create_or_update( self, resource_group_name: str, @@ -340,38 +325,112 @@ def create_or_update( topic_name: str, subscription_name: str, parameters: _models.SBSubscription, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBSubscription: """Creates a topic subscription. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param parameters: Parameters supplied to create a subscription resource. + :param parameters: Parameters supplied to create a subscription resource. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBSubscription + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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.v2018_01_01_preview.models.SBSubscription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBSubscription: + """Creates a topic subscription. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param parameters: Parameters supplied to create a subscription resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2018_01_01_preview.models.SBSubscription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + parameters: Union[_models.SBSubscription, IO], + **kwargs: Any + ) -> _models.SBSubscription: + """Creates a topic subscription. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param parameters: Parameters supplied to create a subscription resource. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBSubscription or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBSubscription, or the result of cls(response) + :return: SBSubscription or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBSubscription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBSubscription] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBSubscription] - _json = self._serialize.body(parameters, 'SBSubscription') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBSubscription") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -382,7 +441,8 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -390,10 +450,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -401,52 +460,43 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBSubscription', pipeline_response) + 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 - + 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: str, - namespace_name: str, - topic_name: str, - subscription_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -454,7 +504,7 @@ def delete( # pylint: disable=inconsistent-return-statements subscription_name=subscription_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -462,10 +512,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -476,45 +525,36 @@ def delete( # pylint: disable=inconsistent-return-statements 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: str, - namespace_name: str, - topic_name: str, - subscription_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :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) + :return: SBSubscription or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBSubscription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBSubscription] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBSubscription] - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -522,7 +562,7 @@ def get( subscription_name=subscription_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -530,10 +570,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -541,12 +580,11 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBSubscription', pipeline_response) + 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 - + 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 54a52eb8ba8e..ccedbc552bb8 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 @@ -6,11 +6,16 @@ # 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, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -20,50 +25,48 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") 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 + resource_group_name: str, namespace_name: str, topic_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_authorization_rule_request( @@ -72,47 +75,43 @@ def build_create_or_update_authorization_rule_request( topic_name: str, authorization_rule_name: str, subscription_id: str, - *, - json: Optional[_models.SBAuthorizationRule] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_authorization_rule_request( @@ -126,34 +125,35 @@ def build_get_authorization_rule_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_authorization_rule_request( @@ -167,34 +167,35 @@ def build_delete_authorization_rule_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( @@ -208,34 +209,35 @@ def build_list_keys_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_regenerate_keys_request( @@ -244,47 +246,43 @@ def build_regenerate_keys_request( topic_name: str, authorization_rule_name: str, subscription_id: str, - *, - json: Optional[_models.RegenerateAccessKeyParameters] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_namespace_request( @@ -299,161 +297,141 @@ def build_list_by_namespace_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if skip is not None: - _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', maximum=1000, minimum=0) + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", maximum=1000, minimum=0) if top is not None: - _params['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_id: str, - *, - json: Optional[_models.SBTopic] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, topic_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, topic_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, topic_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class TopicsOperations: """ @@ -474,50 +452,43 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - **kwargs: Any - ) -> Iterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, topic_name: str, **kwargs: Any + ) -> Iterable["_models.SBAuthorizationRule"]: """Gets authorization rules for a topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :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) + :return: An iterator like instance of either SBAuthorizationRule 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 + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) @@ -525,17 +496,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -551,10 +516,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -565,13 +528,11 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 + @overload def create_or_update_authorization_rule( self, resource_group_name: str, @@ -579,38 +540,112 @@ def create_or_update_authorization_rule( topic_name: str, authorization_rule_name: str, parameters: _models.SBAuthorizationRule, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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.v2018_01_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: Union[_models.SBAuthorizationRule, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2018_01_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - _json = self._serialize.body(parameters, 'SBAuthorizationRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBAuthorizationRule") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -621,7 +656,8 @@ def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -629,10 +665,9 @@ def create_or_update_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -640,15 +675,14 @@ def create_or_update_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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( @@ -661,31 +695,28 @@ def get_authorization_rule( ) -> _models.SBAuthorizationRule: """Returns the specified authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -693,7 +724,7 @@ def get_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -701,10 +732,9 @@ def get_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -712,15 +742,14 @@ def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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 @@ -733,31 +762,28 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes a topic authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -765,7 +791,7 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_authorization_rule.metadata['url'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -773,10 +799,9 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -787,8 +812,7 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements 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( @@ -801,31 +825,28 @@ def list_keys( ) -> _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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -833,7 +854,7 @@ def list_keys( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -841,10 +862,9 @@ def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -852,17 +872,16 @@ def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 - + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore - @distributed_trace + @overload def regenerate_keys( self, resource_group_name: str, @@ -870,39 +889,114 @@ def regenerate_keys( topic_name: str, authorization_rule_name: str, parameters: _models.RegenerateAccessKeyParameters, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.RegenerateAccessKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2018_01_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateAccessKeyParameters, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: + ~azure.mgmt.servicebus.v2018_01_01_preview.models.RegenerateAccessKeyParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2018_01_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateAccessKeyParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -913,7 +1007,8 @@ def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) @@ -921,10 +1016,9 @@ def regenerate_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -932,15 +1026,14 @@ def regenerate_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 - + 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( @@ -950,12 +1043,12 @@ def list_by_namespace( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable[_models.SBTopicListResult]: + ) -> Iterable["_models.SBTopic"]: """Gets all the topics in a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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 @@ -965,32 +1058,30 @@ def list_by_namespace( 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] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either SBTopic or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2018_01_01_preview.models.SBTopic] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBTopicListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + api_version=api_version, + template_url=self.list_by_namespace.metadata["url"], headers=_headers, params=_params, ) @@ -998,18 +1089,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -1025,10 +1109,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1039,49 +1121,115 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 + @overload def create_or_update( self, resource_group_name: str, namespace_name: str, topic_name: str, parameters: _models.SBTopic, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBTopic: """Creates a topic in the specified namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param parameters: Parameters supplied to create a topic resource. + :param parameters: Parameters supplied to create a topic resource. Required. :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBTopic + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBTopic, or the result of cls(response) + :return: SBTopic or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBTopic - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBTopic: + """Creates a topic in the specified namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param parameters: Parameters supplied to create a topic resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2018_01_01_preview.models.SBTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + parameters: Union[_models.SBTopic, IO], + **kwargs: Any + ) -> _models.SBTopic: + """Creates a topic in the specified namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param parameters: Parameters supplied to create a topic resource. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBTopic or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2018_01_01_preview.models.SBTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBTopic] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBTopic] - _json = self._serialize.body(parameters, 'SBTopic') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBTopic") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -1091,7 +1239,8 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -1099,10 +1248,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1110,56 +1258,48 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBTopic', pipeline_response) + 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 - + 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: str, - namespace_name: str, - topic_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -1167,10 +1307,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1181,49 +1320,39 @@ def delete( # pylint: disable=inconsistent-return-statements 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: str, - namespace_name: str, - topic_name: str, - **kwargs: Any - ) -> _models.SBTopic: + def get(self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :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) + :return: SBTopic or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2018_01_01_preview.models.SBTopic - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBTopic] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBTopic] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -1231,10 +1360,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1242,12 +1370,11 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBTopic', pipeline_response) + 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 - + 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 221541a00fb6..2a82b6cb6f69 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 @@ -17,7 +17,8 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['ServiceBusManagementClient'] + +__all__ = ["ServiceBusManagementClient"] __all__.extend([p for p in _patch_all if p not in __all__]) _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 d78f9e92a5dc..933f7d7b499d 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 @@ -25,24 +25,19 @@ class ServiceBusManagementClientConfiguration(Configuration): # pylint: disable Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :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. + subscription. The subscription ID forms part of the URI for every service call. Required. :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: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, 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 + api_version = kwargs.pop("api_version", "2021-01-01-preview") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -52,23 +47,24 @@ def __init__( self.credential = credential self.subscription_id = subscription_id 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.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-servicebus/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> None - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(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 77f7bafcb300..e7de7bbfc407 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 @@ -10,20 +10,20 @@ "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\"], \"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\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ServiceBusManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ServiceBusManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", + "signature": "subscription_id: str,", + "description": "Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", + "description": "Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false 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 index 0ad201a8c586..f7dd32510333 100644 --- 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 @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. 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 fff867ece7b1..5945793adc35 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 @@ -9,20 +9,31 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import ServiceBusManagementClientConfiguration -from .operations import DisasterRecoveryConfigsOperations, MigrationConfigsOperations, NamespacesOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, QueuesOperations, RulesOperations, SubscriptionsOperations, TopicsOperations +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: # pylint: disable=too-many-instance-attributes + +class ServiceBusManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Azure Service Bus client for managing Namespace. :ivar namespaces: NamespacesOperations operations @@ -50,10 +61,10 @@ class ServiceBusManagementClient: # pylint: disable=too-many-instance-attribu :ivar subscriptions: SubscriptionsOperations operations :vartype subscriptions: azure.mgmt.servicebus.v2021_01_01_preview.operations.SubscriptionsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :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. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -71,50 +82,35 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ServiceBusManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + 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._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.namespaces = NamespacesOperations( - 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.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.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: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -123,7 +119,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest 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 index 138f663c53a4..9aad73fc743e 100644 --- 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 @@ -7,6 +7,7 @@ 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) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): 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 - ] + 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 920456322fa1..9f1dc6e309ba 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 = "8.1.0" +VERSION = "0.0.0 (it should be stable)" 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 e7dd87df1f93..ba757410f14a 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 @@ -14,7 +14,8 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['ServiceBusManagementClient'] + +__all__ = ["ServiceBusManagementClient"] __all__.extend([p for p in _patch_all if p not in __all__]) _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 52f2360f8f02..2a2242bb2ac8 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 @@ -25,24 +25,19 @@ class ServiceBusManagementClientConfiguration(Configuration): # pylint: disable Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :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. + subscription. The subscription ID forms part of the URI for every service call. Required. :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: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(ServiceBusManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + api_version = kwargs.pop("api_version", "2021-01-01-preview") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -52,22 +47,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id 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.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-servicebus/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, - **kwargs: Any - ) -> None: - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(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 index 0ad201a8c586..f7dd32510333 100644 --- 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 @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. 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 5bc88f396797..2cfb356fc02d 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 @@ -9,20 +9,31 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import ServiceBusManagementClientConfiguration -from .operations import DisasterRecoveryConfigsOperations, MigrationConfigsOperations, NamespacesOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, QueuesOperations, RulesOperations, SubscriptionsOperations, TopicsOperations +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: # pylint: disable=too-many-instance-attributes + +class ServiceBusManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Azure Service Bus client for managing Namespace. :ivar namespaces: NamespacesOperations operations @@ -51,10 +62,10 @@ class ServiceBusManagementClient: # pylint: disable=too-many-instance-attribu :ivar subscriptions: SubscriptionsOperations operations :vartype subscriptions: azure.mgmt.servicebus.v2021_01_01_preview.aio.operations.SubscriptionsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :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. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -72,50 +83,35 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ServiceBusManagementClientConfiguration(credential=credential, subscription_id=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._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.namespaces = NamespacesOperations( - 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.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.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 - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -124,7 +120,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/__init__.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/__init__.py index 5559ccd3746c..831edc36bd6b 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/__init__.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/__init__.py @@ -20,17 +20,18 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'NamespacesOperations', - 'PrivateEndpointConnectionsOperations', - 'PrivateLinkResourcesOperations', - 'Operations', - 'DisasterRecoveryConfigsOperations', - 'MigrationConfigsOperations', - 'QueuesOperations', - 'TopicsOperations', - 'RulesOperations', - 'SubscriptionsOperations', + "NamespacesOperations", + "PrivateEndpointConnectionsOperations", + "PrivateLinkResourcesOperations", + "Operations", + "DisasterRecoveryConfigsOperations", + "MigrationConfigsOperations", + "QueuesOperations", + "TopicsOperations", + "RulesOperations", + "SubscriptionsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() 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 a116fa6bf83a..d2b434053612 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 @@ -6,10 +6,17 @@ # 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, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +27,23 @@ 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') +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]] + class DisasterRecoveryConfigsOperations: """ .. warning:: @@ -43,41 +63,102 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async + @overload async def check_name_availability( self, resource_group_name: str, namespace_name: str, parameters: _models.CheckNameAvailability, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Check the give namespace name availability. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters to check availability of the given namespace name. + :param parameters: Parameters to check availability of the given namespace name. Required. :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.CheckNameAvailability + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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.v2021_01_01_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters to check availability of the given namespace name. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :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.v2021_01_01_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, + resource_group_name: str, + namespace_name: str, + parameters: Union[_models.CheckNameAvailability, IO], + **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters to check availability of the given namespace name. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.CheckNameAvailability or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameAvailabilityResult, or the result of cls(response) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResult] - _json = self._serialize.body(parameters, 'CheckNameAvailability') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CheckNameAvailability") request = build_check_name_availability_request( resource_group_name=resource_group_name, @@ -86,7 +167,8 @@ async def check_name_availability( api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) @@ -94,10 +176,9 @@ async def check_name_availability( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -105,55 +186,49 @@ async def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + 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 - + 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, - namespace_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.ArmDisasterRecoveryListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ArmDisasterRecovery"]: """Gets all Alias(Disaster Recovery configurations). - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: An iterator like instance of either ArmDisasterRecovery 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 + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.ArmDisasterRecovery] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ArmDisasterRecoveryListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -161,16 +236,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -186,10 +256,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -200,49 +268,117 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 + @overload async def create_or_update( self, resource_group_name: str, namespace_name: str, alias: str, parameters: _models.ArmDisasterRecovery, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Required. :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.ArmDisasterRecovery + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ArmDisasterRecovery or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.ArmDisasterRecovery or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ArmDisasterRecovery, or the result of cls(response) + :return: ArmDisasterRecovery or None or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.ArmDisasterRecovery or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: Union[_models.ArmDisasterRecovery, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). Is + either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.ArmDisasterRecovery or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ArmDisasterRecovery or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.ArmDisasterRecovery or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ArmDisasterRecovery]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ArmDisasterRecovery]] - _json = self._serialize.body(parameters, 'ArmDisasterRecovery') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ArmDisasterRecovery") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -252,7 +388,8 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -260,10 +397,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -273,56 +409,48 @@ async def create_or_update( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ArmDisasterRecovery', pipeline_response) + 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 - + 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, - alias: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -330,10 +458,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -344,49 +471,41 @@ async def delete( # pylint: disable=inconsistent-return-statements 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, - namespace_name: str, - alias: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :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) + :return: ArmDisasterRecovery or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.ArmDisasterRecovery - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ArmDisasterRecovery] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ArmDisasterRecovery] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -394,10 +513,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -405,57 +523,49 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ArmDisasterRecovery', pipeline_response) + 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 - + 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, - alias: str, - **kwargs: Any + self, 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. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.break_pairing.metadata["url"], headers=_headers, params=_params, ) @@ -463,10 +573,9 @@ async def break_pairing( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -477,50 +586,118 @@ async def break_pairing( # pylint: disable=inconsistent-return-statements 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 - @distributed_trace_async + @overload async def fail_over( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, alias: str, parameters: Optional[_models.FailoverProperties] = None, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :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 content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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: + """ + + @overload + async def fail_over( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Default value is None. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace_async + async def fail_over( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: Optional[Union[_models.FailoverProperties, IO]] = 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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). Is + either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.FailoverProperties or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - if parameters is not None: - _json = self._serialize.body(parameters, 'FailoverProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "FailoverProperties") + else: + _json = None request = build_fail_over_request( resource_group_name=resource_group_name, @@ -530,7 +707,8 @@ async def fail_over( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, json=_json, - template_url=self.fail_over.metadata['url'], + content=_content, + template_url=self.fail_over.metadata["url"], headers=_headers, params=_params, ) @@ -538,10 +716,9 @@ async def fail_over( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -552,52 +729,45 @@ async def fail_over( # pylint: disable=inconsistent-return-statements 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, - namespace_name: str, - alias: str, - **kwargs: Any - ) -> AsyncIterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, alias: str, **kwargs: Any + ) -> AsyncIterable["_models.SBAuthorizationRule"]: """Gets the authorization rules for a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :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) + :return: An iterator like instance of either SBAuthorizationRule 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 + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) @@ -605,17 +775,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -631,10 +795,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -645,48 +807,38 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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, - namespace_name: str, - alias: str, - authorization_rule_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -694,7 +846,7 @@ async def get_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -702,10 +854,9 @@ async def get_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -713,52 +864,43 @@ async def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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, - namespace_name: str, - alias: str, - authorization_rule_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -766,7 +908,7 @@ async def list_keys( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -774,10 +916,9 @@ async def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -785,12 +926,11 @@ async def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 - + 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 a50cd2ea520d..7e5ab5df3ef6 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 @@ -6,10 +6,17 @@ # 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, Optional, TypeVar, Union, cast +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +29,19 @@ 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') +from ...operations._migration_configs_operations import ( + build_complete_migration_request, + build_create_and_start_migration_request, + 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]] + class MigrationConfigsOperations: """ .. warning:: @@ -45,46 +61,41 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.MigrationConfigListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.MigrationConfigProperties"]: """Gets all migrationConfigurations. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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 + :return: An iterator like instance of either MigrationConfigProperties 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 + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigProperties] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MigrationConfigListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -92,16 +103,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -117,10 +123,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -131,35 +135,37 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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, resource_group_name: str, namespace_name: str, config_name: Union[str, "_models.MigrationConfigurationName"], - parameters: _models.MigrationConfigProperties, + parameters: Union[_models.MigrationConfigProperties, IO], **kwargs: Any ) -> Optional[_models.MigrationConfigProperties]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.MigrationConfigProperties]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.MigrationConfigProperties]] - _json = self._serialize.body(parameters, 'MigrationConfigProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "MigrationConfigProperties") - request = build_create_and_start_migration_request_initial( + request = build_create_and_start_migration_request( resource_group_name=resource_group_name, namespace_name=namespace_name, config_name=config_name, @@ -167,7 +173,8 @@ async def _create_and_start_migration_initial( api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_and_start_migration_initial.metadata['url'], + content=_content, + template_url=self._create_and_start_migration_initial.metadata["url"], headers=_headers, params=_params, ) @@ -175,27 +182,108 @@ async def _create_and_start_migration_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) + 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 + _create_and_start_migration_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore + @overload + async def begin_create_and_start_migration( + self, + resource_group_name: str, + namespace_name: str, + config_name: Union[str, "_models.MigrationConfigurationName"], + parameters: _models.MigrationConfigProperties, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> 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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param config_name: The configuration name. Should always be "$default". "$default" Required. + :type config_name: str or + ~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigurationName + :param parameters: Parameters required to create Migration Configuration. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. + :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: + """ + + @overload + async def begin_create_and_start_migration( + self, + resource_group_name: str, + namespace_name: str, + config_name: Union[str, "_models.MigrationConfigurationName"], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> 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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param config_name: The configuration name. Should always be "$default". "$default" Required. + :type config_name: str or + ~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigurationName + :param parameters: Parameters required to create Migration Configuration. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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: + """ @distributed_trace_async async def begin_create_and_start_migration( @@ -203,21 +291,26 @@ async def begin_create_and_start_migration( resource_group_name: str, namespace_name: str, config_name: Union[str, "_models.MigrationConfigurationName"], - parameters: _models.MigrationConfigProperties, + parameters: Union[_models.MigrationConfigProperties, IO], **kwargs: Any ) -> 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigurationName - :param parameters: Parameters required to create Migration Configuration. + :param parameters: Parameters required to create Migration Configuration. Is either a model + type or a IO type. Required. :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigProperties + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -230,20 +323,17 @@ async def begin_create_and_start_migration( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigProperties] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.MigrationConfigProperties] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MigrationConfigProperties] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + 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( # type: ignore resource_group_name=resource_group_name, @@ -252,39 +342,35 @@ async def begin_create_and_start_migration( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) + deserialized = self._deserialize("MigrationConfigProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, 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 + deserialization_callback=get_long_running_output, ) 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 + begin_create_and_start_migration.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -296,37 +382,34 @@ async def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes a MigrationConfiguration. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -334,10 +417,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -348,8 +430,7 @@ async def delete( # pylint: disable=inconsistent-return-statements 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( @@ -361,37 +442,34 @@ async def get( ) -> _models.MigrationConfigProperties: """Retrieves Migration Config. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :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) + :return: MigrationConfigProperties or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MigrationConfigProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MigrationConfigProperties] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -399,10 +477,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -410,15 +487,14 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) + 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 - + 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 @@ -432,37 +508,34 @@ async def complete_migration( # pylint: disable=inconsistent-return-statements 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.complete_migration.metadata["url"], headers=_headers, params=_params, ) @@ -470,10 +543,9 @@ async def complete_migration( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -484,8 +556,7 @@ async def complete_migration( # pylint: disable=inconsistent-return-statements 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 @distributed_trace_async async def revert( # pylint: disable=inconsistent-return-statements @@ -497,37 +568,34 @@ async def revert( # pylint: disable=inconsistent-return-statements ) -> None: """This operation reverts Migration. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.revert.metadata["url"], headers=_headers, params=_params, ) @@ -535,10 +603,9 @@ async def revert( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -549,5 +616,4 @@ async def revert( # pylint: disable=inconsistent-return-statements 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 ea9fa3f391b7..77c44a6db5ae 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 @@ -6,10 +6,17 @@ # 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, Optional, TypeVar, Union, cast +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +29,29 @@ 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') +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, + build_delete_authorization_rule_request, + build_delete_request, + 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]] + class NamespacesOperations: """ .. warning:: @@ -45,38 +71,32 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.SBNamespaceListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.SBNamespace"]: """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) + :return: An iterator like instance of either SBNamespace 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 + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBNamespace] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespaceListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -84,14 +104,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -107,10 +124,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -121,47 +136,39 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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, - **kwargs: Any - ) -> AsyncIterable[_models.SBNamespaceListResult]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.SBNamespace"]: """Gets the available namespaces within a resource group. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :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) + :return: An iterator like instance of either SBNamespace 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 + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBNamespace] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespaceListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -169,15 +176,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -193,10 +196,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -207,41 +208,40 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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, - resource_group_name: str, - namespace_name: str, - parameters: _models.SBNamespace, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, parameters: Union[_models.SBNamespace, IO], **kwargs: Any ) -> Optional[_models.SBNamespace]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.SBNamespace]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.SBNamespace]] - _json = self._serialize.body(parameters, 'SBNamespace') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBNamespace") - request = build_create_or_update_request_initial( + request = build_create_or_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._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) @@ -249,48 +249,121 @@ async def _create_or_update_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SBNamespace', pipeline_response) + 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 - + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - @distributed_trace_async + @overload async def begin_create_or_update( self, resource_group_name: str, namespace_name: str, parameters: _models.SBNamespace, + *, + content_type: str = "application/json", **kwargs: Any ) -> 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters supplied to create a namespace resource. + :param parameters: Parameters supplied to create a namespace resource. Required. :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBNamespace + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. + :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: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> 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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to create a namespace resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, resource_group_name: str, namespace_name: str, parameters: Union[_models.SBNamespace, IO], **kwargs: Any + ) -> 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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to create a namespace resource. Is either a model type + or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBNamespace or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -303,20 +376,17 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBNamespace] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespace] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBNamespace] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + 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( # type: ignore resource_group_name=resource_group_name, @@ -324,64 +394,54 @@ async def begin_create_or_update( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, 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 + deserialization_callback=get_long_running_output, ) 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 + 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, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_request_initial( + request = build_delete_request( 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'], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) @@ -389,35 +449,29 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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_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 @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete(self, resource_group_name: str, namespace_name: str, **kwargs: Any) -> 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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. @@ -429,92 +483,77 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + 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( # type: ignore resource_group_name=resource_group_name, namespace_name=namespace_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, 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 + deserialization_callback=get_long_running_output, ) 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 + 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, - namespace_name: str, - **kwargs: Any - ) -> _models.SBNamespace: + async def get(self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: SBNamespace or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBNamespace - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespace] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBNamespace] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -522,10 +561,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -533,51 +571,115 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBNamespace', pipeline_response) + 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 + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + @overload + async def update( + self, + resource_group_name: str, + namespace_name: str, + parameters: _models.SBNamespaceUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> 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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to update a namespace resource. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBNamespaceUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBNamespace or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBNamespace or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> 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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to update a namespace resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBNamespace or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBNamespace or None + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def update( self, resource_group_name: str, namespace_name: str, - parameters: _models.SBNamespaceUpdateParameters, + parameters: Union[_models.SBNamespaceUpdateParameters, IO], **kwargs: Any ) -> 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters supplied to update a namespace resource. + :param parameters: Parameters supplied to update a namespace resource. Is either a model type + or a IO type. Required. :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBNamespaceUpdateParameters + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBNamespace, or the result of cls(response) + :return: SBNamespace or None or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBNamespace or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.SBNamespace]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.SBNamespace]] - _json = self._serialize.body(parameters, 'SBNamespaceUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBNamespaceUpdateParameters") request = build_update_request( resource_group_name=resource_group_name, @@ -586,7 +688,8 @@ async def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -594,10 +697,9 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -607,53 +709,113 @@ async def update( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SBNamespace', pipeline_response) + 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 + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - - @distributed_trace_async + @overload async def create_or_update_network_rule_set( self, resource_group_name: str, namespace_name: str, parameters: _models.NetworkRuleSet, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.NetworkRuleSet: """Create or update NetworkRuleSet for a Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: The Namespace IpFilterRule. + :param parameters: The Namespace IpFilterRule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.NetworkRuleSet + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: NetworkRuleSet, or the result of cls(response) + :return: NetworkRuleSet or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.NetworkRuleSet - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + async def create_or_update_network_rule_set( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NetworkRuleSet: + """Create or update NetworkRuleSet for a Namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: The Namespace IpFilterRule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2021_01_01_preview.models.NetworkRuleSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_network_rule_set( + self, + resource_group_name: str, + namespace_name: str, + parameters: Union[_models.NetworkRuleSet, IO], + **kwargs: Any + ) -> _models.NetworkRuleSet: + """Create or update NetworkRuleSet for a Namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: The Namespace IpFilterRule. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.NetworkRuleSet or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2021_01_01_preview.models.NetworkRuleSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkRuleSet] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.NetworkRuleSet] - _json = self._serialize.body(parameters, 'NetworkRuleSet') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "NetworkRuleSet") request = build_create_or_update_network_rule_set_request( resource_group_name=resource_group_name, @@ -662,7 +824,8 @@ async def create_or_update_network_rule_set( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_network_rule_set.metadata['url'], + content=_content, + template_url=self.create_or_update_network_rule_set.metadata["url"], headers=_headers, params=_params, ) @@ -670,10 +833,9 @@ async def create_or_update_network_rule_set( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -681,52 +843,45 @@ async def create_or_update_network_rule_set( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('NetworkRuleSet', pipeline_response) + 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 - + 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, - namespace_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: NetworkRuleSet or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.NetworkRuleSet - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkRuleSet] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.NetworkRuleSet] - 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'], + template_url=self.get_network_rule_set.metadata["url"], headers=_headers, params=_params, ) @@ -734,10 +889,9 @@ async def get_network_rule_set( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -745,55 +899,49 @@ async def get_network_rule_set( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('NetworkRuleSet', pipeline_response) + 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 - + 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, - namespace_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.NetworkRuleSetListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.NetworkRuleSet"]: """Gets list of NetworkRuleSet for a Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: An iterator like instance of either NetworkRuleSet 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 + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.NetworkRuleSet] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkRuleSetListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_network_rule_sets.metadata["url"], headers=_headers, params=_params, ) @@ -801,16 +949,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -826,10 +969,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -840,51 +981,44 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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, - namespace_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SBAuthorizationRule"]: """Gets the authorization rules for a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: An iterator like instance of either SBAuthorizationRule 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 + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) @@ -892,16 +1026,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -917,10 +1046,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -931,49 +1058,115 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 + @overload async def create_or_update_authorization_rule( self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, parameters: _models.SBAuthorizationRule, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2021_01_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: Union[_models.SBAuthorizationRule, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2021_01_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - _json = self._serialize.body(parameters, 'SBAuthorizationRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBAuthorizationRule") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -983,7 +1176,8 @@ async def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -991,10 +1185,9 @@ async def create_or_update_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1002,56 +1195,48 @@ async def create_or_update_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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, - authorization_rule_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -1059,10 +1244,9 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1073,49 +1257,41 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat 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, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - 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'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -1123,10 +1299,9 @@ async def get_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1134,56 +1309,48 @@ async def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - 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'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1191,10 +1358,9 @@ async def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1202,54 +1368,122 @@ async def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys"} # type: ignore - - @distributed_trace_async + @overload async def regenerate_keys( self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, parameters: _models.RegenerateAccessKeyParameters, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.RegenerateAccessKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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.v2021_01_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace_async + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateAccessKeyParameters, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: + ~azure.mgmt.servicebus.v2021_01_01_preview.models.RegenerateAccessKeyParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2021_01_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateAccessKeyParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -1259,7 +1493,8 @@ async def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1267,10 +1502,9 @@ async def regenerate_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1278,51 +1512,91 @@ async def regenerate_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 + regenerate_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore + @overload + async def check_name_availability( + self, parameters: _models.CheckNameAvailability, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param parameters: Parameters to check availability of the given namespace name. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.CheckNameAvailability + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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.v2021_01_01_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param parameters: Parameters to check availability of the given namespace name. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :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.v2021_01_01_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def check_name_availability( - self, - parameters: _models.CheckNameAvailability, - **kwargs: Any + self, parameters: Union[_models.CheckNameAvailability, IO], **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Check the give namespace name availability. - :param parameters: Parameters to check availability of the given namespace name. - :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.CheckNameAvailability + :param parameters: Parameters to check availability of the given namespace name. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.CheckNameAvailability or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameAvailabilityResult, or the result of cls(response) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResult] - _json = self._serialize.body(parameters, 'CheckNameAvailability') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _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'], + content=_content, + template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) @@ -1330,10 +1604,9 @@ async def check_name_availability( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1341,12 +1614,11 @@ async def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + 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 - + 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 1dd31f0daad0..5a44627dfaf7 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 @@ -7,9 +7,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +27,11 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class Operations: """ .. warning:: @@ -42,36 +51,31 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.OperationListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """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) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -79,13 +83,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -101,10 +103,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -115,8 +115,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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/_patch.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_patch.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/aio/operations/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. 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 31f68d205e98..d913520f1659 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 @@ -6,10 +6,17 @@ # 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, Optional, TypeVar, Union, cast +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +29,17 @@ 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') +from ...operations._private_endpoint_connections_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class PrivateEndpointConnectionsOperations: """ .. warning:: @@ -45,46 +59,41 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.PrivateEndpointConnectionListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PrivateEndpointConnection"]: """Gets the available PrivateEndpointConnections within a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: An iterator like instance of either PrivateEndpointConnection 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 + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnectionListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -92,16 +101,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -117,10 +121,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -131,60 +133,129 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 + @overload async def create_or_update( self, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, parameters: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.PrivateEndpointConnection: """Creates or updates PrivateEndpointConnections of service namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param private_endpoint_connection_name: The PrivateEndpointConnection name. + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. :type private_endpoint_connection_name: str :param parameters: Parameters supplied to update Status of PrivateEndPoint Connection to - namespace resource. + namespace resource. Required. :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.PrivateEndpointConnection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateEndpointConnection, or the result of cls(response) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Creates or updates PrivateEndpointConnections of service namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. + :type private_endpoint_connection_name: str + :param parameters: Parameters supplied to update Status of PrivateEndPoint Connection to + namespace resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2021_01_01_preview.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + parameters: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Creates or updates PrivateEndpointConnections of service namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. + :type private_endpoint_connection_name: str + :param parameters: Parameters supplied to update Status of PrivateEndPoint Connection to + namespace resource. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.PrivateEndpointConnection + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2021_01_01_preview.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - _json = self._serialize.body(parameters, 'PrivateEndpointConnection') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _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, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -192,10 +263,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -204,45 +274,37 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + 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 - + 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, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_request_initial( + request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, - subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) @@ -250,37 +312,32 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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_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 @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes an existing Private Endpoint Connection. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param private_endpoint_connection_name: The PrivateEndpointConnection name. + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. :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. @@ -292,97 +349,83 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + 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( # type: ignore 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, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, 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 + deserialization_callback=get_long_running_output, ) 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 + 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, - namespace_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param private_endpoint_connection_name: The PrivateEndpointConnection name. + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. :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) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -390,10 +433,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -401,12 +443,11 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + 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 - + 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 e411d3ee57ee..fa97adf180fc 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 @@ -8,7 +8,13 @@ # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Optional, TypeVar -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -19,9 +25,11 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._private_link_resources_operations import build_get_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class PrivateLinkResourcesOperations: """ .. warning:: @@ -41,43 +49,36 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async async def get( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: PrivateLinkResourcesListResult or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.PrivateLinkResourcesListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourcesListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResourcesListResult] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -85,10 +86,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -96,12 +96,11 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateLinkResourcesListResult', pipeline_response) + 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 - + 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 a0dd3b79f63a..e3260dcecf43 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 @@ -6,10 +6,17 @@ # 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, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +27,23 @@ 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') +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]] + class QueuesOperations: """ .. warning:: @@ -43,50 +63,43 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, queue_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SBAuthorizationRule"]: """Gets all authorization rules for a queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :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) + :return: An iterator like instance of either SBAuthorizationRule 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 + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) @@ -94,17 +107,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -120,10 +127,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -134,13 +139,11 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 + @overload async def create_or_update_authorization_rule( self, resource_group_name: str, @@ -148,38 +151,112 @@ async def create_or_update_authorization_rule( queue_name: str, authorization_rule_name: str, parameters: _models.SBAuthorizationRule, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBAuthorizationRule: """Creates an authorization rule for a queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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.v2021_01_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for a queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace_async + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: Union[_models.SBAuthorizationRule, IO], + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for a queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2021_01_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - _json = self._serialize.body(parameters, 'SBAuthorizationRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBAuthorizationRule") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -190,7 +267,8 @@ async def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -198,10 +276,9 @@ async def create_or_update_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -209,15 +286,14 @@ async def create_or_update_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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 @@ -230,31 +306,28 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat ) -> None: """Deletes a queue authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -262,7 +335,7 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_authorization_rule.metadata['url'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -270,10 +343,9 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -284,8 +356,7 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat 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( @@ -298,31 +369,28 @@ async def get_authorization_rule( ) -> _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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -330,7 +398,7 @@ async def get_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -338,10 +406,9 @@ async def get_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -349,15 +416,14 @@ async def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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( @@ -370,31 +436,28 @@ async def list_keys( ) -> _models.AccessKeys: """Primary and secondary connection strings to the queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -402,7 +465,7 @@ async def list_keys( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -410,10 +473,9 @@ async def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -421,17 +483,16 @@ async def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 - + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore - @distributed_trace_async + @overload async def regenerate_keys( self, resource_group_name: str, @@ -439,39 +500,114 @@ async def regenerate_keys( queue_name: str, authorization_rule_name: str, parameters: _models.RegenerateAccessKeyParameters, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.RegenerateAccessKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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.v2021_01_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2021_01_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateAccessKeyParameters, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: + ~azure.mgmt.servicebus.v2021_01_01_preview.models.RegenerateAccessKeyParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateAccessKeyParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -482,7 +618,8 @@ async def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) @@ -490,10 +627,9 @@ async def regenerate_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -501,15 +637,14 @@ async def regenerate_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 - + 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( @@ -519,12 +654,12 @@ def list_by_namespace( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable[_models.SBQueueListResult]: + ) -> AsyncIterable["_models.SBQueue"]: """Gets the queues within a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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 @@ -534,32 +669,31 @@ def list_by_namespace( 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) + :return: An iterator like instance of either SBQueue or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBQueueListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBQueue] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBQueueListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + api_version=api_version, + template_url=self.list_by_namespace.metadata["url"], headers=_headers, params=_params, ) @@ -567,18 +701,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -594,10 +721,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -608,49 +733,115 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 + @overload async def create_or_update( self, resource_group_name: str, namespace_name: str, queue_name: str, parameters: _models.SBQueue, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param parameters: Parameters supplied to create or update a queue resource. + :param parameters: Parameters supplied to create or update a queue resource. Required. :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBQueue + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBQueue, or the result of cls(response) + :return: SBQueue or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param parameters: Parameters supplied to create or update a queue resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2021_01_01_preview.models.SBQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + parameters: Union[_models.SBQueue, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param parameters: Parameters supplied to create or update a queue resource. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBQueue or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2021_01_01_preview.models.SBQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBQueue] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBQueue] - _json = self._serialize.body(parameters, 'SBQueue') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBQueue") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -660,7 +851,8 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -668,10 +860,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -679,56 +870,48 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBQueue', pipeline_response) + 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 - + 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, - queue_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -736,10 +919,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -750,49 +932,41 @@ async def delete( # pylint: disable=inconsistent-return-statements 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, - namespace_name: str, - queue_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :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) + :return: SBQueue or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBQueue] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBQueue] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -800,10 +974,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -811,12 +984,11 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBQueue', pipeline_response) + 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 - + 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 555da9b53416..f2c81d926dbb 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 @@ -6,10 +6,17 @@ # 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, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +27,17 @@ 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') +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]] + class RulesOperations: """ .. warning:: @@ -43,7 +57,6 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_by_subscriptions( self, @@ -54,16 +67,16 @@ def list_by_subscriptions( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable[_models.RuleListResult]: + ) -> AsyncIterable["_models.Rule"]: """List all the rules within given topic-subscription. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :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 @@ -73,34 +86,33 @@ def list_by_subscriptions( 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) + :return: An iterator like instance of either Rule or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.RuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.Rule] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.RuleListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + api_version=api_version, + template_url=self.list_by_subscriptions.metadata["url"], headers=_headers, params=_params, ) @@ -108,20 +120,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -137,10 +140,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -151,13 +152,11 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 + @overload async def create_or_update( self, resource_group_name: str, @@ -166,40 +165,120 @@ async def create_or_update( subscription_name: str, rule_name: str, parameters: _models.Rule, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param rule_name: The rule name. + :param rule_name: The rule name. Required. :type rule_name: str - :param parameters: Parameters supplied to create a rule. + :param parameters: Parameters supplied to create a rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.Rule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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.v2021_01_01_preview.models.Rule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param rule_name: The rule name. Required. + :type rule_name: str + :param parameters: Parameters supplied to create a rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2021_01_01_preview.models.Rule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + parameters: Union[_models.Rule, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param rule_name: The rule name. Required. + :type rule_name: str + :param parameters: Parameters supplied to create a rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.Rule or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Rule, or the result of cls(response) + :return: Rule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.Rule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Rule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Rule] - _json = self._serialize.body(parameters, 'Rule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Rule") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -211,7 +290,8 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -219,10 +299,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -230,15 +309,14 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Rule', pipeline_response) + 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 - + 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 @@ -252,33 +330,30 @@ async def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes an existing rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param rule_name: The rule name. + :param rule_name: The rule name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -287,7 +362,7 @@ async def delete( # pylint: disable=inconsistent-return-statements rule_name=rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -295,10 +370,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -309,8 +383,7 @@ async def delete( # pylint: disable=inconsistent-return-statements 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( @@ -324,33 +397,30 @@ async def get( ) -> _models.Rule: """Retrieves the description for the specified rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param rule_name: The rule name. + :param rule_name: The rule name. Required. :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) + :return: Rule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.Rule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Rule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Rule] - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -359,7 +429,7 @@ async def get( rule_name=rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -367,10 +437,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -378,12 +447,11 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Rule', pipeline_response) + 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 - + 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 44c8226c8844..60451d45a520 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 @@ -6,10 +6,17 @@ # 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, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +27,17 @@ 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') +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]] + class SubscriptionsOperations: """ .. warning:: @@ -43,7 +57,6 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_by_topic( self, @@ -53,14 +66,14 @@ def list_by_topic( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable[_models.SBSubscriptionListResult]: + ) -> AsyncIterable["_models.SBSubscription"]: """List all the subscriptions under a specified topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :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 @@ -70,34 +83,32 @@ def list_by_topic( 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) + :return: An iterator like instance of either SBSubscription 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 + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBSubscription] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBSubscriptionListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + api_version=api_version, + template_url=self.list_by_topic.metadata["url"], headers=_headers, params=_params, ) @@ -105,19 +116,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -133,10 +136,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -147,13 +148,11 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 + @overload async def create_or_update( self, resource_group_name: str, @@ -161,38 +160,112 @@ async def create_or_update( topic_name: str, subscription_name: str, parameters: _models.SBSubscription, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBSubscription: """Creates a topic subscription. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param parameters: Parameters supplied to create a subscription resource. + :param parameters: Parameters supplied to create a subscription resource. Required. :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBSubscription + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBSubscription, or the result of cls(response) + :return: SBSubscription or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBSubscription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBSubscription: + """Creates a topic subscription. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param parameters: Parameters supplied to create a subscription resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2021_01_01_preview.models.SBSubscription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + parameters: Union[_models.SBSubscription, IO], + **kwargs: Any + ) -> _models.SBSubscription: + """Creates a topic subscription. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param parameters: Parameters supplied to create a subscription resource. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBSubscription or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2021_01_01_preview.models.SBSubscription + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBSubscription] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBSubscription] - _json = self._serialize.body(parameters, 'SBSubscription') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBSubscription") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -203,7 +276,8 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -211,10 +285,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -222,52 +295,43 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBSubscription', pipeline_response) + 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 - + 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, - topic_name: str, - subscription_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -275,7 +339,7 @@ async def delete( # pylint: disable=inconsistent-return-statements subscription_name=subscription_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -283,10 +347,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -297,45 +360,36 @@ async def delete( # pylint: disable=inconsistent-return-statements 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, - namespace_name: str, - topic_name: str, - subscription_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :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) + :return: SBSubscription or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBSubscription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBSubscription] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBSubscription] - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -343,7 +397,7 @@ async def get( subscription_name=subscription_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -351,10 +405,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -362,12 +415,11 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBSubscription', pipeline_response) + 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 - + 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 7bb7d6f6ac4c..f0d876c83ffe 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 @@ -6,10 +6,17 @@ # 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, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +27,23 @@ 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') +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]] + class TopicsOperations: """ .. warning:: @@ -43,50 +63,43 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, topic_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SBAuthorizationRule"]: """Gets authorization rules for a topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :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) + :return: An iterator like instance of either SBAuthorizationRule 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 + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) @@ -94,17 +107,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -120,10 +127,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -134,13 +139,11 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 + @overload async def create_or_update_authorization_rule( self, resource_group_name: str, @@ -148,38 +151,112 @@ async def create_or_update_authorization_rule( topic_name: str, authorization_rule_name: str, parameters: _models.SBAuthorizationRule, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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.v2021_01_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace_async + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: Union[_models.SBAuthorizationRule, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2021_01_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - _json = self._serialize.body(parameters, 'SBAuthorizationRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBAuthorizationRule") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -190,7 +267,8 @@ async def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -198,10 +276,9 @@ async def create_or_update_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -209,15 +286,14 @@ async def create_or_update_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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( @@ -230,31 +306,28 @@ async def get_authorization_rule( ) -> _models.SBAuthorizationRule: """Returns the specified authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -262,7 +335,7 @@ async def get_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -270,10 +343,9 @@ async def get_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -281,15 +353,14 @@ async def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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 @@ -302,31 +373,28 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat ) -> None: """Deletes a topic authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -334,7 +402,7 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_authorization_rule.metadata['url'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -342,10 +410,9 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -356,8 +423,7 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat 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( @@ -370,31 +436,28 @@ async def list_keys( ) -> _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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -402,7 +465,7 @@ async def list_keys( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -410,10 +473,9 @@ async def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -421,17 +483,16 @@ async def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 - + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore - @distributed_trace_async + @overload async def regenerate_keys( self, resource_group_name: str, @@ -439,39 +500,114 @@ async def regenerate_keys( topic_name: str, authorization_rule_name: str, parameters: _models.RegenerateAccessKeyParameters, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.RegenerateAccessKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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.v2021_01_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2021_01_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateAccessKeyParameters, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: + ~azure.mgmt.servicebus.v2021_01_01_preview.models.RegenerateAccessKeyParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateAccessKeyParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -482,7 +618,8 @@ async def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) @@ -490,10 +627,9 @@ async def regenerate_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -501,15 +637,14 @@ async def regenerate_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 - + 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( @@ -519,12 +654,12 @@ def list_by_namespace( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable[_models.SBTopicListResult]: + ) -> AsyncIterable["_models.SBTopic"]: """Gets all the topics in a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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 @@ -534,32 +669,31 @@ def list_by_namespace( 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) + :return: An iterator like instance of either SBTopic or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBTopicListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBTopic] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBTopicListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + api_version=api_version, + template_url=self.list_by_namespace.metadata["url"], headers=_headers, params=_params, ) @@ -567,18 +701,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -594,10 +721,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -608,49 +733,115 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 + @overload async def create_or_update( self, resource_group_name: str, namespace_name: str, topic_name: str, parameters: _models.SBTopic, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBTopic: """Creates a topic in the specified namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param parameters: Parameters supplied to create a topic resource. + :param parameters: Parameters supplied to create a topic resource. Required. :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBTopic + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBTopic, or the result of cls(response) + :return: SBTopic or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBTopic - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBTopic: + """Creates a topic in the specified namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param parameters: Parameters supplied to create a topic resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2021_01_01_preview.models.SBTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + parameters: Union[_models.SBTopic, IO], + **kwargs: Any + ) -> _models.SBTopic: + """Creates a topic in the specified namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param parameters: Parameters supplied to create a topic resource. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBTopic or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2021_01_01_preview.models.SBTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBTopic] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBTopic] - _json = self._serialize.body(parameters, 'SBTopic') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBTopic") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -660,7 +851,8 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -668,10 +860,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -679,56 +870,48 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBTopic', pipeline_response) + 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 - + 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, - topic_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -736,10 +919,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -750,49 +932,41 @@ async def delete( # pylint: disable=inconsistent-return-statements 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, - namespace_name: str, - topic_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :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) + :return: SBTopic or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBTopic - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBTopic] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBTopic] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -800,10 +974,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -811,12 +984,11 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBTopic', pipeline_response) + 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 - + 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 8da943ad1f9b..1d4ebbcf1d90 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 @@ -61,99 +61,97 @@ from ._models_py3 import TrackedResource from ._models_py3 import UserAssignedIdentityProperties - -from ._service_bus_management_client_enums import ( - AccessRights, - CreatedByType, - DefaultAction, - EndPointProvisioningState, - EntityStatus, - FilterType, - KeyType, - ManagedServiceIdentityType, - MigrationConfigurationName, - NetworkRuleIPAction, - PrivateLinkConnectionStatus, - ProvisioningStateDR, - RoleDisasterRecovery, - SkuName, - SkuTier, - UnavailableReason, -) +from ._service_bus_management_client_enums import AccessRights +from ._service_bus_management_client_enums import CreatedByType +from ._service_bus_management_client_enums import DefaultAction +from ._service_bus_management_client_enums import EndPointProvisioningState +from ._service_bus_management_client_enums import EntityStatus +from ._service_bus_management_client_enums import FilterType +from ._service_bus_management_client_enums import KeyType +from ._service_bus_management_client_enums import ManagedServiceIdentityType +from ._service_bus_management_client_enums import MigrationConfigurationName +from ._service_bus_management_client_enums import NetworkRuleIPAction +from ._service_bus_management_client_enums import PrivateLinkConnectionStatus +from ._service_bus_management_client_enums import ProvisioningStateDR +from ._service_bus_management_client_enums import RoleDisasterRecovery +from ._service_bus_management_client_enums import SkuName +from ._service_bus_management_client_enums import SkuTier +from ._service_bus_management_client_enums import UnavailableReason from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'AccessKeys', - 'Action', - 'ArmDisasterRecovery', - 'ArmDisasterRecoveryListResult', - 'CheckNameAvailability', - 'CheckNameAvailabilityResult', - 'ConnectionState', - 'CorrelationFilter', - 'DictionaryValue', - 'Encryption', - 'ErrorAdditionalInfo', - 'ErrorResponse', - 'ErrorResponseError', - 'FailoverProperties', - 'Identity', - 'KeyVaultProperties', - 'MessageCountDetails', - 'MigrationConfigListResult', - 'MigrationConfigProperties', - 'NWRuleSetIpRules', - 'NWRuleSetVirtualNetworkRules', - 'NetworkRuleSet', - 'NetworkRuleSetListResult', - 'Operation', - 'OperationDisplay', - 'OperationListResult', - 'PrivateEndpoint', - 'PrivateEndpointConnection', - 'PrivateEndpointConnectionListResult', - 'PrivateLinkResource', - 'PrivateLinkResourcesListResult', - 'RegenerateAccessKeyParameters', - 'Resource', - 'ResourceNamespacePatch', - 'Rule', - 'RuleListResult', - 'SBAuthorizationRule', - 'SBAuthorizationRuleListResult', - 'SBNamespace', - 'SBNamespaceListResult', - 'SBNamespaceUpdateParameters', - 'SBQueue', - 'SBQueueListResult', - 'SBSku', - 'SBSubscription', - 'SBSubscriptionListResult', - 'SBTopic', - 'SBTopicListResult', - 'SqlFilter', - 'SqlRuleAction', - 'Subnet', - 'SystemData', - 'TrackedResource', - 'UserAssignedIdentityProperties', - 'AccessRights', - 'CreatedByType', - 'DefaultAction', - 'EndPointProvisioningState', - 'EntityStatus', - 'FilterType', - 'KeyType', - 'ManagedServiceIdentityType', - 'MigrationConfigurationName', - 'NetworkRuleIPAction', - 'PrivateLinkConnectionStatus', - 'ProvisioningStateDR', - 'RoleDisasterRecovery', - 'SkuName', - 'SkuTier', - 'UnavailableReason', + "AccessKeys", + "Action", + "ArmDisasterRecovery", + "ArmDisasterRecoveryListResult", + "CheckNameAvailability", + "CheckNameAvailabilityResult", + "ConnectionState", + "CorrelationFilter", + "DictionaryValue", + "Encryption", + "ErrorAdditionalInfo", + "ErrorResponse", + "ErrorResponseError", + "FailoverProperties", + "Identity", + "KeyVaultProperties", + "MessageCountDetails", + "MigrationConfigListResult", + "MigrationConfigProperties", + "NWRuleSetIpRules", + "NWRuleSetVirtualNetworkRules", + "NetworkRuleSet", + "NetworkRuleSetListResult", + "Operation", + "OperationDisplay", + "OperationListResult", + "PrivateEndpoint", + "PrivateEndpointConnection", + "PrivateEndpointConnectionListResult", + "PrivateLinkResource", + "PrivateLinkResourcesListResult", + "RegenerateAccessKeyParameters", + "Resource", + "ResourceNamespacePatch", + "Rule", + "RuleListResult", + "SBAuthorizationRule", + "SBAuthorizationRuleListResult", + "SBNamespace", + "SBNamespaceListResult", + "SBNamespaceUpdateParameters", + "SBQueue", + "SBQueueListResult", + "SBSku", + "SBSubscription", + "SBSubscriptionListResult", + "SBTopic", + "SBTopicListResult", + "SqlFilter", + "SqlRuleAction", + "Subnet", + "SystemData", + "TrackedResource", + "UserAssignedIdentityProperties", + "AccessRights", + "CreatedByType", + "DefaultAction", + "EndPointProvisioningState", + "EntityStatus", + "FilterType", + "KeyType", + "ManagedServiceIdentityType", + "MigrationConfigurationName", + "NetworkRuleIPAction", + "PrivateLinkConnectionStatus", + "ProvisioningStateDR", + "RoleDisasterRecovery", + "SkuName", + "SkuTier", + "UnavailableReason", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() 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 0a048bd15c49..9ae37cfeac7d 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 @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -9,15 +10,14 @@ import datetime from typing import Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - import __init__ as _models + from .. import models as _models -class AccessKeys(msrest.serialization.Model): +class AccessKeys(_serialization.Model): """Namespace/ServiceBus Connection String. Variables are only populated by the server, and will be ignored when sending a request. @@ -45,32 +45,28 @@ class AccessKeys(msrest.serialization.Model): """ _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}, + "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) + "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().__init__(**kwargs) self.primary_connection_string = None self.secondary_connection_string = None self.alias_primary_connection_string = None @@ -80,7 +76,7 @@ def __init__( self.key_name = None -class Action(msrest.serialization.Model): +class Action(_serialization.Model): """Represents the filter actions which are allowed for the transformation of a message that have been matched by a filter expression. :ivar sql_expression: SQL expression. e.g. MyProperty='ABC'. @@ -94,9 +90,9 @@ class Action(msrest.serialization.Model): """ _attribute_map = { - 'sql_expression': {'key': 'sqlExpression', 'type': 'str'}, - 'compatibility_level': {'key': 'compatibilityLevel', 'type': 'int'}, - 'requires_preprocessing': {'key': 'requiresPreprocessing', 'type': 'bool'}, + "sql_expression": {"key": "sqlExpression", "type": "str"}, + "compatibility_level": {"key": "compatibilityLevel", "type": "int"}, + "requires_preprocessing": {"key": "requiresPreprocessing", "type": "bool"}, } def __init__( @@ -104,7 +100,7 @@ def __init__( *, sql_expression: Optional[str] = None, compatibility_level: Optional[int] = None, - requires_preprocessing: Optional[bool] = True, + requires_preprocessing: bool = True, **kwargs ): """ @@ -117,13 +113,13 @@ def __init__( preprocessing. :paramtype requires_preprocessing: bool """ - super(Action, self).__init__(**kwargs) + super().__init__(**kwargs) self.sql_expression = sql_expression self.compatibility_level = compatibility_level self.requires_preprocessing = requires_preprocessing -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """The Resource definition for other than namespace. Variables are only populated by the server, and will be ignored when sending a request. @@ -137,24 +133,20 @@ class Resource(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "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'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Resource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -175,11 +167,11 @@ class ArmDisasterRecovery(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'. Known values are: "Accepted", - "Succeeded", "Failed". + "Succeeded", and "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 + :vartype pending_replication_operations_count: int :ivar partner_namespace: ARM Id of the Primary/Secondary eventhub namespace name, which is part of GEO DR pairing. :vartype partner_namespace: str @@ -187,39 +179,33 @@ class ArmDisasterRecovery(Resource): pairing. :vartype alternate_name: str :ivar role: role of namespace in GEO DR - possible values 'Primary' or 'PrimaryNotReplicating' - or 'Secondary'. Known values are: "Primary", "PrimaryNotReplicating", "Secondary". + or 'Secondary'. Known values are: "Primary", "PrimaryNotReplicating", and "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}, + "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'}, + "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": "int"}, + "partner_namespace": {"key": "properties.partnerNamespace", "type": "str"}, + "alternate_name": {"key": "properties.alternateName", "type": "str"}, + "role": {"key": "properties.role", "type": "str"}, } - def __init__( - self, - *, - partner_namespace: Optional[str] = None, - alternate_name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, partner_namespace: Optional[str] = None, 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. @@ -228,7 +214,7 @@ def __init__( pairing. :paramtype alternate_name: str """ - super(ArmDisasterRecovery, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.provisioning_state = None self.pending_replication_operations_count = None @@ -237,7 +223,7 @@ def __init__( self.role = None -class ArmDisasterRecoveryListResult(msrest.serialization.Model): +class ArmDisasterRecoveryListResult(_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. @@ -250,65 +236,55 @@ class ArmDisasterRecoveryListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ArmDisasterRecovery]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ArmDisasterRecovery]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.ArmDisasterRecovery"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.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) + super().__init__(**kwargs) self.value = value self.next_link = None -class CheckNameAvailability(msrest.serialization.Model): +class CheckNameAvailability(_serialization.Model): """Description of a Check Name availability request properties. All required parameters must be populated in order to send to Azure. - :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. + :ivar name: 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. Required. :vartype name: str """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - name: str, - **kwargs - ): + def __init__(self, *, 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. + :keyword name: 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. Required. :paramtype name: str """ - super(CheckNameAvailability, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class CheckNameAvailabilityResult(msrest.serialization.Model): +class CheckNameAvailabilityResult(_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. @@ -319,19 +295,19 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): available; otherwise, false. :vartype name_available: bool :ivar reason: The reason for unavailability of a namespace. Known values are: "None", - "InvalidName", "SubscriptionIsDisabled", "NameInUse", "NameInLockdown", + "InvalidName", "SubscriptionIsDisabled", "NameInUse", "NameInLockdown", and "TooManyNamespaceInCurrentSubscription". :vartype reason: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.UnavailableReason """ _validation = { - 'message': {'readonly': True}, + "message": {"readonly": True}, } _attribute_map = { - 'message': {'key': 'message', 'type': 'str'}, - 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, - 'reason': {'key': 'reason', 'type': 'str'}, + "message": {"key": "message", "type": "str"}, + "name_available": {"key": "nameAvailable", "type": "bool"}, + "reason": {"key": "reason", "type": "str"}, } def __init__( @@ -346,21 +322,21 @@ def __init__( available; otherwise, false. :paramtype name_available: bool :keyword reason: The reason for unavailability of a namespace. Known values are: "None", - "InvalidName", "SubscriptionIsDisabled", "NameInUse", "NameInLockdown", + "InvalidName", "SubscriptionIsDisabled", "NameInUse", "NameInLockdown", and "TooManyNamespaceInCurrentSubscription". :paramtype reason: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.UnavailableReason """ - super(CheckNameAvailabilityResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.message = None self.name_available = name_available self.reason = reason -class ConnectionState(msrest.serialization.Model): +class ConnectionState(_serialization.Model): """ConnectionState information. :ivar status: Status of the connection. Known values are: "Pending", "Approved", "Rejected", - "Disconnected". + and "Disconnected". :vartype status: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.PrivateLinkConnectionStatus :ivar description: Description of the connection state. @@ -368,8 +344,8 @@ class ConnectionState(msrest.serialization.Model): """ _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "status": {"key": "status", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -381,18 +357,18 @@ def __init__( ): """ :keyword status: Status of the connection. Known values are: "Pending", "Approved", "Rejected", - "Disconnected". + and "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) + super().__init__(**kwargs) self.status = status self.description = description -class CorrelationFilter(msrest.serialization.Model): +class CorrelationFilter(_serialization.Model): """Represents the correlation filter expression. :ivar properties: dictionary object for custom filters. @@ -419,16 +395,16 @@ class CorrelationFilter(msrest.serialization.Model): """ _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'}, + "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__( @@ -443,7 +419,7 @@ def __init__( session_id: Optional[str] = None, reply_to_session_id: Optional[str] = None, content_type: Optional[str] = None, - requires_preprocessing: Optional[bool] = True, + requires_preprocessing: bool = True, **kwargs ): """ @@ -469,7 +445,7 @@ def __init__( preprocessing. :paramtype requires_preprocessing: bool """ - super(CorrelationFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.correlation_id = correlation_id self.message_id = message_id @@ -482,7 +458,7 @@ def __init__( self.requires_preprocessing = requires_preprocessing -class DictionaryValue(msrest.serialization.Model): +class DictionaryValue(_serialization.Model): """Recognized Dictionary value. Variables are only populated by the server, and will be ignored when sending a request. @@ -494,34 +470,29 @@ class DictionaryValue(msrest.serialization.Model): """ _validation = { - 'principal_id': {'readonly': True}, - 'client_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "client_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'client_id': {'key': 'clientId', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "client_id": {"key": "clientId", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(DictionaryValue, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.principal_id = None self.client_id = None -class Encryption(msrest.serialization.Model): +class Encryption(_serialization.Model): """Properties to configure Encryption. :ivar key_vault_properties: Properties of KeyVault. :vartype key_vault_properties: list[~azure.mgmt.servicebus.v2021_01_01_preview.models.KeyVaultProperties] - :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 + :ivar key_source: Enumerates the possible value of keySource for Encryption. Default value is "Microsoft.KeyVault". :vartype key_source: str :ivar require_infrastructure_encryption: Enable Infrastructure Encryption (Double Encryption). @@ -529,16 +500,16 @@ class Encryption(msrest.serialization.Model): """ _attribute_map = { - 'key_vault_properties': {'key': 'keyVaultProperties', 'type': '[KeyVaultProperties]'}, - 'key_source': {'key': 'keySource', 'type': 'str'}, - 'require_infrastructure_encryption': {'key': 'requireInfrastructureEncryption', 'type': 'bool'}, + "key_vault_properties": {"key": "keyVaultProperties", "type": "[KeyVaultProperties]"}, + "key_source": {"key": "keySource", "type": "str"}, + "require_infrastructure_encryption": {"key": "requireInfrastructureEncryption", "type": "bool"}, } def __init__( self, *, key_vault_properties: Optional[List["_models.KeyVaultProperties"]] = None, - key_source: Optional[str] = "Microsoft.KeyVault", + key_source: str = "Microsoft.KeyVault", require_infrastructure_encryption: Optional[bool] = None, **kwargs ): @@ -546,21 +517,20 @@ def __init__( :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". + :keyword key_source: Enumerates the possible value of keySource for Encryption. 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) + super().__init__(**kwargs) self.key_vault_properties = key_vault_properties self.key_source = key_source self.require_infrastructure_encryption = require_infrastructure_encryption -class ErrorAdditionalInfo(msrest.serialization.Model): +class ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. Variables are only populated by the server, and will be ignored when sending a request. @@ -568,31 +538,27 @@ class ErrorAdditionalInfo(msrest.serialization.Model): :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. - :vartype info: any + :vartype info: JSON """ _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, + "type": {"readonly": True}, + "info": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorAdditionalInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.info = None -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """The resource management error response. :ivar error: The error object. @@ -600,24 +566,19 @@ class ErrorResponse(msrest.serialization.Model): """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponseError'}, + "error": {"key": "error", "type": "ErrorResponseError"}, } - def __init__( - self, - *, - error: Optional["_models.ErrorResponseError"] = None, - **kwargs - ): + def __init__(self, *, error: Optional["_models.ErrorResponseError"] = None, **kwargs): """ :keyword error: The error object. :paramtype error: ~azure.mgmt.servicebus.v2021_01_01_preview.models.ErrorResponseError """ - super(ErrorResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error -class ErrorResponseError(msrest.serialization.Model): +class ErrorResponseError(_serialization.Model): """The error object. Variables are only populated by the server, and will be ignored when sending a request. @@ -636,28 +597,24 @@ class ErrorResponseError(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, + "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]'}, + "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) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.message = None self.target = None @@ -665,7 +622,7 @@ def __init__( self.additional_info = None -class FailoverProperties(msrest.serialization.Model): +class FailoverProperties(_serialization.Model): """Safe failover is to indicate the service should wait for pending replication to finish before switching to the secondary. :ivar is_safe_failover: Safe failover is to indicate the service should wait for pending @@ -674,25 +631,20 @@ class FailoverProperties(msrest.serialization.Model): """ _attribute_map = { - 'is_safe_failover': {'key': 'properties.IsSafeFailover', 'type': 'bool'}, + "is_safe_failover": {"key": "properties.IsSafeFailover", "type": "bool"}, } - def __init__( - self, - *, - is_safe_failover: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, 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) + super().__init__(**kwargs) self.is_safe_failover = is_safe_failover -class Identity(msrest.serialization.Model): +class Identity(_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. @@ -702,7 +654,7 @@ class Identity(msrest.serialization.Model): :ivar tenant_id: TenantId from the KeyVault. :vartype tenant_id: str :ivar type: Type of managed service identity. Known values are: "SystemAssigned", - "UserAssigned", "SystemAssigned, UserAssigned", "None". + "UserAssigned", "SystemAssigned, UserAssigned", and "None". :vartype type: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.ManagedServiceIdentityType :ivar user_assigned_identities: Properties for User Assigned Identities. @@ -711,15 +663,15 @@ class Identity(msrest.serialization.Model): """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, + "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}'}, + "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__( @@ -731,21 +683,21 @@ def __init__( ): """ :keyword type: Type of managed service identity. Known values are: "SystemAssigned", - "UserAssigned", "SystemAssigned, UserAssigned", "None". + "UserAssigned", "SystemAssigned, UserAssigned", and "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) + super().__init__(**kwargs) self.principal_id = None self.tenant_id = None self.type = type self.user_assigned_identities = user_assigned_identities -class KeyVaultProperties(msrest.serialization.Model): +class KeyVaultProperties(_serialization.Model): """Properties to configure keyVault Properties. :ivar key_name: Name of the Key from KeyVault. @@ -760,10 +712,10 @@ class KeyVaultProperties(msrest.serialization.Model): """ _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'}, + "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__( @@ -786,54 +738,50 @@ def __init__( :paramtype identity: ~azure.mgmt.servicebus.v2021_01_01_preview.models.UserAssignedIdentityProperties """ - super(KeyVaultProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_name = key_name self.key_vault_uri = key_vault_uri self.key_version = key_version self.identity = identity -class MessageCountDetails(msrest.serialization.Model): +class MessageCountDetails(_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 + :vartype active_message_count: int :ivar dead_letter_message_count: Number of messages that are dead lettered. - :vartype dead_letter_message_count: long + :vartype dead_letter_message_count: int :ivar scheduled_message_count: Number of scheduled messages. - :vartype scheduled_message_count: long + :vartype scheduled_message_count: int :ivar transfer_message_count: Number of messages transferred to another queue, topic, or subscription. - :vartype transfer_message_count: long + :vartype transfer_message_count: int :ivar transfer_dead_letter_message_count: Number of messages transferred into dead letters. - :vartype transfer_dead_letter_message_count: long + :vartype transfer_dead_letter_message_count: int """ _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}, + "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'}, + "active_message_count": {"key": "activeMessageCount", "type": "int"}, + "dead_letter_message_count": {"key": "deadLetterMessageCount", "type": "int"}, + "scheduled_message_count": {"key": "scheduledMessageCount", "type": "int"}, + "transfer_message_count": {"key": "transferMessageCount", "type": "int"}, + "transfer_dead_letter_message_count": {"key": "transferDeadLetterMessageCount", "type": "int"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(MessageCountDetails, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.active_message_count = None self.dead_letter_message_count = None self.scheduled_message_count = None @@ -841,7 +789,7 @@ def __init__( self.transfer_dead_letter_message_count = None -class MigrationConfigListResult(msrest.serialization.Model): +class MigrationConfigListResult(_serialization.Model): """The result of the List migrationConfigurations operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -855,26 +803,21 @@ class MigrationConfigListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[MigrationConfigProperties]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[MigrationConfigProperties]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.MigrationConfigProperties"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.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) + super().__init__(**kwargs) self.value = value self.next_link = None @@ -895,7 +838,7 @@ class MigrationConfigProperties(Resource): :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 + :vartype pending_replication_operations_count: int :ivar target_namespace: Existing premium Namespace ARM Id name which has no entities, will be used for migration. :vartype target_namespace: str @@ -907,34 +850,28 @@ class MigrationConfigProperties(Resource): """ _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}, + "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'}, + "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": "int"}, + "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, - *, - target_namespace: Optional[str] = None, - post_migration_name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, target_namespace: Optional[str] = None, 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. @@ -942,7 +879,7 @@ def __init__( :keyword post_migration_name: Name to access Standard Namespace after migration. :paramtype post_migration_name: str """ - super(MigrationConfigProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.provisioning_state = None self.pending_replication_operations_count = None @@ -964,7 +901,8 @@ 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 - :ivar default_action: Default Action for Network Rule Set. Known values are: "Allow", "Deny". + :ivar default_action: Default Action for Network Rule Set. Known values are: "Allow" and + "Deny". :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: @@ -974,20 +912,20 @@ class NetworkRuleSet(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, + "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]'}, + "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__( @@ -999,7 +937,7 @@ def __init__( **kwargs ): """ - :keyword default_action: Default Action for Network Rule Set. Known values are: "Allow", + :keyword default_action: Default Action for Network Rule Set. Known values are: "Allow" and "Deny". :paramtype default_action: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.DefaultAction @@ -1009,14 +947,14 @@ def __init__( :keyword ip_rules: List of IpRules. :paramtype ip_rules: list[~azure.mgmt.servicebus.v2021_01_01_preview.models.NWRuleSetIpRules] """ - super(NetworkRuleSet, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.default_action = default_action self.virtual_network_rules = virtual_network_rules self.ip_rules = ip_rules -class NetworkRuleSetListResult(msrest.serialization.Model): +class NetworkRuleSetListResult(_serialization.Model): """The response of the List NetworkRuleSet operation. :ivar value: Result of the List NetworkRuleSet operation. @@ -1027,16 +965,12 @@ class NetworkRuleSetListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[NetworkRuleSet]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[NetworkRuleSet]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.NetworkRuleSet"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.NetworkRuleSet"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Result of the List NetworkRuleSet operation. @@ -1045,44 +979,40 @@ def __init__( list of NetworkRuleSet. :paramtype next_link: str """ - super(NetworkRuleSetListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class NWRuleSetIpRules(msrest.serialization.Model): +class NWRuleSetIpRules(_serialization.Model): """Description of NetWorkRuleSet - IpRules resource. :ivar ip_mask: IP Mask. :vartype ip_mask: str - :ivar action: The IP Filter Action. Known values are: "Allow". Default value: "Allow". + :ivar action: The IP Filter Action. "Allow" :vartype 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'}, + "ip_mask": {"key": "ipMask", "type": "str"}, + "action": {"key": "action", "type": "str"}, } def __init__( - self, - *, - ip_mask: Optional[str] = None, - action: Optional[Union[str, "_models.NetworkRuleIPAction"]] = "Allow", - **kwargs + self, *, ip_mask: Optional[str] = None, action: Union[str, "_models.NetworkRuleIPAction"] = "Allow", **kwargs ): """ :keyword ip_mask: IP Mask. :paramtype ip_mask: str - :keyword action: The IP Filter Action. Known values are: "Allow". Default value: "Allow". + :keyword action: The IP Filter Action. "Allow" :paramtype action: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.NetworkRuleIPAction """ - super(NWRuleSetIpRules, self).__init__(**kwargs) + super().__init__(**kwargs) self.ip_mask = ip_mask self.action = action -class NWRuleSetVirtualNetworkRules(msrest.serialization.Model): +class NWRuleSetVirtualNetworkRules(_serialization.Model): """Description of VirtualNetworkRules - NetworkRules resource. :ivar subnet: Subnet properties. @@ -1093,8 +1023,8 @@ class NWRuleSetVirtualNetworkRules(msrest.serialization.Model): """ _attribute_map = { - 'subnet': {'key': 'subnet', 'type': 'Subnet'}, - 'ignore_missing_vnet_service_endpoint': {'key': 'ignoreMissingVnetServiceEndpoint', 'type': 'bool'}, + "subnet": {"key": "subnet", "type": "Subnet"}, + "ignore_missing_vnet_service_endpoint": {"key": "ignoreMissingVnetServiceEndpoint", "type": "bool"}, } def __init__( @@ -1111,12 +1041,12 @@ def __init__( VNet Service Endpoint. :paramtype ignore_missing_vnet_service_endpoint: bool """ - super(NWRuleSetVirtualNetworkRules, self).__init__(**kwargs) + super().__init__(**kwargs) self.subnet = subnet self.ignore_missing_vnet_service_endpoint = ignore_missing_vnet_service_endpoint -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """A ServiceBus REST API operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -1128,30 +1058,25 @@ class Operation(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, + "name": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, } - def __init__( - self, - *, - display: Optional["_models.OperationDisplay"] = None, - **kwargs - ): + def __init__(self, *, display: Optional["_models.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) + super().__init__(**kwargs) self.name = None self.display = display -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """The object that represents the operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -1165,30 +1090,26 @@ class OperationDisplay(msrest.serialization.Model): """ _validation = { - 'provider': {'readonly': True}, - 'resource': {'readonly': True}, - 'operation': {'readonly': True}, + "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'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(OperationDisplay, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.provider = None self.resource = None self.operation = None -class OperationListResult(msrest.serialization.Model): +class OperationListResult(_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. @@ -1201,27 +1122,23 @@ class OperationListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(OperationListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class PrivateEndpoint(msrest.serialization.Model): +class PrivateEndpoint(_serialization.Model): """PrivateEndpoint information. :ivar id: The ARM identifier for Private Endpoint. @@ -1229,20 +1146,15 @@ class PrivateEndpoint(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, id: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin """ :keyword id: The ARM identifier for Private Endpoint. :paramtype id: str """ - super(PrivateEndpoint, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id @@ -1265,26 +1177,29 @@ class PrivateEndpointConnection(Resource): :vartype private_link_service_connection_state: ~azure.mgmt.servicebus.v2021_01_01_preview.models.ConnectionState :ivar provisioning_state: Provisioning state of the Private Endpoint Connection. Known values - are: "Creating", "Updating", "Deleting", "Succeeded", "Canceled", "Failed". + are: "Creating", "Updating", "Deleting", "Succeeded", "Canceled", and "Failed". :vartype 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}, + "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'}, + "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__( @@ -1302,18 +1217,18 @@ def __init__( :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. Known - values are: "Creating", "Updating", "Deleting", "Succeeded", "Canceled", "Failed". + values are: "Creating", "Updating", "Deleting", "Succeeded", "Canceled", and "Failed". :paramtype provisioning_state: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.EndPointProvisioningState """ - super(PrivateEndpointConnection, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.private_endpoint = private_endpoint self.private_link_service_connection_state = private_link_service_connection_state self.provisioning_state = provisioning_state -class PrivateEndpointConnectionListResult(msrest.serialization.Model): +class PrivateEndpointConnectionListResult(_serialization.Model): """Result of the list of all private endpoint connections operation. :ivar value: A collection of private endpoint connection resources. @@ -1324,8 +1239,8 @@ class PrivateEndpointConnectionListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateEndpointConnection]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PrivateEndpointConnection]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( @@ -1342,12 +1257,12 @@ def __init__( :keyword next_link: A link for the next page of private endpoint connection resources. :paramtype next_link: str """ - super(PrivateEndpointConnectionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class PrivateLinkResource(msrest.serialization.Model): +class PrivateLinkResource(_serialization.Model): """Information of the private link resource. :ivar id: Fully qualified identifier of the resource. @@ -1365,18 +1280,18 @@ class PrivateLinkResource(msrest.serialization.Model): """ _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]'}, + "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, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin name: Optional[str] = None, type: Optional[str] = None, group_id: Optional[str] = None, @@ -1398,7 +1313,7 @@ def __init__( :keyword required_zone_names: Required Zone Names. :paramtype required_zone_names: list[str] """ - super(PrivateLinkResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.name = name self.type = type @@ -1407,7 +1322,7 @@ def __init__( self.required_zone_names = required_zone_names -class PrivateLinkResourcesListResult(msrest.serialization.Model): +class PrivateLinkResourcesListResult(_serialization.Model): """Result of the List private link resources operation. :ivar value: A collection of private link resources. @@ -1417,16 +1332,12 @@ class PrivateLinkResourcesListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateLinkResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PrivateLinkResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.PrivateLinkResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.PrivateLinkResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: A collection of private link resources. @@ -1434,17 +1345,17 @@ def __init__( :keyword next_link: A link for the next page of private link resources. :paramtype next_link: str """ - super(PrivateLinkResourcesListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class RegenerateAccessKeyParameters(msrest.serialization.Model): +class RegenerateAccessKeyParameters(_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. - :ivar key_type: Required. The access key to regenerate. Known values are: "PrimaryKey", + :ivar key_type: The access key to regenerate. Required. Known values are: "PrimaryKey" and "SecondaryKey". :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 @@ -1453,30 +1364,24 @@ class RegenerateAccessKeyParameters(msrest.serialization.Model): """ _validation = { - 'key_type': {'required': True}, + "key_type": {"required": True}, } _attribute_map = { - 'key_type': {'key': 'keyType', 'type': 'str'}, - 'key': {'key': 'key', 'type': 'str'}, + "key_type": {"key": "keyType", "type": "str"}, + "key": {"key": "key", "type": "str"}, } - def __init__( - self, - *, - key_type: Union[str, "_models.KeyType"], - key: Optional[str] = None, - **kwargs - ): + def __init__(self, *, key_type: Union[str, "_models.KeyType"], key: Optional[str] = None, **kwargs): """ - :keyword key_type: Required. The access key to regenerate. Known values are: "PrimaryKey", + :keyword key_type: The access key to regenerate. Required. Known values are: "PrimaryKey" and "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) + super().__init__(**kwargs) self.key_type = key_type self.key = key @@ -1494,38 +1399,32 @@ class ResourceNamespacePatch(Resource): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "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}'}, + "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, - *, - location: Optional[str] = None, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs): """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(ResourceNamespacePatch, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.tags = tags @@ -1547,7 +1446,7 @@ class Rule(Resource): message that have been matched by a filter expression. :vartype action: ~azure.mgmt.servicebus.v2021_01_01_preview.models.Action :ivar filter_type: Filter type that is evaluated against a BrokeredMessage. Known values are: - "SqlFilter", "CorrelationFilter". + "SqlFilter" and "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 @@ -1557,21 +1456,21 @@ class Rule(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, + "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'}, + "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__( @@ -1588,7 +1487,7 @@ def __init__( 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. Known values - are: "SqlFilter", "CorrelationFilter". + are: "SqlFilter" and "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 @@ -1596,7 +1495,7 @@ def __init__( :paramtype correlation_filter: ~azure.mgmt.servicebus.v2021_01_01_preview.models.CorrelationFilter """ - super(Rule, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.action = action self.filter_type = filter_type @@ -1604,7 +1503,7 @@ def __init__( self.correlation_filter = correlation_filter -class RuleListResult(msrest.serialization.Model): +class RuleListResult(_serialization.Model): """The response of the List rule operation. :ivar value: Result of the List Rules operation. @@ -1615,17 +1514,11 @@ class RuleListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Rule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Rule]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.Rule"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Rule"]] = None, 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] @@ -1633,7 +1526,7 @@ def __init__( list of rules. :paramtype next_link: str """ - super(RuleListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link @@ -1656,36 +1549,31 @@ class SBAuthorizationRule(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, + "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]'}, + "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, - *, - rights: Optional[List[Union[str, "_models.AccessRights"]]] = None, - **kwargs - ): + def __init__(self, *, rights: Optional[List[Union[str, "_models.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) + super().__init__(**kwargs) self.system_data = None self.rights = rights -class SBAuthorizationRuleListResult(msrest.serialization.Model): +class SBAuthorizationRuleListResult(_serialization.Model): """The response to the List Namespace operation. :ivar value: Result of the List Authorization Rules operation. @@ -1696,16 +1584,12 @@ class SBAuthorizationRuleListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SBAuthorizationRule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SBAuthorizationRule]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.SBAuthorizationRule"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.SBAuthorizationRule"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Result of the List Authorization Rules operation. @@ -1714,7 +1598,7 @@ def __init__( list of Authorization Rules. :paramtype next_link: str """ - super(SBAuthorizationRuleListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link @@ -1732,46 +1616,40 @@ class TrackedResource(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :ivar location: Required. The Geo-location where the resource lives. + :ivar location: The Geo-location where the resource lives. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "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}'}, + "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, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword location: Required. The Geo-location where the resource lives. + :keyword location: The Geo-location where the resource lives. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(TrackedResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.tags = tags -class SBNamespace(TrackedResource): +class SBNamespace(TrackedResource): # pylint: disable=too-many-instance-attributes """Description of a namespace resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -1784,9 +1662,9 @@ class SBNamespace(TrackedResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :ivar location: Required. The Geo-location where the resource lives. + :ivar location: The Geo-location where the resource lives. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar sku: Properties of SKU. :vartype sku: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBSku @@ -1817,37 +1695,40 @@ class SBNamespace(TrackedResource): """ _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}, + "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]'}, + "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__( @@ -1863,9 +1744,9 @@ def __init__( **kwargs ): """ - :keyword location: Required. The Geo-location where the resource lives. + :keyword location: The Geo-location where the resource lives. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword sku: Properties of SKU. :paramtype sku: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBSku @@ -1880,7 +1761,7 @@ def __init__( :paramtype private_endpoint_connections: list[~azure.mgmt.servicebus.v2021_01_01_preview.models.PrivateEndpointConnection] """ - super(SBNamespace, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.sku = sku self.identity = identity self.system_data = None @@ -1895,7 +1776,7 @@ def __init__( self.private_endpoint_connections = private_endpoint_connections -class SBNamespaceListResult(msrest.serialization.Model): +class SBNamespaceListResult(_serialization.Model): """The response of the List Namespace operation. :ivar value: Result of the List Namespace operation. @@ -1906,16 +1787,12 @@ class SBNamespaceListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SBNamespace]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SBNamespace]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.SBNamespace"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.SBNamespace"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Result of the List Namespace operation. @@ -1924,12 +1801,12 @@ def __init__( list of Namespaces. :paramtype next_link: str """ - super(SBNamespaceListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SBNamespaceUpdateParameters(ResourceNamespacePatch): +class SBNamespaceUpdateParameters(ResourceNamespacePatch): # pylint: disable=too-many-instance-attributes """Description of a namespace resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -1942,7 +1819,7 @@ class SBNamespaceUpdateParameters(ResourceNamespacePatch): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar sku: Properties of SKU. :vartype sku: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBSku @@ -1971,34 +1848,37 @@ class SBNamespaceUpdateParameters(ResourceNamespacePatch): """ _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}, + "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]'}, + "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__( @@ -2016,7 +1896,7 @@ def __init__( """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword sku: Properties of SKU. :paramtype sku: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBSku @@ -2031,7 +1911,7 @@ def __init__( :paramtype private_endpoint_connections: list[~azure.mgmt.servicebus.v2021_01_01_preview.models.PrivateEndpointConnection] """ - super(SBNamespaceUpdateParameters, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.sku = sku self.identity = identity self.provisioning_state = None @@ -2045,7 +1925,7 @@ def __init__( self.private_endpoint_connections = private_endpoint_connections -class SBQueue(Resource): +class SBQueue(Resource): # pylint: disable=too-many-instance-attributes """Description of queue Resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2068,9 +1948,9 @@ class SBQueue(Resource): to this queue. :vartype accessed_at: ~datetime.datetime :ivar size_in_bytes: The size of the queue, in bytes. - :vartype size_in_bytes: long + :vartype size_in_bytes: int :ivar message_count: The number of messages in the queue. - :vartype message_count: long + :vartype message_count: int :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. @@ -2099,7 +1979,7 @@ class SBQueue(Resource): :vartype max_delivery_count: int :ivar status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". + "Deleting", "Renaming", and "Unknown". :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. @@ -2120,47 +2000,50 @@ class SBQueue(Resource): """ _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}, + "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__( + "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": "int"}, + "message_count": {"key": "properties.messageCount", "type": "int"}, + "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__( # pylint: disable=too-many-locals self, *, lock_duration: Optional[datetime.timedelta] = None, @@ -2209,7 +2092,7 @@ def __init__( :paramtype max_delivery_count: int :keyword status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". + "Deleting", "Renaming", and "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. @@ -2229,7 +2112,7 @@ def __init__( message. :paramtype forward_dead_lettered_messages_to: str """ - super(SBQueue, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.count_details = None self.created_at = None @@ -2254,7 +2137,7 @@ def __init__( self.forward_dead_lettered_messages_to = forward_dead_lettered_messages_to -class SBQueueListResult(msrest.serialization.Model): +class SBQueueListResult(_serialization.Model): """The response to the List Queues operation. :ivar value: Result of the List Queues operation. @@ -2265,17 +2148,11 @@ class SBQueueListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SBQueue]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SBQueue]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.SBQueue"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.SBQueue"]] = None, 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] @@ -2283,19 +2160,19 @@ def __init__( list of queues. :paramtype next_link: str """ - super(SBQueueListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SBSku(msrest.serialization.Model): +class SBSku(_serialization.Model): """SKU of the namespace. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Name of this SKU. Known values are: "Basic", "Standard", "Premium". + :ivar name: Name of this SKU. Required. Known values are: "Basic", "Standard", and "Premium". :vartype name: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.SkuName - :ivar tier: The billing tier of this particular SKU. Known values are: "Basic", "Standard", + :ivar tier: The billing tier of this particular SKU. Known values are: "Basic", "Standard", and "Premium". :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 @@ -2304,13 +2181,13 @@ class SBSku(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'int'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "capacity": {"key": "capacity", "type": "int"}, } def __init__( @@ -2322,22 +2199,23 @@ def __init__( **kwargs ): """ - :keyword name: Required. Name of this SKU. Known values are: "Basic", "Standard", "Premium". + :keyword name: Name of this SKU. Required. Known values are: "Basic", "Standard", and + "Premium". :paramtype name: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.SkuName :keyword tier: The billing tier of this particular SKU. Known values are: "Basic", "Standard", - "Premium". + and "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) + super().__init__(**kwargs) self.name = name self.tier = tier self.capacity = capacity -class SBSubscription(Resource): +class SBSubscription(Resource): # pylint: disable=too-many-instance-attributes """Description of subscription resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2351,7 +2229,7 @@ class SBSubscription(Resource): :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 + :vartype message_count: int :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. @@ -2382,7 +2260,7 @@ class SBSubscription(Resource): :vartype max_delivery_count: int :ivar status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". + "Deleting", "Renaming", and "Unknown". :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. @@ -2397,39 +2275,45 @@ class SBSubscription(Resource): """ _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}, + "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'}, + "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": "int"}, + "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__( @@ -2472,7 +2356,7 @@ def __init__( :paramtype max_delivery_count: int :keyword status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". + "Deleting", "Renaming", and "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. @@ -2486,7 +2370,7 @@ def __init__( message. :paramtype forward_dead_lettered_messages_to: str """ - super(SBSubscription, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.message_count = None self.created_at = None @@ -2507,7 +2391,7 @@ def __init__( self.forward_dead_lettered_messages_to = forward_dead_lettered_messages_to -class SBSubscriptionListResult(msrest.serialization.Model): +class SBSubscriptionListResult(_serialization.Model): """The response to the List Subscriptions operation. :ivar value: Result of the List Subscriptions operation. @@ -2518,16 +2402,12 @@ class SBSubscriptionListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SBSubscription]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SBSubscription]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.SBSubscription"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.SBSubscription"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Result of the List Subscriptions operation. @@ -2536,12 +2416,12 @@ def __init__( list of subscriptions. :paramtype next_link: str """ - super(SBSubscriptionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SBTopic(Resource): +class SBTopic(Resource): # pylint: disable=too-many-instance-attributes """Description of topic resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2555,7 +2435,7 @@ class SBTopic(Resource): :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 + :vartype size_in_bytes: int :ivar created_at: Exact time the message was created. :vartype created_at: ~datetime.datetime :ivar updated_at: The exact time the message was updated. @@ -2584,7 +2464,7 @@ class SBTopic(Resource): :vartype enable_batched_operations: bool :ivar status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". + "Deleting", "Renaming", and "Unknown". :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 @@ -2600,39 +2480,42 @@ class SBTopic(Resource): """ _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}, + "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'}, + "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": "int"}, + "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__( @@ -2669,7 +2552,7 @@ def __init__( :paramtype enable_batched_operations: bool :keyword status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". + "Deleting", "Renaming", and "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 @@ -2683,7 +2566,7 @@ def __init__( topic holds a message in memory temporarily before writing it to persistent storage. :paramtype enable_express: bool """ - super(SBTopic, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.size_in_bytes = None self.created_at = None @@ -2703,7 +2586,7 @@ def __init__( self.enable_express = enable_express -class SBTopicListResult(msrest.serialization.Model): +class SBTopicListResult(_serialization.Model): """The response to the List Topics operation. :ivar value: Result of the List Topics operation. @@ -2714,17 +2597,11 @@ class SBTopicListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SBTopic]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SBTopic]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.SBTopic"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.SBTopic"]] = None, 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] @@ -2732,12 +2609,12 @@ def __init__( list of topics. :paramtype next_link: str """ - super(SBTopicListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SqlFilter(msrest.serialization.Model): +class SqlFilter(_serialization.Model): """Represents a filter which is a composition of an expression and an action that is executed in the pub/sub pipeline. :ivar sql_expression: The SQL expression. e.g. MyProperty='ABC'. @@ -2751,21 +2628,21 @@ class SqlFilter(msrest.serialization.Model): """ _validation = { - 'compatibility_level': {'maximum': 20, 'minimum': 20}, + "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'}, + "sql_expression": {"key": "sqlExpression", "type": "str"}, + "compatibility_level": {"key": "compatibilityLevel", "type": "int"}, + "requires_preprocessing": {"key": "requiresPreprocessing", "type": "bool"}, } def __init__( self, *, sql_expression: Optional[str] = None, - compatibility_level: Optional[int] = 20, - requires_preprocessing: Optional[bool] = True, + compatibility_level: int = 20, + requires_preprocessing: bool = True, **kwargs ): """ @@ -2778,7 +2655,7 @@ def __init__( preprocessing. :paramtype requires_preprocessing: bool """ - super(SqlFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.sql_expression = sql_expression self.compatibility_level = compatibility_level self.requires_preprocessing = requires_preprocessing @@ -2798,9 +2675,9 @@ class SqlRuleAction(Action): """ _attribute_map = { - 'sql_expression': {'key': 'sqlExpression', 'type': 'str'}, - 'compatibility_level': {'key': 'compatibilityLevel', 'type': 'int'}, - 'requires_preprocessing': {'key': 'requiresPreprocessing', 'type': 'bool'}, + "sql_expression": {"key": "sqlExpression", "type": "str"}, + "compatibility_level": {"key": "compatibilityLevel", "type": "int"}, + "requires_preprocessing": {"key": "requiresPreprocessing", "type": "bool"}, } def __init__( @@ -2808,7 +2685,7 @@ def __init__( *, sql_expression: Optional[str] = None, compatibility_level: Optional[int] = None, - requires_preprocessing: Optional[bool] = True, + requires_preprocessing: bool = True, **kwargs ): """ @@ -2821,47 +2698,47 @@ def __init__( preprocessing. :paramtype requires_preprocessing: bool """ - super(SqlRuleAction, self).__init__(sql_expression=sql_expression, compatibility_level=compatibility_level, requires_preprocessing=requires_preprocessing, **kwargs) + super().__init__( + sql_expression=sql_expression, + compatibility_level=compatibility_level, + requires_preprocessing=requires_preprocessing, + **kwargs + ) -class Subnet(msrest.serialization.Model): +class Subnet(_serialization.Model): """Properties supplied for Subnet. All required parameters must be populated in order to send to Azure. - :ivar id: Required. Resource ID of Virtual Network Subnet. + :ivar id: Resource ID of Virtual Network Subnet. Required. :vartype id: str """ _validation = { - 'id': {'required': True}, + "id": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: str, - **kwargs - ): + def __init__(self, *, id: str, **kwargs): # pylint: disable=redefined-builtin """ - :keyword id: Required. Resource ID of Virtual Network Subnet. + :keyword id: Resource ID of Virtual Network Subnet. Required. :paramtype id: str """ - super(Subnet, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id -class SystemData(msrest.serialization.Model): +class SystemData(_serialization.Model): """Metadata pertaining to creation and last modification of the resource. :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. Known values are: - "User", "Application", "ManagedIdentity", "Key". + "User", "Application", "ManagedIdentity", and "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). @@ -2869,7 +2746,7 @@ class SystemData(msrest.serialization.Model): :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. Known values - are: "User", "Application", "ManagedIdentity", "Key". + are: "User", "Application", "ManagedIdentity", and "Key". :vartype last_modified_by_type: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.CreatedByType :ivar last_modified_at: The type of identity that last modified the resource. @@ -2877,12 +2754,12 @@ class SystemData(msrest.serialization.Model): """ _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'}, + "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__( @@ -2900,7 +2777,7 @@ def __init__( :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. Known values are: - "User", "Application", "ManagedIdentity", "Key". + "User", "Application", "ManagedIdentity", and "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). @@ -2908,13 +2785,13 @@ def __init__( :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. Known - values are: "User", "Application", "ManagedIdentity", "Key". + values are: "User", "Application", "ManagedIdentity", and "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) + super().__init__(**kwargs) self.created_by = created_by self.created_by_type = created_by_type self.created_at = created_at @@ -2923,7 +2800,7 @@ def __init__( self.last_modified_at = last_modified_at -class UserAssignedIdentityProperties(msrest.serialization.Model): +class UserAssignedIdentityProperties(_serialization.Model): """UserAssignedIdentityProperties. :ivar user_assigned_identity: ARM ID of user Identity selected for encryption. @@ -2931,18 +2808,13 @@ class UserAssignedIdentityProperties(msrest.serialization.Model): """ _attribute_map = { - 'user_assigned_identity': {'key': 'userAssignedIdentity', 'type': 'str'}, + "user_assigned_identity": {"key": "userAssignedIdentity", "type": "str"}, } - def __init__( - self, - *, - user_assigned_identity: Optional[str] = None, - **kwargs - ): + def __init__(self, *, 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) + super().__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/_patch.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/models/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/models/_patch.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/models/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. 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 6fa98eab2bd7..4eff4b68262a 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 @@ -11,30 +11,31 @@ class AccessRights(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """AccessRights.""" MANAGE = "Manage" SEND = "Send" LISTEN = "Listen" + class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of identity that created the resource. - """ + """The type of identity that created the resource.""" USER = "User" APPLICATION = "Application" MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" + class DefaultAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Default Action for Network Rule Set - """ + """Default Action for Network Rule Set.""" ALLOW = "Allow" DENY = "Deny" + class EndPointProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Provisioning state of the Private Endpoint Connection. - """ + """Provisioning state of the Private Endpoint Connection.""" CREATING = "Creating" UPDATING = "Updating" @@ -43,9 +44,9 @@ class EndPointProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): CANCELED = "Canceled" FAILED = "Failed" + class EntityStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Entity status. - """ + """Entity status.""" ACTIVE = "Active" DISABLED = "Disabled" @@ -57,85 +58,89 @@ class EntityStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): RENAMING = "Renaming" UNKNOWN = "Unknown" + class FilterType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Rule filter types - """ + """Rule filter types.""" SQL_FILTER = "SqlFilter" CORRELATION_FILTER = "CorrelationFilter" + class KeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The access key to regenerate. - """ + """The access key to regenerate.""" PRIMARY_KEY = "PrimaryKey" SECONDARY_KEY = "SecondaryKey" + class ManagedServiceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Type of managed service identity. - """ + """Type of managed service identity.""" SYSTEM_ASSIGNED = "SystemAssigned" USER_ASSIGNED = "UserAssigned" SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" NONE = "None" + class MigrationConfigurationName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """MigrationConfigurationName.""" _DEFAULT = "$default" + class NetworkRuleIPAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The IP Filter Action - """ + """The IP Filter Action.""" ALLOW = "Allow" + class PrivateLinkConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Status of the connection. - """ + """Status of the connection.""" PENDING = "Pending" APPROVED = "Approved" REJECTED = "Rejected" DISCONNECTED = "Disconnected" + class ProvisioningStateDR(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Provisioning state of the Alias(Disaster Recovery configuration) - possible values 'Accepted' - or 'Succeeded' or 'Failed' + or 'Succeeded' or 'Failed'. """ ACCEPTED = "Accepted" SUCCEEDED = "Succeeded" FAILED = "Failed" + class RoleDisasterRecovery(str, Enum, metaclass=CaseInsensitiveEnumMeta): """role of namespace in GEO DR - possible values 'Primary' or 'PrimaryNotReplicating' or - 'Secondary' + 'Secondary'. """ PRIMARY = "Primary" PRIMARY_NOT_REPLICATING = "PrimaryNotReplicating" SECONDARY = "Secondary" + class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Name of this SKU. - """ + """Name of this SKU.""" BASIC = "Basic" STANDARD = "Standard" PREMIUM = "Premium" + class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The billing tier of this particular SKU. - """ + """The billing tier of this particular SKU.""" BASIC = "Basic" STANDARD = "Standard" PREMIUM = "Premium" + class UnavailableReason(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the reason for the unavailability of the service. - """ + """Specifies the reason for the unavailability of the service.""" NONE = "None" INVALID_NAME = "InvalidName" diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/__init__.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/__init__.py index 5559ccd3746c..831edc36bd6b 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/__init__.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/__init__.py @@ -20,17 +20,18 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'NamespacesOperations', - 'PrivateEndpointConnectionsOperations', - 'PrivateLinkResourcesOperations', - 'Operations', - 'DisasterRecoveryConfigsOperations', - 'MigrationConfigsOperations', - 'QueuesOperations', - 'TopicsOperations', - 'RulesOperations', - 'SubscriptionsOperations', + "NamespacesOperations", + "PrivateEndpointConnectionsOperations", + "PrivateLinkResourcesOperations", + "Operations", + "DisasterRecoveryConfigsOperations", + "MigrationConfigsOperations", + "QueuesOperations", + "TopicsOperations", + "RulesOperations", + "SubscriptionsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() 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 58c06a315379..e6e4334ce7fa 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 @@ -6,11 +6,16 @@ # 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, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -20,343 +25,293 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") 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: Optional[_models.CheckNameAvailability] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - resource_group_name: str, - namespace_name: str, - alias: str, - subscription_id: str, - *, - json: Optional[_models.ArmDisasterRecovery] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, alias: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - namespace_name: str, - alias: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, alias: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - namespace_name: str, - alias: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, alias: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_break_pairing_request( - resource_group_name: str, - namespace_name: str, - alias: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, alias: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_fail_over_request( - resource_group_name: str, - namespace_name: str, - alias: str, - subscription_id: str, - *, - json: Optional[_models.FailoverProperties] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, alias: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_authorization_rules_request( - resource_group_name: str, - namespace_name: str, - alias: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, alias: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_authorization_rule_request( @@ -370,34 +325,35 @@ def build_get_authorization_rule_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( @@ -411,34 +367,36 @@ def build_list_keys_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class DisasterRecoveryConfigsOperations: """ @@ -459,41 +417,102 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace + @overload def check_name_availability( self, resource_group_name: str, namespace_name: str, parameters: _models.CheckNameAvailability, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Check the give namespace name availability. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters to check availability of the given namespace name. + :param parameters: Parameters to check availability of the given namespace name. Required. :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.CheckNameAvailability + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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.v2021_01_01_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters to check availability of the given namespace name. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :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.v2021_01_01_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, + resource_group_name: str, + namespace_name: str, + parameters: Union[_models.CheckNameAvailability, IO], + **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters to check availability of the given namespace name. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.CheckNameAvailability or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameAvailabilityResult, or the result of cls(response) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResult] - _json = self._serialize.body(parameters, 'CheckNameAvailability') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CheckNameAvailability") request = build_check_name_availability_request( resource_group_name=resource_group_name, @@ -502,7 +521,8 @@ def check_name_availability( api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) @@ -510,10 +530,9 @@ def check_name_availability( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -521,55 +540,49 @@ def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + 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 - + 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, - namespace_name: str, - **kwargs: Any - ) -> Iterable[_models.ArmDisasterRecoveryListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> Iterable["_models.ArmDisasterRecovery"]: """Gets all Alias(Disaster Recovery configurations). - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: An iterator like instance of either ArmDisasterRecovery 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 + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.ArmDisasterRecovery] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ArmDisasterRecoveryListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -577,16 +590,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -602,10 +610,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -616,49 +622,117 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 + @overload def create_or_update( self, resource_group_name: str, namespace_name: str, alias: str, parameters: _models.ArmDisasterRecovery, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Required. :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.ArmDisasterRecovery + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ArmDisasterRecovery or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.ArmDisasterRecovery or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ArmDisasterRecovery or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.ArmDisasterRecovery or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: Union[_models.ArmDisasterRecovery, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). Is + either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.ArmDisasterRecovery or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ArmDisasterRecovery, or the result of cls(response) + :return: ArmDisasterRecovery or None or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.ArmDisasterRecovery or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ArmDisasterRecovery]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ArmDisasterRecovery]] - _json = self._serialize.body(parameters, 'ArmDisasterRecovery') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ArmDisasterRecovery") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -668,7 +742,8 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -676,10 +751,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -689,56 +763,48 @@ def create_or_update( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ArmDisasterRecovery', pipeline_response) + 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 - + 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: str, - namespace_name: str, - alias: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -746,10 +812,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -760,49 +825,41 @@ def delete( # pylint: disable=inconsistent-return-statements 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: str, - namespace_name: str, - alias: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :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) + :return: ArmDisasterRecovery or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.ArmDisasterRecovery - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ArmDisasterRecovery] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ArmDisasterRecovery] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -810,10 +867,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -821,57 +877,49 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ArmDisasterRecovery', pipeline_response) + 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 - + 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: str, - namespace_name: str, - alias: str, - **kwargs: Any + self, 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. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.break_pairing.metadata["url"], headers=_headers, params=_params, ) @@ -879,10 +927,9 @@ def break_pairing( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -893,50 +940,118 @@ def break_pairing( # pylint: disable=inconsistent-return-statements 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 - @distributed_trace + @overload def fail_over( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, alias: str, parameters: Optional[_models.FailoverProperties] = None, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :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 content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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: + """ + + @overload + def fail_over( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Default value is None. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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: + """ + + @distributed_trace + def fail_over( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: Optional[Union[_models.FailoverProperties, IO]] = 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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). Is + either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.FailoverProperties or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - if parameters is not None: - _json = self._serialize.body(parameters, 'FailoverProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "FailoverProperties") + else: + _json = None request = build_fail_over_request( resource_group_name=resource_group_name, @@ -946,7 +1061,8 @@ def fail_over( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, json=_json, - template_url=self.fail_over.metadata['url'], + content=_content, + template_url=self.fail_over.metadata["url"], headers=_headers, params=_params, ) @@ -954,10 +1070,9 @@ def fail_over( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -968,52 +1083,45 @@ def fail_over( # pylint: disable=inconsistent-return-statements 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, - namespace_name: str, - alias: str, - **kwargs: Any - ) -> Iterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, alias: str, **kwargs: Any + ) -> Iterable["_models.SBAuthorizationRule"]: """Gets the authorization rules for a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :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) + :return: An iterator like instance of either SBAuthorizationRule 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 + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) @@ -1021,17 +1129,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -1047,10 +1149,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1061,48 +1161,38 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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: str, - namespace_name: str, - alias: str, - authorization_rule_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -1110,7 +1200,7 @@ def get_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -1118,10 +1208,9 @@ def get_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1129,52 +1218,43 @@ def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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: str, - namespace_name: str, - alias: str, - authorization_rule_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -1182,7 +1262,7 @@ def list_keys( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1190,10 +1270,9 @@ def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1201,12 +1280,11 @@ def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 - + 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 0f1c90d3644d..17ac6d0a4c1c 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 @@ -6,11 +6,16 @@ # 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, Iterable, Optional, TypeVar, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -22,95 +27,88 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_and_start_migration_request_initial( +def build_create_and_start_migration_request( resource_group_name: str, namespace_name: str, config_name: Union[str, "_models.MigrationConfigurationName"], subscription_id: str, - *, - json: Optional[_models.MigrationConfigProperties] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( @@ -123,33 +121,32 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( @@ -162,33 +159,32 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_complete_migration_request( @@ -201,33 +197,32 @@ def build_complete_migration_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_revert_request( @@ -240,33 +235,33 @@ def build_revert_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class MigrationConfigsOperations: """ @@ -287,46 +282,41 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> Iterable[_models.MigrationConfigListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> Iterable["_models.MigrationConfigProperties"]: """Gets all migrationConfigurations. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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 + :return: An iterator like instance of either MigrationConfigProperties 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 + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigProperties] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MigrationConfigListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -334,16 +324,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -359,10 +344,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -373,35 +356,37 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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: str, namespace_name: str, config_name: Union[str, "_models.MigrationConfigurationName"], - parameters: _models.MigrationConfigProperties, + parameters: Union[_models.MigrationConfigProperties, IO], **kwargs: Any ) -> Optional[_models.MigrationConfigProperties]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.MigrationConfigProperties]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.MigrationConfigProperties]] - _json = self._serialize.body(parameters, 'MigrationConfigProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "MigrationConfigProperties") - request = build_create_and_start_migration_request_initial( + request = build_create_and_start_migration_request( resource_group_name=resource_group_name, namespace_name=namespace_name, config_name=config_name, @@ -409,7 +394,8 @@ def _create_and_start_migration_initial( api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_and_start_migration_initial.metadata['url'], + content=_content, + template_url=self._create_and_start_migration_initial.metadata["url"], headers=_headers, params=_params, ) @@ -417,27 +403,108 @@ def _create_and_start_migration_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) + 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 + _create_and_start_migration_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore + @overload + def begin_create_and_start_migration( + self, + resource_group_name: str, + namespace_name: str, + config_name: Union[str, "_models.MigrationConfigurationName"], + parameters: _models.MigrationConfigProperties, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param config_name: The configuration name. Should always be "$default". "$default" Required. + :type config_name: str or + ~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigurationName + :param parameters: Parameters required to create Migration Configuration. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. + :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: + """ + + @overload + def begin_create_and_start_migration( + self, + resource_group_name: str, + namespace_name: str, + config_name: Union[str, "_models.MigrationConfigurationName"], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param config_name: The configuration name. Should always be "$default". "$default" Required. + :type config_name: str or + ~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigurationName + :param parameters: Parameters required to create Migration Configuration. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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: + """ @distributed_trace def begin_create_and_start_migration( @@ -445,21 +512,26 @@ def begin_create_and_start_migration( resource_group_name: str, namespace_name: str, config_name: Union[str, "_models.MigrationConfigurationName"], - parameters: _models.MigrationConfigProperties, + parameters: Union[_models.MigrationConfigProperties, IO], **kwargs: Any ) -> LROPoller[_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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigurationName - :param parameters: Parameters required to create Migration Configuration. + :param parameters: Parameters required to create Migration Configuration. Is either a model + type or a IO type. Required. :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigProperties + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -472,20 +544,17 @@ def begin_create_and_start_migration( of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigProperties] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.MigrationConfigProperties] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MigrationConfigProperties] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + 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 = self._create_and_start_migration_initial( # type: ignore resource_group_name=resource_group_name, @@ -494,39 +563,35 @@ def begin_create_and_start_migration( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) + deserialized = self._deserialize("MigrationConfigProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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 @@ -538,37 +603,34 @@ def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes a MigrationConfiguration. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -576,10 +638,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -590,8 +651,7 @@ def delete( # pylint: disable=inconsistent-return-statements 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( @@ -603,37 +663,34 @@ def get( ) -> _models.MigrationConfigProperties: """Retrieves Migration Config. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :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) + :return: MigrationConfigProperties or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.MigrationConfigProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MigrationConfigProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MigrationConfigProperties] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -641,10 +698,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -652,15 +708,14 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) + 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 - + 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 @@ -674,37 +729,34 @@ def complete_migration( # pylint: disable=inconsistent-return-statements 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.complete_migration.metadata["url"], headers=_headers, params=_params, ) @@ -712,10 +764,9 @@ def complete_migration( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -726,8 +777,7 @@ def complete_migration( # pylint: disable=inconsistent-return-statements 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 @distributed_trace def revert( # pylint: disable=inconsistent-return-statements @@ -739,37 +789,34 @@ def revert( # pylint: disable=inconsistent-return-statements ) -> None: """This operation reverts Migration. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.revert.metadata["url"], headers=_headers, params=_params, ) @@ -777,10 +824,9 @@ def revert( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -791,5 +837,4 @@ def revert( # pylint: disable=inconsistent-return-statements 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 a81d7686daa0..bcd6b3318375 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 @@ -6,11 +6,16 @@ # 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, Iterable, Optional, TypeVar, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -22,651 +27,557 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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: + +def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + accept = _headers.pop("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'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_resource_group_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces") # pylint: disable=line-too-long + _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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request_initial( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - *, - json: Optional[_models.SBNamespace] = None, - content: Any = None, - **kwargs: Any + +def build_create_or_update_request( + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long + _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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any +def build_delete_request( + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - *, - json: Optional[_models.SBNamespaceUpdateParameters] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_network_rule_set_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - *, - json: Optional[_models.NetworkRuleSet] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_network_rule_set_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_network_rule_sets_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_authorization_rules_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_authorization_rule_request( - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - subscription_id: str, - *, - json: Optional[_models.SBAuthorizationRule] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, authorization_rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_authorization_rule_request( - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, authorization_rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_authorization_rule_request( - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, authorization_rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, authorization_rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_regenerate_keys_request( - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - subscription_id: str, - *, - json: Optional[_models.RegenerateAccessKeyParameters] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, authorization_rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_check_name_availability_request( - subscription_id: str, - *, - json: Optional[_models.CheckNameAvailability] = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: + +def build_check_name_availability_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + class NamespacesOperations: """ @@ -687,38 +598,32 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.SBNamespaceListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.SBNamespace"]: """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) + :return: An iterator like instance of either SBNamespace 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 + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBNamespace] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespaceListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -726,14 +631,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -749,10 +651,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -763,47 +663,39 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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: str, - **kwargs: Any - ) -> Iterable[_models.SBNamespaceListResult]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.SBNamespace"]: """Gets the available namespaces within a resource group. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :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) + :return: An iterator like instance of either SBNamespace 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 + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBNamespace] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespaceListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -811,15 +703,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -835,10 +723,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -849,41 +735,40 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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: str, - namespace_name: str, - parameters: _models.SBNamespace, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, parameters: Union[_models.SBNamespace, IO], **kwargs: Any ) -> Optional[_models.SBNamespace]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.SBNamespace]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.SBNamespace]] - _json = self._serialize.body(parameters, 'SBNamespace') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBNamespace") - request = build_create_or_update_request_initial( + request = build_create_or_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._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) @@ -891,48 +776,89 @@ def _create_or_update_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SBNamespace', pipeline_response) + 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 - + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, namespace_name: str, parameters: _models.SBNamespace, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters supplied to create a namespace resource. + :param parameters: Parameters supplied to create a namespace resource. Required. :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBNamespace + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. + :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: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to create a namespace resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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 @@ -945,20 +871,49 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBNamespace] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, resource_group_name: str, namespace_name: str, parameters: Union[_models.SBNamespace, IO], **kwargs: Any + ) -> LROPoller[_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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to create a namespace resource. Is either a model type + or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBNamespace or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespace] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBNamespace] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + 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 = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, @@ -966,64 +921,54 @@ def begin_create_or_update( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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: str, - namespace_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_request_initial( + request = build_delete_request( 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'], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1031,35 +976,29 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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_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 @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, 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. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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. @@ -1071,92 +1010,77 @@ def begin_delete( # pylint: disable=inconsistent-return-statements 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + 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 = self._delete_initial( # type: ignore resource_group_name=resource_group_name, namespace_name=namespace_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> _models.SBNamespace: + def get(self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: SBNamespace or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBNamespace - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespace] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBNamespace] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -1164,10 +1088,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1175,51 +1098,115 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBNamespace', pipeline_response) + 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 + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + + @overload + def update( + self, + resource_group_name: str, + namespace_name: str, + parameters: _models.SBNamespaceUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> 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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to update a namespace resource. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBNamespaceUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBNamespace or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBNamespace or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> 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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to update a namespace resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBNamespace or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBNamespace or None + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def update( self, resource_group_name: str, namespace_name: str, - parameters: _models.SBNamespaceUpdateParameters, + parameters: Union[_models.SBNamespaceUpdateParameters, IO], **kwargs: Any ) -> 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters supplied to update a namespace resource. + :param parameters: Parameters supplied to update a namespace resource. Is either a model type + or a IO type. Required. :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBNamespaceUpdateParameters + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBNamespace, or the result of cls(response) + :return: SBNamespace or None or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBNamespace or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.SBNamespace]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.SBNamespace]] - _json = self._serialize.body(parameters, 'SBNamespaceUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBNamespaceUpdateParameters") request = build_update_request( resource_group_name=resource_group_name, @@ -1228,7 +1215,8 @@ def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -1236,10 +1224,9 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -1249,53 +1236,113 @@ def update( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SBNamespace', pipeline_response) + 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 + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - - @distributed_trace + @overload def create_or_update_network_rule_set( self, resource_group_name: str, namespace_name: str, parameters: _models.NetworkRuleSet, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.NetworkRuleSet: """Create or update NetworkRuleSet for a Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: The Namespace IpFilterRule. + :param parameters: The Namespace IpFilterRule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.NetworkRuleSet + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: NetworkRuleSet, or the result of cls(response) + :return: NetworkRuleSet or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.NetworkRuleSet - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def create_or_update_network_rule_set( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NetworkRuleSet: + """Create or update NetworkRuleSet for a Namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: The Namespace IpFilterRule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2021_01_01_preview.models.NetworkRuleSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_network_rule_set( + self, + resource_group_name: str, + namespace_name: str, + parameters: Union[_models.NetworkRuleSet, IO], + **kwargs: Any + ) -> _models.NetworkRuleSet: + """Create or update NetworkRuleSet for a Namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: The Namespace IpFilterRule. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.NetworkRuleSet or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2021_01_01_preview.models.NetworkRuleSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkRuleSet] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.NetworkRuleSet] - _json = self._serialize.body(parameters, 'NetworkRuleSet') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "NetworkRuleSet") request = build_create_or_update_network_rule_set_request( resource_group_name=resource_group_name, @@ -1304,7 +1351,8 @@ def create_or_update_network_rule_set( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_network_rule_set.metadata['url'], + content=_content, + template_url=self.create_or_update_network_rule_set.metadata["url"], headers=_headers, params=_params, ) @@ -1312,10 +1360,9 @@ def create_or_update_network_rule_set( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1323,52 +1370,45 @@ def create_or_update_network_rule_set( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('NetworkRuleSet', pipeline_response) + 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 - + 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: str, - namespace_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: NetworkRuleSet or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.NetworkRuleSet - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkRuleSet] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.NetworkRuleSet] - 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'], + template_url=self.get_network_rule_set.metadata["url"], headers=_headers, params=_params, ) @@ -1376,10 +1416,9 @@ def get_network_rule_set( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1387,55 +1426,49 @@ def get_network_rule_set( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('NetworkRuleSet', pipeline_response) + 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 - + 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, - namespace_name: str, - **kwargs: Any - ) -> Iterable[_models.NetworkRuleSetListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> Iterable["_models.NetworkRuleSet"]: """Gets list of NetworkRuleSet for a Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: An iterator like instance of either NetworkRuleSet 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 + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.NetworkRuleSet] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkRuleSetListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_network_rule_sets.metadata["url"], headers=_headers, params=_params, ) @@ -1443,16 +1476,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -1468,10 +1496,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1482,51 +1508,44 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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: str, - namespace_name: str, - **kwargs: Any - ) -> Iterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> Iterable["_models.SBAuthorizationRule"]: """Gets the authorization rules for a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: An iterator like instance of either SBAuthorizationRule 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 + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) @@ -1534,16 +1553,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -1559,10 +1573,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1573,49 +1585,115 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 + @overload def create_or_update_authorization_rule( self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, parameters: _models.SBAuthorizationRule, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2021_01_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: Union[_models.SBAuthorizationRule, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2021_01_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - _json = self._serialize.body(parameters, 'SBAuthorizationRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBAuthorizationRule") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -1625,7 +1703,8 @@ def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -1633,10 +1712,9 @@ def create_or_update_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1644,56 +1722,48 @@ def create_or_update_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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: str, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -1701,10 +1771,9 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1715,49 +1784,41 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements 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: str, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - 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'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -1765,10 +1826,9 @@ def get_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1776,56 +1836,48 @@ def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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: str, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - 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'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1833,10 +1885,9 @@ def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1844,54 +1895,122 @@ def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 - + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys"} # type: ignore - @distributed_trace + @overload def regenerate_keys( self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, parameters: _models.RegenerateAccessKeyParameters, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.RegenerateAccessKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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.v2021_01_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2021_01_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateAccessKeyParameters, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: + ~azure.mgmt.servicebus.v2021_01_01_preview.models.RegenerateAccessKeyParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateAccessKeyParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -1901,7 +2020,8 @@ def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1909,10 +2029,9 @@ def regenerate_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1920,51 +2039,91 @@ def regenerate_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 + regenerate_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore + + @overload + def check_name_availability( + self, parameters: _models.CheckNameAvailability, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + :param parameters: Parameters to check availability of the given namespace name. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.CheckNameAvailability + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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.v2021_01_01_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param parameters: Parameters to check availability of the given namespace name. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :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.v2021_01_01_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def check_name_availability( - self, - parameters: _models.CheckNameAvailability, - **kwargs: Any + self, parameters: Union[_models.CheckNameAvailability, IO], **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Check the give namespace name availability. - :param parameters: Parameters to check availability of the given namespace name. - :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.CheckNameAvailability + :param parameters: Parameters to check availability of the given namespace name. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.CheckNameAvailability or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameAvailabilityResult, or the result of cls(response) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResult] - _json = self._serialize.body(parameters, 'CheckNameAvailability') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _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'], + content=_content, + template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) @@ -1972,10 +2131,9 @@ def check_name_availability( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1983,12 +2141,11 @@ def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + 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 - + 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 9faec6420ec1..4112dd857add 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 @@ -7,10 +7,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- 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 urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -20,38 +25,34 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +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: + +def build_list_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.ServiceBus/operations") # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class Operations: """ @@ -72,36 +73,31 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.OperationListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """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) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -109,13 +105,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -131,10 +125,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -145,8 +137,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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/_patch.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_patch.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_01_01_preview/operations/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. 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 f3a9dd347ae1..07dd531a8e13 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 @@ -6,11 +6,16 @@ # 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, Iterable, Optional, TypeVar, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -22,134 +27,130 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - subscription_id: str, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, - *, - json: Optional[_models.PrivateEndpointConnection] = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( +def build_delete_request( resource_group_name: str, namespace_name: str, - subscription_id: str, private_endpoint_connection_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( @@ -162,33 +163,35 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class PrivateEndpointConnectionsOperations: """ @@ -209,46 +212,41 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> Iterable[_models.PrivateEndpointConnectionListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> Iterable["_models.PrivateEndpointConnection"]: """Gets the available PrivateEndpointConnections within a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: An iterator like instance of either PrivateEndpointConnection 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 + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnectionListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -256,16 +254,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -281,10 +274,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -295,60 +286,129 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 + @overload def create_or_update( self, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, parameters: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.PrivateEndpointConnection: """Creates or updates PrivateEndpointConnections of service namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param private_endpoint_connection_name: The PrivateEndpointConnection name. + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. :type private_endpoint_connection_name: str :param parameters: Parameters supplied to update Status of PrivateEndPoint Connection to - namespace resource. + namespace resource. Required. :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.PrivateEndpointConnection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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.v2021_01_01_preview.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Creates or updates PrivateEndpointConnections of service namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. + :type private_endpoint_connection_name: str + :param parameters: Parameters supplied to update Status of PrivateEndPoint Connection to + namespace resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateEndpointConnection, or the result of cls(response) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + parameters: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Creates or updates PrivateEndpointConnections of service namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. + :type private_endpoint_connection_name: str + :param parameters: Parameters supplied to update Status of PrivateEndPoint Connection to + namespace resource. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.PrivateEndpointConnection + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2021_01_01_preview.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - _json = self._serialize.body(parameters, 'PrivateEndpointConnection') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _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, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -356,10 +416,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -368,45 +427,37 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + 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 - + 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: str, - namespace_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_request_initial( + request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, - subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) @@ -414,37 +465,32 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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_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 @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + def begin_delete( + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param private_endpoint_connection_name: The PrivateEndpointConnection name. + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. :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. @@ -456,97 +502,83 @@ def begin_delete( # pylint: disable=inconsistent-return-statements 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + 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 = self._delete_initial( # type: ignore 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, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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: str, - namespace_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param private_endpoint_connection_name: The PrivateEndpointConnection name. + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. :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) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -554,10 +586,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -565,12 +596,11 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + 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 - + 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 9fd9e6f03a90..2b6d1d23ebe8 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 @@ -8,9 +8,13 @@ # -------------------------------------------------------------------------- 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.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,48 +23,48 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class PrivateLinkResourcesOperations: """ @@ -81,43 +85,36 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def get( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: PrivateLinkResourcesListResult or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.PrivateLinkResourcesListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourcesListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResourcesListResult] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -125,10 +122,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -136,12 +132,11 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateLinkResourcesListResult', pipeline_response) + 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 - + 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 c72a7a31149f..5d952b4b6374 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 @@ -6,11 +6,16 @@ # 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, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -20,50 +25,48 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") 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 + resource_group_name: str, namespace_name: str, queue_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_authorization_rule_request( @@ -72,47 +75,43 @@ def build_create_or_update_authorization_rule_request( queue_name: str, authorization_rule_name: str, subscription_id: str, - *, - json: Optional[_models.SBAuthorizationRule] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_authorization_rule_request( @@ -126,34 +125,35 @@ def build_delete_authorization_rule_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_authorization_rule_request( @@ -167,34 +167,35 @@ def build_get_authorization_rule_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( @@ -208,34 +209,35 @@ def build_list_keys_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_regenerate_keys_request( @@ -244,47 +246,43 @@ def build_regenerate_keys_request( queue_name: str, authorization_rule_name: str, subscription_id: str, - *, - json: Optional[_models.RegenerateAccessKeyParameters] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_namespace_request( @@ -299,161 +297,141 @@ def build_list_by_namespace_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if skip is not None: - _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', maximum=1000, minimum=0) + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", maximum=1000, minimum=0) if top is not None: - _params['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - resource_group_name: str, - namespace_name: str, - queue_name: str, - subscription_id: str, - *, - json: Optional[_models.SBQueue] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, queue_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - namespace_name: str, - queue_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, queue_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - namespace_name: str, - queue_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, queue_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class QueuesOperations: """ @@ -474,50 +452,43 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - **kwargs: Any - ) -> Iterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, queue_name: str, **kwargs: Any + ) -> Iterable["_models.SBAuthorizationRule"]: """Gets all authorization rules for a queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :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) + :return: An iterator like instance of either SBAuthorizationRule 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 + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) @@ -525,17 +496,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -551,10 +516,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -565,13 +528,11 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 + @overload def create_or_update_authorization_rule( self, resource_group_name: str, @@ -579,38 +540,112 @@ def create_or_update_authorization_rule( queue_name: str, authorization_rule_name: str, parameters: _models.SBAuthorizationRule, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBAuthorizationRule: """Creates an authorization rule for a queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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.v2021_01_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for a queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: Union[_models.SBAuthorizationRule, IO], + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for a queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2021_01_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - _json = self._serialize.body(parameters, 'SBAuthorizationRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBAuthorizationRule") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -621,7 +656,8 @@ def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -629,10 +665,9 @@ def create_or_update_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -640,15 +675,14 @@ def create_or_update_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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 @@ -661,31 +695,28 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes a queue authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -693,7 +724,7 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_authorization_rule.metadata['url'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -701,10 +732,9 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -715,8 +745,7 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements 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( @@ -729,31 +758,28 @@ def get_authorization_rule( ) -> _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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -761,7 +787,7 @@ def get_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -769,10 +795,9 @@ def get_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -780,15 +805,14 @@ def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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( @@ -801,31 +825,28 @@ def list_keys( ) -> _models.AccessKeys: """Primary and secondary connection strings to the queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -833,7 +854,7 @@ def list_keys( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -841,10 +862,9 @@ def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -852,17 +872,16 @@ def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 - + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore - @distributed_trace + @overload def regenerate_keys( self, resource_group_name: str, @@ -870,39 +889,114 @@ def regenerate_keys( queue_name: str, authorization_rule_name: str, parameters: _models.RegenerateAccessKeyParameters, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.RegenerateAccessKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2021_01_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateAccessKeyParameters, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: + ~azure.mgmt.servicebus.v2021_01_01_preview.models.RegenerateAccessKeyParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2021_01_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateAccessKeyParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -913,7 +1007,8 @@ def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) @@ -921,10 +1016,9 @@ def regenerate_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -932,15 +1026,14 @@ def regenerate_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 - + 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( @@ -950,12 +1043,12 @@ def list_by_namespace( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable[_models.SBQueueListResult]: + ) -> Iterable["_models.SBQueue"]: """Gets the queues within a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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 @@ -965,32 +1058,30 @@ def list_by_namespace( 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] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either SBQueue or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBQueue] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBQueueListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + api_version=api_version, + template_url=self.list_by_namespace.metadata["url"], headers=_headers, params=_params, ) @@ -998,18 +1089,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -1025,10 +1109,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1039,49 +1121,115 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 + @overload def create_or_update( self, resource_group_name: str, namespace_name: str, queue_name: str, parameters: _models.SBQueue, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param parameters: Parameters supplied to create or update a queue resource. + :param parameters: Parameters supplied to create or update a queue resource. Required. :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBQueue + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBQueue, or the result of cls(response) + :return: SBQueue or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param parameters: Parameters supplied to create or update a queue resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2021_01_01_preview.models.SBQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + parameters: Union[_models.SBQueue, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param parameters: Parameters supplied to create or update a queue resource. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBQueue or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2021_01_01_preview.models.SBQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBQueue] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBQueue] - _json = self._serialize.body(parameters, 'SBQueue') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBQueue") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -1091,7 +1239,8 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -1099,10 +1248,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1110,56 +1258,48 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBQueue', pipeline_response) + 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 - + 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: str, - namespace_name: str, - queue_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -1167,10 +1307,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1181,49 +1320,39 @@ def delete( # pylint: disable=inconsistent-return-statements 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: str, - namespace_name: str, - queue_name: str, - **kwargs: Any - ) -> _models.SBQueue: + def get(self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :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) + :return: SBQueue or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBQueue] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBQueue] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -1231,10 +1360,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1242,12 +1370,11 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBQueue', pipeline_response) + 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 - + 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 0b08d466999a..5f2c5d87653f 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 @@ -6,11 +6,16 @@ # 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, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -20,13 +25,16 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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_subscriptions_request( resource_group_name: str, namespace_name: str, @@ -41,38 +49,37 @@ def build_list_by_subscriptions_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if skip is not None: - _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', maximum=1000, minimum=0) + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", maximum=1000, minimum=0) if top is not None: - _params['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( @@ -82,48 +89,42 @@ def build_create_or_update_request( subscription_name: str, rule_name: str, subscription_id: str, - *, - json: Optional[_models.Rule] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( @@ -138,35 +139,34 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( @@ -181,35 +181,35 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class RulesOperations: """ @@ -230,7 +230,6 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_by_subscriptions( self, @@ -241,16 +240,16 @@ def list_by_subscriptions( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable[_models.RuleListResult]: + ) -> Iterable["_models.Rule"]: """List all the rules within given topic-subscription. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :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 @@ -260,34 +259,32 @@ def list_by_subscriptions( 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] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Rule or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.Rule] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.RuleListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + api_version=api_version, + template_url=self.list_by_subscriptions.metadata["url"], headers=_headers, params=_params, ) @@ -295,20 +292,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -324,10 +312,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -338,13 +324,11 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 + @overload def create_or_update( self, resource_group_name: str, @@ -353,40 +337,120 @@ def create_or_update( subscription_name: str, rule_name: str, parameters: _models.Rule, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param rule_name: The rule name. + :param rule_name: The rule name. Required. :type rule_name: str - :param parameters: Parameters supplied to create a rule. + :param parameters: Parameters supplied to create a rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.Rule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Rule, or the result of cls(response) + :return: Rule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.Rule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param rule_name: The rule name. Required. + :type rule_name: str + :param parameters: Parameters supplied to create a rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2021_01_01_preview.models.Rule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + parameters: Union[_models.Rule, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param rule_name: The rule name. Required. + :type rule_name: str + :param parameters: Parameters supplied to create a rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.Rule or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2021_01_01_preview.models.Rule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Rule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Rule] - _json = self._serialize.body(parameters, 'Rule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Rule") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -398,7 +462,8 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -406,10 +471,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -417,15 +481,14 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Rule', pipeline_response) + 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 - + 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 @@ -439,33 +502,30 @@ def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes an existing rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param rule_name: The rule name. + :param rule_name: The rule name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -474,7 +534,7 @@ def delete( # pylint: disable=inconsistent-return-statements rule_name=rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -482,10 +542,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -496,8 +555,7 @@ def delete( # pylint: disable=inconsistent-return-statements 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( @@ -511,33 +569,30 @@ def get( ) -> _models.Rule: """Retrieves the description for the specified rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param rule_name: The rule name. + :param rule_name: The rule name. Required. :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) + :return: Rule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.Rule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Rule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Rule] - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -546,7 +601,7 @@ def get( rule_name=rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -554,10 +609,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -565,12 +619,11 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Rule', pipeline_response) + 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 - + 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 92a358c44679..3c5a652e89f9 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 @@ -6,11 +6,16 @@ # 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, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -20,13 +25,16 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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_topic_request( resource_group_name: str, namespace_name: str, @@ -40,37 +48,36 @@ def build_list_by_topic_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if skip is not None: - _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', maximum=1000, minimum=0) + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", maximum=1000, minimum=0) if top is not None: - _params['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( @@ -79,47 +86,41 @@ def build_create_or_update_request( topic_name: str, subscription_name: str, subscription_id: str, - *, - json: Optional[_models.SBSubscription] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( @@ -133,34 +134,33 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( @@ -174,34 +174,34 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class SubscriptionsOperations: """ @@ -222,7 +222,6 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_by_topic( self, @@ -232,14 +231,14 @@ def list_by_topic( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable[_models.SBSubscriptionListResult]: + ) -> Iterable["_models.SBSubscription"]: """List all the subscriptions under a specified topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :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 @@ -249,34 +248,32 @@ def list_by_topic( 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) + :return: An iterator like instance of either SBSubscription 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 + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBSubscription] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBSubscriptionListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + api_version=api_version, + template_url=self.list_by_topic.metadata["url"], headers=_headers, params=_params, ) @@ -284,19 +281,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -312,10 +301,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -326,13 +313,11 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 + @overload def create_or_update( self, resource_group_name: str, @@ -340,38 +325,112 @@ def create_or_update( topic_name: str, subscription_name: str, parameters: _models.SBSubscription, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBSubscription: """Creates a topic subscription. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param parameters: Parameters supplied to create a subscription resource. + :param parameters: Parameters supplied to create a subscription resource. Required. :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBSubscription + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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.v2021_01_01_preview.models.SBSubscription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBSubscription: + """Creates a topic subscription. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param parameters: Parameters supplied to create a subscription resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2021_01_01_preview.models.SBSubscription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + parameters: Union[_models.SBSubscription, IO], + **kwargs: Any + ) -> _models.SBSubscription: + """Creates a topic subscription. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param parameters: Parameters supplied to create a subscription resource. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBSubscription or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBSubscription, or the result of cls(response) + :return: SBSubscription or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBSubscription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBSubscription] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBSubscription] - _json = self._serialize.body(parameters, 'SBSubscription') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBSubscription") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -382,7 +441,8 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -390,10 +450,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -401,52 +460,43 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBSubscription', pipeline_response) + 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 - + 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: str, - namespace_name: str, - topic_name: str, - subscription_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -454,7 +504,7 @@ def delete( # pylint: disable=inconsistent-return-statements subscription_name=subscription_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -462,10 +512,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -476,45 +525,36 @@ def delete( # pylint: disable=inconsistent-return-statements 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: str, - namespace_name: str, - topic_name: str, - subscription_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :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) + :return: SBSubscription or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBSubscription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBSubscription] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBSubscription] - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -522,7 +562,7 @@ def get( subscription_name=subscription_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -530,10 +570,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -541,12 +580,11 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBSubscription', pipeline_response) + 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 - + 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 8791f787584f..13930897ee62 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 @@ -6,11 +6,16 @@ # 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, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -20,50 +25,48 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") 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 + resource_group_name: str, namespace_name: str, topic_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_authorization_rule_request( @@ -72,47 +75,43 @@ def build_create_or_update_authorization_rule_request( topic_name: str, authorization_rule_name: str, subscription_id: str, - *, - json: Optional[_models.SBAuthorizationRule] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_authorization_rule_request( @@ -126,34 +125,35 @@ def build_get_authorization_rule_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_authorization_rule_request( @@ -167,34 +167,35 @@ def build_delete_authorization_rule_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( @@ -208,34 +209,35 @@ def build_list_keys_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_regenerate_keys_request( @@ -244,47 +246,43 @@ def build_regenerate_keys_request( topic_name: str, authorization_rule_name: str, subscription_id: str, - *, - json: Optional[_models.RegenerateAccessKeyParameters] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_namespace_request( @@ -299,161 +297,141 @@ def build_list_by_namespace_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if skip is not None: - _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', maximum=1000, minimum=0) + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", maximum=1000, minimum=0) if top is not None: - _params['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_id: str, - *, - json: Optional[_models.SBTopic] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, topic_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, topic_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, topic_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class TopicsOperations: """ @@ -474,50 +452,43 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - **kwargs: Any - ) -> Iterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, topic_name: str, **kwargs: Any + ) -> Iterable["_models.SBAuthorizationRule"]: """Gets authorization rules for a topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :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) + :return: An iterator like instance of either SBAuthorizationRule 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 + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) @@ -525,17 +496,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -551,10 +516,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -565,13 +528,11 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 + @overload def create_or_update_authorization_rule( self, resource_group_name: str, @@ -579,38 +540,112 @@ def create_or_update_authorization_rule( topic_name: str, authorization_rule_name: str, parameters: _models.SBAuthorizationRule, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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.v2021_01_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: Union[_models.SBAuthorizationRule, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2021_01_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - _json = self._serialize.body(parameters, 'SBAuthorizationRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBAuthorizationRule") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -621,7 +656,8 @@ def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -629,10 +665,9 @@ def create_or_update_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -640,15 +675,14 @@ def create_or_update_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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( @@ -661,31 +695,28 @@ def get_authorization_rule( ) -> _models.SBAuthorizationRule: """Returns the specified authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -693,7 +724,7 @@ def get_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -701,10 +732,9 @@ def get_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -712,15 +742,14 @@ def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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 @@ -733,31 +762,28 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes a topic authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -765,7 +791,7 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_authorization_rule.metadata['url'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -773,10 +799,9 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -787,8 +812,7 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements 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( @@ -801,31 +825,28 @@ def list_keys( ) -> _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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -833,7 +854,7 @@ def list_keys( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -841,10 +862,9 @@ def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -852,17 +872,16 @@ def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 - + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore - @distributed_trace + @overload def regenerate_keys( self, resource_group_name: str, @@ -870,39 +889,114 @@ def regenerate_keys( topic_name: str, authorization_rule_name: str, parameters: _models.RegenerateAccessKeyParameters, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.RegenerateAccessKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2021_01_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateAccessKeyParameters, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: + ~azure.mgmt.servicebus.v2021_01_01_preview.models.RegenerateAccessKeyParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2021_01_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateAccessKeyParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -913,7 +1007,8 @@ def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) @@ -921,10 +1016,9 @@ def regenerate_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -932,15 +1026,14 @@ def regenerate_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 - + 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( @@ -950,12 +1043,12 @@ def list_by_namespace( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable[_models.SBTopicListResult]: + ) -> Iterable["_models.SBTopic"]: """Gets all the topics in a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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 @@ -965,32 +1058,30 @@ def list_by_namespace( 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] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either SBTopic or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_01_01_preview.models.SBTopic] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBTopicListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + api_version=api_version, + template_url=self.list_by_namespace.metadata["url"], headers=_headers, params=_params, ) @@ -998,18 +1089,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -1025,10 +1109,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1039,49 +1121,115 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 + @overload def create_or_update( self, resource_group_name: str, namespace_name: str, topic_name: str, parameters: _models.SBTopic, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBTopic: """Creates a topic in the specified namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param parameters: Parameters supplied to create a topic resource. + :param parameters: Parameters supplied to create a topic resource. Required. :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBTopic + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBTopic, or the result of cls(response) + :return: SBTopic or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBTopic - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBTopic: + """Creates a topic in the specified namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param parameters: Parameters supplied to create a topic resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2021_01_01_preview.models.SBTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + parameters: Union[_models.SBTopic, IO], + **kwargs: Any + ) -> _models.SBTopic: + """Creates a topic in the specified namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param parameters: Parameters supplied to create a topic resource. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBTopic or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2021_01_01_preview.models.SBTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBTopic] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBTopic] - _json = self._serialize.body(parameters, 'SBTopic') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBTopic") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -1091,7 +1239,8 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -1099,10 +1248,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1110,56 +1258,48 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBTopic', pipeline_response) + 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 - + 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: str, - namespace_name: str, - topic_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -1167,10 +1307,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1181,49 +1320,39 @@ def delete( # pylint: disable=inconsistent-return-statements 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: str, - namespace_name: str, - topic_name: str, - **kwargs: Any - ) -> _models.SBTopic: + def get(self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :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) + :return: SBTopic or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_01_01_preview.models.SBTopic - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBTopic] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBTopic] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -1231,10 +1360,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1242,12 +1370,11 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBTopic', pipeline_response) + 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 - + 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 221541a00fb6..2a82b6cb6f69 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 @@ -17,7 +17,8 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['ServiceBusManagementClient'] + +__all__ = ["ServiceBusManagementClient"] __all__.extend([p for p in _patch_all if p not in __all__]) _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 91585e68502c..02da50323989 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 @@ -25,24 +25,19 @@ class ServiceBusManagementClientConfiguration(Configuration): # pylint: disable Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :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. + subscription. The subscription ID forms part of the URI for every service call. Required. :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: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, 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 + api_version = kwargs.pop("api_version", "2021-06-01-preview") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -52,23 +47,24 @@ def __init__( self.credential = credential self.subscription_id = subscription_id 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.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-servicebus/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> None - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(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 d5209a713f9d..96b9b4fb44c2 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 @@ -10,20 +10,20 @@ "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\"], \"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\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ServiceBusManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ServiceBusManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", + "signature": "subscription_id: str,", + "description": "Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", + "description": "Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false 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 index 0ad201a8c586..f7dd32510333 100644 --- 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 @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. 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 e7ba0ba9ea96..80ad538a051a 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 @@ -9,20 +9,31 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import ServiceBusManagementClientConfiguration -from .operations import DisasterRecoveryConfigsOperations, MigrationConfigsOperations, NamespacesOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, QueuesOperations, RulesOperations, SubscriptionsOperations, TopicsOperations +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: # pylint: disable=too-many-instance-attributes + +class ServiceBusManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Azure Service Bus client for managing Namespace. :ivar namespaces: NamespacesOperations operations @@ -50,10 +61,10 @@ class ServiceBusManagementClient: # pylint: disable=too-many-instance-attribu :ivar subscriptions: SubscriptionsOperations operations :vartype subscriptions: azure.mgmt.servicebus.v2021_06_01_preview.operations.SubscriptionsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :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. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -71,50 +82,35 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ServiceBusManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + 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._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.namespaces = NamespacesOperations( - 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.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.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: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -123,7 +119,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest 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 index 138f663c53a4..9aad73fc743e 100644 --- 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 @@ -7,6 +7,7 @@ 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) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): 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 - ] + 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 920456322fa1..9f1dc6e309ba 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 = "8.1.0" +VERSION = "0.0.0 (it should be stable)" 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 e7dd87df1f93..ba757410f14a 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 @@ -14,7 +14,8 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['ServiceBusManagementClient'] + +__all__ = ["ServiceBusManagementClient"] __all__.extend([p for p in _patch_all if p not in __all__]) _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 6b3e32290dc5..482b288bb558 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 @@ -25,24 +25,19 @@ class ServiceBusManagementClientConfiguration(Configuration): # pylint: disable Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :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. + subscription. The subscription ID forms part of the URI for every service call. Required. :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: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(ServiceBusManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + api_version = kwargs.pop("api_version", "2021-06-01-preview") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -52,22 +47,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id 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.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-servicebus/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, - **kwargs: Any - ) -> None: - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(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 index 0ad201a8c586..f7dd32510333 100644 --- 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 @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. 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 e1e25354debf..449c51b02daa 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 @@ -9,20 +9,31 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import ServiceBusManagementClientConfiguration -from .operations import DisasterRecoveryConfigsOperations, MigrationConfigsOperations, NamespacesOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, QueuesOperations, RulesOperations, SubscriptionsOperations, TopicsOperations +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: # pylint: disable=too-many-instance-attributes + +class ServiceBusManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Azure Service Bus client for managing Namespace. :ivar namespaces: NamespacesOperations operations @@ -51,10 +62,10 @@ class ServiceBusManagementClient: # pylint: disable=too-many-instance-attribu :ivar subscriptions: SubscriptionsOperations operations :vartype subscriptions: azure.mgmt.servicebus.v2021_06_01_preview.aio.operations.SubscriptionsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :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. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -72,50 +83,35 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ServiceBusManagementClientConfiguration(credential=credential, subscription_id=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._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.namespaces = NamespacesOperations( - 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.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.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 - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -124,7 +120,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/__init__.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/__init__.py index 5559ccd3746c..831edc36bd6b 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/__init__.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/__init__.py @@ -20,17 +20,18 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'NamespacesOperations', - 'PrivateEndpointConnectionsOperations', - 'PrivateLinkResourcesOperations', - 'Operations', - 'DisasterRecoveryConfigsOperations', - 'MigrationConfigsOperations', - 'QueuesOperations', - 'TopicsOperations', - 'RulesOperations', - 'SubscriptionsOperations', + "NamespacesOperations", + "PrivateEndpointConnectionsOperations", + "PrivateLinkResourcesOperations", + "Operations", + "DisasterRecoveryConfigsOperations", + "MigrationConfigsOperations", + "QueuesOperations", + "TopicsOperations", + "RulesOperations", + "SubscriptionsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() 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 d30d714bf426..72f5080c3077 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 @@ -6,10 +6,17 @@ # 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, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +27,23 @@ 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') +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]] + class DisasterRecoveryConfigsOperations: """ .. warning:: @@ -43,41 +63,102 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async + @overload async def check_name_availability( self, resource_group_name: str, namespace_name: str, parameters: _models.CheckNameAvailability, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Check the give namespace name availability. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters to check availability of the given namespace name. + :param parameters: Parameters to check availability of the given namespace name. Required. :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.CheckNameAvailability + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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.v2021_06_01_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters to check availability of the given namespace name. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :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.v2021_06_01_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, + resource_group_name: str, + namespace_name: str, + parameters: Union[_models.CheckNameAvailability, IO], + **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters to check availability of the given namespace name. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.CheckNameAvailability or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameAvailabilityResult, or the result of cls(response) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResult] - _json = self._serialize.body(parameters, 'CheckNameAvailability') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CheckNameAvailability") request = build_check_name_availability_request( resource_group_name=resource_group_name, @@ -86,7 +167,8 @@ async def check_name_availability( api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) @@ -94,10 +176,9 @@ async def check_name_availability( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -105,55 +186,49 @@ async def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + 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 - + 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, - namespace_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.ArmDisasterRecoveryListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ArmDisasterRecovery"]: """Gets all Alias(Disaster Recovery configurations). - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: An iterator like instance of either ArmDisasterRecovery 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 + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.ArmDisasterRecovery] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ArmDisasterRecoveryListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -161,16 +236,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -186,10 +256,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -200,49 +268,117 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 + @overload async def create_or_update( self, resource_group_name: str, namespace_name: str, alias: str, parameters: _models.ArmDisasterRecovery, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Required. :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.ArmDisasterRecovery + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ArmDisasterRecovery or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.ArmDisasterRecovery or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ArmDisasterRecovery, or the result of cls(response) + :return: ArmDisasterRecovery or None or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.ArmDisasterRecovery or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: Union[_models.ArmDisasterRecovery, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). Is + either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.ArmDisasterRecovery or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ArmDisasterRecovery or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.ArmDisasterRecovery or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ArmDisasterRecovery]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ArmDisasterRecovery]] - _json = self._serialize.body(parameters, 'ArmDisasterRecovery') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ArmDisasterRecovery") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -252,7 +388,8 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -260,10 +397,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -273,56 +409,48 @@ async def create_or_update( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ArmDisasterRecovery', pipeline_response) + 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 - + 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, - alias: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -330,10 +458,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -344,49 +471,41 @@ async def delete( # pylint: disable=inconsistent-return-statements 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, - namespace_name: str, - alias: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :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) + :return: ArmDisasterRecovery or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.ArmDisasterRecovery - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ArmDisasterRecovery] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ArmDisasterRecovery] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -394,10 +513,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -405,57 +523,49 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ArmDisasterRecovery', pipeline_response) + 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 - + 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, - alias: str, - **kwargs: Any + self, 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. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.break_pairing.metadata["url"], headers=_headers, params=_params, ) @@ -463,10 +573,9 @@ async def break_pairing( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -477,50 +586,118 @@ async def break_pairing( # pylint: disable=inconsistent-return-statements 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 - @distributed_trace_async + @overload async def fail_over( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, alias: str, parameters: Optional[_models.FailoverProperties] = None, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :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 content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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: + """ + + @overload + async def fail_over( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Default value is None. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace_async + async def fail_over( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: Optional[Union[_models.FailoverProperties, IO]] = 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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). Is + either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.FailoverProperties or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - if parameters is not None: - _json = self._serialize.body(parameters, 'FailoverProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "FailoverProperties") + else: + _json = None request = build_fail_over_request( resource_group_name=resource_group_name, @@ -530,7 +707,8 @@ async def fail_over( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, json=_json, - template_url=self.fail_over.metadata['url'], + content=_content, + template_url=self.fail_over.metadata["url"], headers=_headers, params=_params, ) @@ -538,10 +716,9 @@ async def fail_over( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -552,52 +729,45 @@ async def fail_over( # pylint: disable=inconsistent-return-statements 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, - namespace_name: str, - alias: str, - **kwargs: Any - ) -> AsyncIterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, alias: str, **kwargs: Any + ) -> AsyncIterable["_models.SBAuthorizationRule"]: """Gets the authorization rules for a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :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) + :return: An iterator like instance of either SBAuthorizationRule 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 + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) @@ -605,17 +775,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -631,10 +795,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -645,48 +807,38 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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, - namespace_name: str, - alias: str, - authorization_rule_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -694,7 +846,7 @@ async def get_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -702,10 +854,9 @@ async def get_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -713,52 +864,43 @@ async def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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, - namespace_name: str, - alias: str, - authorization_rule_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -766,7 +908,7 @@ async def list_keys( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -774,10 +916,9 @@ async def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -785,12 +926,11 @@ async def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 - + 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 5c0cde0e9ca2..d1b1b298c9e8 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 @@ -6,10 +6,17 @@ # 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, Optional, TypeVar, Union, cast +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +29,19 @@ 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') +from ...operations._migration_configs_operations import ( + build_complete_migration_request, + build_create_and_start_migration_request, + 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]] + class MigrationConfigsOperations: """ .. warning:: @@ -45,46 +61,41 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.MigrationConfigListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.MigrationConfigProperties"]: """Gets all migrationConfigurations. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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 + :return: An iterator like instance of either MigrationConfigProperties 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 + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigProperties] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MigrationConfigListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -92,16 +103,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -117,10 +123,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -131,35 +135,37 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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, resource_group_name: str, namespace_name: str, config_name: Union[str, "_models.MigrationConfigurationName"], - parameters: _models.MigrationConfigProperties, + parameters: Union[_models.MigrationConfigProperties, IO], **kwargs: Any ) -> Optional[_models.MigrationConfigProperties]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.MigrationConfigProperties]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.MigrationConfigProperties]] - _json = self._serialize.body(parameters, 'MigrationConfigProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "MigrationConfigProperties") - request = build_create_and_start_migration_request_initial( + request = build_create_and_start_migration_request( resource_group_name=resource_group_name, namespace_name=namespace_name, config_name=config_name, @@ -167,7 +173,8 @@ async def _create_and_start_migration_initial( api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_and_start_migration_initial.metadata['url'], + content=_content, + template_url=self._create_and_start_migration_initial.metadata["url"], headers=_headers, params=_params, ) @@ -175,27 +182,108 @@ async def _create_and_start_migration_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) + 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 + _create_and_start_migration_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore + @overload + async def begin_create_and_start_migration( + self, + resource_group_name: str, + namespace_name: str, + config_name: Union[str, "_models.MigrationConfigurationName"], + parameters: _models.MigrationConfigProperties, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> 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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param config_name: The configuration name. Should always be "$default". "$default" Required. + :type config_name: str or + ~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigurationName + :param parameters: Parameters required to create Migration Configuration. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. + :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: + """ + + @overload + async def begin_create_and_start_migration( + self, + resource_group_name: str, + namespace_name: str, + config_name: Union[str, "_models.MigrationConfigurationName"], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> 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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param config_name: The configuration name. Should always be "$default". "$default" Required. + :type config_name: str or + ~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigurationName + :param parameters: Parameters required to create Migration Configuration. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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: + """ @distributed_trace_async async def begin_create_and_start_migration( @@ -203,21 +291,26 @@ async def begin_create_and_start_migration( resource_group_name: str, namespace_name: str, config_name: Union[str, "_models.MigrationConfigurationName"], - parameters: _models.MigrationConfigProperties, + parameters: Union[_models.MigrationConfigProperties, IO], **kwargs: Any ) -> 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigurationName - :param parameters: Parameters required to create Migration Configuration. + :param parameters: Parameters required to create Migration Configuration. Is either a model + type or a IO type. Required. :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigProperties + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -230,20 +323,17 @@ async def begin_create_and_start_migration( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigProperties] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.MigrationConfigProperties] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MigrationConfigProperties] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + 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( # type: ignore resource_group_name=resource_group_name, @@ -252,39 +342,35 @@ async def begin_create_and_start_migration( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) + deserialized = self._deserialize("MigrationConfigProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, 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 + deserialization_callback=get_long_running_output, ) 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 + begin_create_and_start_migration.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -296,37 +382,34 @@ async def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes a MigrationConfiguration. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -334,10 +417,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -348,8 +430,7 @@ async def delete( # pylint: disable=inconsistent-return-statements 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( @@ -361,37 +442,34 @@ async def get( ) -> _models.MigrationConfigProperties: """Retrieves Migration Config. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :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) + :return: MigrationConfigProperties or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MigrationConfigProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MigrationConfigProperties] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -399,10 +477,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -410,15 +487,14 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) + 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 - + 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 @@ -432,37 +508,34 @@ async def complete_migration( # pylint: disable=inconsistent-return-statements 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.complete_migration.metadata["url"], headers=_headers, params=_params, ) @@ -470,10 +543,9 @@ async def complete_migration( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -484,8 +556,7 @@ async def complete_migration( # pylint: disable=inconsistent-return-statements 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 @distributed_trace_async async def revert( # pylint: disable=inconsistent-return-statements @@ -497,37 +568,34 @@ async def revert( # pylint: disable=inconsistent-return-statements ) -> None: """This operation reverts Migration. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.revert.metadata["url"], headers=_headers, params=_params, ) @@ -535,10 +603,9 @@ async def revert( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -549,5 +616,4 @@ async def revert( # pylint: disable=inconsistent-return-statements 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 dcf31ed61eff..9a6850506cfd 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 @@ -6,10 +6,17 @@ # 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, Optional, TypeVar, Union, cast +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +29,29 @@ 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') +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, + build_delete_authorization_rule_request, + build_delete_request, + 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]] + class NamespacesOperations: """ .. warning:: @@ -45,38 +71,32 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.SBNamespaceListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.SBNamespace"]: """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) + :return: An iterator like instance of either SBNamespace 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 + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBNamespace] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespaceListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -84,14 +104,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -107,10 +124,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -121,47 +136,39 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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, - **kwargs: Any - ) -> AsyncIterable[_models.SBNamespaceListResult]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.SBNamespace"]: """Gets the available namespaces within a resource group. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :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) + :return: An iterator like instance of either SBNamespace 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 + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBNamespace] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespaceListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -169,15 +176,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -193,10 +196,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -207,41 +208,40 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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, - resource_group_name: str, - namespace_name: str, - parameters: _models.SBNamespace, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, parameters: Union[_models.SBNamespace, IO], **kwargs: Any ) -> Optional[_models.SBNamespace]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.SBNamespace]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.SBNamespace]] - _json = self._serialize.body(parameters, 'SBNamespace') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBNamespace") - request = build_create_or_update_request_initial( + request = build_create_or_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._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) @@ -249,48 +249,121 @@ async def _create_or_update_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SBNamespace', pipeline_response) + 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 - + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - @distributed_trace_async + @overload async def begin_create_or_update( self, resource_group_name: str, namespace_name: str, parameters: _models.SBNamespace, + *, + content_type: str = "application/json", **kwargs: Any ) -> 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters supplied to create a namespace resource. + :param parameters: Parameters supplied to create a namespace resource. Required. :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBNamespace + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. + :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: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> 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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to create a namespace resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, resource_group_name: str, namespace_name: str, parameters: Union[_models.SBNamespace, IO], **kwargs: Any + ) -> 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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to create a namespace resource. Is either a model type + or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBNamespace or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -303,20 +376,17 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBNamespace] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespace] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBNamespace] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + 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( # type: ignore resource_group_name=resource_group_name, @@ -324,64 +394,54 @@ async def begin_create_or_update( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, 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 + deserialization_callback=get_long_running_output, ) 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 + 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, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_request_initial( + request = build_delete_request( 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'], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) @@ -389,35 +449,29 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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_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 @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete(self, resource_group_name: str, namespace_name: str, **kwargs: Any) -> 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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. @@ -429,92 +483,77 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + 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( # type: ignore resource_group_name=resource_group_name, namespace_name=namespace_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, 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 + deserialization_callback=get_long_running_output, ) 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 + 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, - namespace_name: str, - **kwargs: Any - ) -> _models.SBNamespace: + async def get(self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: SBNamespace or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBNamespace - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespace] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBNamespace] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -522,10 +561,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -533,51 +571,115 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBNamespace', pipeline_response) + 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 + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + @overload + async def update( + self, + resource_group_name: str, + namespace_name: str, + parameters: _models.SBNamespaceUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> 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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to update a namespace resource. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBNamespaceUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBNamespace or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBNamespace or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> 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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to update a namespace resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBNamespace or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBNamespace or None + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def update( self, resource_group_name: str, namespace_name: str, - parameters: _models.SBNamespaceUpdateParameters, + parameters: Union[_models.SBNamespaceUpdateParameters, IO], **kwargs: Any ) -> 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters supplied to update a namespace resource. + :param parameters: Parameters supplied to update a namespace resource. Is either a model type + or a IO type. Required. :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBNamespaceUpdateParameters + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBNamespace, or the result of cls(response) + :return: SBNamespace or None or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBNamespace or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.SBNamespace]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.SBNamespace]] - _json = self._serialize.body(parameters, 'SBNamespaceUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBNamespaceUpdateParameters") request = build_update_request( resource_group_name=resource_group_name, @@ -586,7 +688,8 @@ async def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -594,10 +697,9 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -607,53 +709,113 @@ async def update( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SBNamespace', pipeline_response) + 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 + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - - @distributed_trace_async + @overload async def create_or_update_network_rule_set( self, resource_group_name: str, namespace_name: str, parameters: _models.NetworkRuleSet, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.NetworkRuleSet: """Create or update NetworkRuleSet for a Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: The Namespace IpFilterRule. + :param parameters: The Namespace IpFilterRule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.NetworkRuleSet + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: NetworkRuleSet, or the result of cls(response) + :return: NetworkRuleSet or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.NetworkRuleSet - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + async def create_or_update_network_rule_set( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NetworkRuleSet: + """Create or update NetworkRuleSet for a Namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: The Namespace IpFilterRule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2021_06_01_preview.models.NetworkRuleSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_network_rule_set( + self, + resource_group_name: str, + namespace_name: str, + parameters: Union[_models.NetworkRuleSet, IO], + **kwargs: Any + ) -> _models.NetworkRuleSet: + """Create or update NetworkRuleSet for a Namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: The Namespace IpFilterRule. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.NetworkRuleSet or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2021_06_01_preview.models.NetworkRuleSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkRuleSet] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.NetworkRuleSet] - _json = self._serialize.body(parameters, 'NetworkRuleSet') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "NetworkRuleSet") request = build_create_or_update_network_rule_set_request( resource_group_name=resource_group_name, @@ -662,7 +824,8 @@ async def create_or_update_network_rule_set( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_network_rule_set.metadata['url'], + content=_content, + template_url=self.create_or_update_network_rule_set.metadata["url"], headers=_headers, params=_params, ) @@ -670,10 +833,9 @@ async def create_or_update_network_rule_set( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -681,52 +843,45 @@ async def create_or_update_network_rule_set( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('NetworkRuleSet', pipeline_response) + 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 - + 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, - namespace_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: NetworkRuleSet or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.NetworkRuleSet - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkRuleSet] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.NetworkRuleSet] - 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'], + template_url=self.get_network_rule_set.metadata["url"], headers=_headers, params=_params, ) @@ -734,10 +889,9 @@ async def get_network_rule_set( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -745,55 +899,49 @@ async def get_network_rule_set( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('NetworkRuleSet', pipeline_response) + 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 - + 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, - namespace_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.NetworkRuleSetListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.NetworkRuleSet"]: """Gets list of NetworkRuleSet for a Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: An iterator like instance of either NetworkRuleSet 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 + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.NetworkRuleSet] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkRuleSetListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_network_rule_sets.metadata["url"], headers=_headers, params=_params, ) @@ -801,16 +949,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -826,10 +969,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -840,51 +981,44 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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, - namespace_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SBAuthorizationRule"]: """Gets the authorization rules for a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: An iterator like instance of either SBAuthorizationRule 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 + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) @@ -892,16 +1026,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -917,10 +1046,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -931,49 +1058,115 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 + @overload async def create_or_update_authorization_rule( self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, parameters: _models.SBAuthorizationRule, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2021_06_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: Union[_models.SBAuthorizationRule, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2021_06_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - _json = self._serialize.body(parameters, 'SBAuthorizationRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBAuthorizationRule") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -983,7 +1176,8 @@ async def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -991,10 +1185,9 @@ async def create_or_update_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1002,56 +1195,48 @@ async def create_or_update_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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, - authorization_rule_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -1059,10 +1244,9 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1073,49 +1257,41 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat 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, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - 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'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -1123,10 +1299,9 @@ async def get_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1134,56 +1309,48 @@ async def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - 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'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1191,10 +1358,9 @@ async def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1202,54 +1368,122 @@ async def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys"} # type: ignore - - @distributed_trace_async + @overload async def regenerate_keys( self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, parameters: _models.RegenerateAccessKeyParameters, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.RegenerateAccessKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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.v2021_06_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace_async + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateAccessKeyParameters, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: + ~azure.mgmt.servicebus.v2021_06_01_preview.models.RegenerateAccessKeyParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2021_06_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateAccessKeyParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -1259,7 +1493,8 @@ async def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1267,10 +1502,9 @@ async def regenerate_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1278,51 +1512,91 @@ async def regenerate_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 + regenerate_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore + @overload + async def check_name_availability( + self, parameters: _models.CheckNameAvailability, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param parameters: Parameters to check availability of the given namespace name. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.CheckNameAvailability + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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.v2021_06_01_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param parameters: Parameters to check availability of the given namespace name. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :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.v2021_06_01_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def check_name_availability( - self, - parameters: _models.CheckNameAvailability, - **kwargs: Any + self, parameters: Union[_models.CheckNameAvailability, IO], **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Check the give namespace name availability. - :param parameters: Parameters to check availability of the given namespace name. - :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.CheckNameAvailability + :param parameters: Parameters to check availability of the given namespace name. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.CheckNameAvailability or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameAvailabilityResult, or the result of cls(response) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResult] - _json = self._serialize.body(parameters, 'CheckNameAvailability') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _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'], + content=_content, + template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) @@ -1330,10 +1604,9 @@ async def check_name_availability( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1341,12 +1614,11 @@ async def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + 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 - + 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 abe0a4cf460c..fd5804a6fe4a 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 @@ -7,9 +7,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +27,11 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class Operations: """ .. warning:: @@ -42,36 +51,31 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.OperationListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """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) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -79,13 +83,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -101,10 +103,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -115,8 +115,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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/_patch.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_patch.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/aio/operations/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. 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 c02180611329..523eed5b5edc 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 @@ -6,10 +6,17 @@ # 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, Optional, TypeVar, Union, cast +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +29,17 @@ 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') +from ...operations._private_endpoint_connections_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class PrivateEndpointConnectionsOperations: """ .. warning:: @@ -45,46 +59,41 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.PrivateEndpointConnectionListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PrivateEndpointConnection"]: """Gets the available PrivateEndpointConnections within a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: An iterator like instance of either PrivateEndpointConnection 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 + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnectionListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -92,16 +101,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -117,10 +121,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -131,60 +133,129 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 + @overload async def create_or_update( self, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, parameters: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.PrivateEndpointConnection: """Creates or updates PrivateEndpointConnections of service namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param private_endpoint_connection_name: The PrivateEndpointConnection name. + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. :type private_endpoint_connection_name: str :param parameters: Parameters supplied to update Status of PrivateEndPoint Connection to - namespace resource. + namespace resource. Required. :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.PrivateEndpointConnection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateEndpointConnection, or the result of cls(response) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Creates or updates PrivateEndpointConnections of service namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. + :type private_endpoint_connection_name: str + :param parameters: Parameters supplied to update Status of PrivateEndPoint Connection to + namespace resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2021_06_01_preview.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + parameters: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Creates or updates PrivateEndpointConnections of service namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. + :type private_endpoint_connection_name: str + :param parameters: Parameters supplied to update Status of PrivateEndPoint Connection to + namespace resource. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.PrivateEndpointConnection + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2021_06_01_preview.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - _json = self._serialize.body(parameters, 'PrivateEndpointConnection') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _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, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -192,10 +263,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -204,45 +274,37 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + 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 - + 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, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_request_initial( + request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, - subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) @@ -250,37 +312,32 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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_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 @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes an existing Private Endpoint Connection. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param private_endpoint_connection_name: The PrivateEndpointConnection name. + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. :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. @@ -292,97 +349,83 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + 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( # type: ignore 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, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, 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 + deserialization_callback=get_long_running_output, ) 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 + 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, - namespace_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param private_endpoint_connection_name: The PrivateEndpointConnection name. + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. :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) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -390,10 +433,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -401,12 +443,11 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + 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 - + 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 aa5401e310a1..b60ff6abcee3 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 @@ -8,7 +8,13 @@ # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Optional, TypeVar -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -19,9 +25,11 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._private_link_resources_operations import build_get_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class PrivateLinkResourcesOperations: """ .. warning:: @@ -41,43 +49,36 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async async def get( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: PrivateLinkResourcesListResult or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.PrivateLinkResourcesListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourcesListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResourcesListResult] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -85,10 +86,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -96,12 +96,11 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateLinkResourcesListResult', pipeline_response) + 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 - + 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 d97a7cbc3044..a5157f4eb94c 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 @@ -6,10 +6,17 @@ # 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, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +27,23 @@ 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') +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]] + class QueuesOperations: """ .. warning:: @@ -43,50 +63,43 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, queue_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SBAuthorizationRule"]: """Gets all authorization rules for a queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :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) + :return: An iterator like instance of either SBAuthorizationRule 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 + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) @@ -94,17 +107,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -120,10 +127,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -134,13 +139,11 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 + @overload async def create_or_update_authorization_rule( self, resource_group_name: str, @@ -148,38 +151,112 @@ async def create_or_update_authorization_rule( queue_name: str, authorization_rule_name: str, parameters: _models.SBAuthorizationRule, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBAuthorizationRule: """Creates an authorization rule for a queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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.v2021_06_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for a queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace_async + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: Union[_models.SBAuthorizationRule, IO], + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for a queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2021_06_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - _json = self._serialize.body(parameters, 'SBAuthorizationRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBAuthorizationRule") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -190,7 +267,8 @@ async def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -198,10 +276,9 @@ async def create_or_update_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -209,15 +286,14 @@ async def create_or_update_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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 @@ -230,31 +306,28 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat ) -> None: """Deletes a queue authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -262,7 +335,7 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_authorization_rule.metadata['url'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -270,10 +343,9 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -284,8 +356,7 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat 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( @@ -298,31 +369,28 @@ async def get_authorization_rule( ) -> _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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -330,7 +398,7 @@ async def get_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -338,10 +406,9 @@ async def get_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -349,15 +416,14 @@ async def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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( @@ -370,31 +436,28 @@ async def list_keys( ) -> _models.AccessKeys: """Primary and secondary connection strings to the queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -402,7 +465,7 @@ async def list_keys( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -410,10 +473,9 @@ async def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -421,17 +483,16 @@ async def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 - + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore - @distributed_trace_async + @overload async def regenerate_keys( self, resource_group_name: str, @@ -439,39 +500,114 @@ async def regenerate_keys( queue_name: str, authorization_rule_name: str, parameters: _models.RegenerateAccessKeyParameters, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.RegenerateAccessKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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.v2021_06_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2021_06_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateAccessKeyParameters, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: + ~azure.mgmt.servicebus.v2021_06_01_preview.models.RegenerateAccessKeyParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateAccessKeyParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -482,7 +618,8 @@ async def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) @@ -490,10 +627,9 @@ async def regenerate_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -501,15 +637,14 @@ async def regenerate_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 - + 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( @@ -519,12 +654,12 @@ def list_by_namespace( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable[_models.SBQueueListResult]: + ) -> AsyncIterable["_models.SBQueue"]: """Gets the queues within a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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 @@ -534,32 +669,31 @@ def list_by_namespace( 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) + :return: An iterator like instance of either SBQueue or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBQueueListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBQueue] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBQueueListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + api_version=api_version, + template_url=self.list_by_namespace.metadata["url"], headers=_headers, params=_params, ) @@ -567,18 +701,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -594,10 +721,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -608,49 +733,115 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 + @overload async def create_or_update( self, resource_group_name: str, namespace_name: str, queue_name: str, parameters: _models.SBQueue, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param parameters: Parameters supplied to create or update a queue resource. + :param parameters: Parameters supplied to create or update a queue resource. Required. :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBQueue + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBQueue, or the result of cls(response) + :return: SBQueue or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param parameters: Parameters supplied to create or update a queue resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2021_06_01_preview.models.SBQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + parameters: Union[_models.SBQueue, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param parameters: Parameters supplied to create or update a queue resource. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBQueue or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2021_06_01_preview.models.SBQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBQueue] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBQueue] - _json = self._serialize.body(parameters, 'SBQueue') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBQueue") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -660,7 +851,8 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -668,10 +860,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -679,56 +870,48 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBQueue', pipeline_response) + 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 - + 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, - queue_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -736,10 +919,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -750,49 +932,41 @@ async def delete( # pylint: disable=inconsistent-return-statements 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, - namespace_name: str, - queue_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :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) + :return: SBQueue or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBQueue] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBQueue] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -800,10 +974,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -811,12 +984,11 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBQueue', pipeline_response) + 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 - + 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 50be288b6037..35379dcf750c 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 @@ -6,10 +6,17 @@ # 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, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +27,17 @@ 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') +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]] + class RulesOperations: """ .. warning:: @@ -43,7 +57,6 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_by_subscriptions( self, @@ -54,16 +67,16 @@ def list_by_subscriptions( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable[_models.RuleListResult]: + ) -> AsyncIterable["_models.Rule"]: """List all the rules within given topic-subscription. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :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 @@ -73,34 +86,33 @@ def list_by_subscriptions( 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) + :return: An iterator like instance of either Rule or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.RuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.Rule] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.RuleListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + api_version=api_version, + template_url=self.list_by_subscriptions.metadata["url"], headers=_headers, params=_params, ) @@ -108,20 +120,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -137,10 +140,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -151,13 +152,11 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 + @overload async def create_or_update( self, resource_group_name: str, @@ -166,40 +165,120 @@ async def create_or_update( subscription_name: str, rule_name: str, parameters: _models.Rule, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param rule_name: The rule name. + :param rule_name: The rule name. Required. :type rule_name: str - :param parameters: Parameters supplied to create a rule. + :param parameters: Parameters supplied to create a rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.Rule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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.v2021_06_01_preview.models.Rule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param rule_name: The rule name. Required. + :type rule_name: str + :param parameters: Parameters supplied to create a rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2021_06_01_preview.models.Rule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + parameters: Union[_models.Rule, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param rule_name: The rule name. Required. + :type rule_name: str + :param parameters: Parameters supplied to create a rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.Rule or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Rule, or the result of cls(response) + :return: Rule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.Rule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Rule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Rule] - _json = self._serialize.body(parameters, 'Rule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Rule") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -211,7 +290,8 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -219,10 +299,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -230,15 +309,14 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Rule', pipeline_response) + 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 - + 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 @@ -252,33 +330,30 @@ async def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes an existing rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param rule_name: The rule name. + :param rule_name: The rule name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -287,7 +362,7 @@ async def delete( # pylint: disable=inconsistent-return-statements rule_name=rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -295,10 +370,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -309,8 +383,7 @@ async def delete( # pylint: disable=inconsistent-return-statements 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( @@ -324,33 +397,30 @@ async def get( ) -> _models.Rule: """Retrieves the description for the specified rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param rule_name: The rule name. + :param rule_name: The rule name. Required. :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) + :return: Rule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.Rule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Rule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Rule] - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -359,7 +429,7 @@ async def get( rule_name=rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -367,10 +437,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -378,12 +447,11 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Rule', pipeline_response) + 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 - + 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 7c336657b705..e9a807d61d50 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 @@ -6,10 +6,17 @@ # 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, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +27,17 @@ 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') +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]] + class SubscriptionsOperations: """ .. warning:: @@ -43,7 +57,6 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_by_topic( self, @@ -53,14 +66,14 @@ def list_by_topic( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable[_models.SBSubscriptionListResult]: + ) -> AsyncIterable["_models.SBSubscription"]: """List all the subscriptions under a specified topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :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 @@ -70,34 +83,32 @@ def list_by_topic( 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) + :return: An iterator like instance of either SBSubscription 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 + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBSubscription] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBSubscriptionListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + api_version=api_version, + template_url=self.list_by_topic.metadata["url"], headers=_headers, params=_params, ) @@ -105,19 +116,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -133,10 +136,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -147,13 +148,11 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 + @overload async def create_or_update( self, resource_group_name: str, @@ -161,38 +160,112 @@ async def create_or_update( topic_name: str, subscription_name: str, parameters: _models.SBSubscription, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBSubscription: """Creates a topic subscription. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param parameters: Parameters supplied to create a subscription resource. + :param parameters: Parameters supplied to create a subscription resource. Required. :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBSubscription + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBSubscription, or the result of cls(response) + :return: SBSubscription or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBSubscription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBSubscription: + """Creates a topic subscription. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param parameters: Parameters supplied to create a subscription resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2021_06_01_preview.models.SBSubscription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + parameters: Union[_models.SBSubscription, IO], + **kwargs: Any + ) -> _models.SBSubscription: + """Creates a topic subscription. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param parameters: Parameters supplied to create a subscription resource. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBSubscription or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2021_06_01_preview.models.SBSubscription + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBSubscription] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBSubscription] - _json = self._serialize.body(parameters, 'SBSubscription') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBSubscription") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -203,7 +276,8 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -211,10 +285,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -222,52 +295,43 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBSubscription', pipeline_response) + 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 - + 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, - topic_name: str, - subscription_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -275,7 +339,7 @@ async def delete( # pylint: disable=inconsistent-return-statements subscription_name=subscription_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -283,10 +347,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -297,45 +360,36 @@ async def delete( # pylint: disable=inconsistent-return-statements 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, - namespace_name: str, - topic_name: str, - subscription_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :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) + :return: SBSubscription or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBSubscription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBSubscription] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBSubscription] - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -343,7 +397,7 @@ async def get( subscription_name=subscription_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -351,10 +405,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -362,12 +415,11 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBSubscription', pipeline_response) + 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 - + 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 c55bd895d94e..a0abbe6f2418 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 @@ -6,10 +6,17 @@ # 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, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +27,23 @@ 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') +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]] + class TopicsOperations: """ .. warning:: @@ -43,50 +63,43 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, topic_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SBAuthorizationRule"]: """Gets authorization rules for a topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :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) + :return: An iterator like instance of either SBAuthorizationRule 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 + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) @@ -94,17 +107,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -120,10 +127,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -134,13 +139,11 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 + @overload async def create_or_update_authorization_rule( self, resource_group_name: str, @@ -148,38 +151,112 @@ async def create_or_update_authorization_rule( topic_name: str, authorization_rule_name: str, parameters: _models.SBAuthorizationRule, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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.v2021_06_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace_async + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: Union[_models.SBAuthorizationRule, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2021_06_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - _json = self._serialize.body(parameters, 'SBAuthorizationRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBAuthorizationRule") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -190,7 +267,8 @@ async def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -198,10 +276,9 @@ async def create_or_update_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -209,15 +286,14 @@ async def create_or_update_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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( @@ -230,31 +306,28 @@ async def get_authorization_rule( ) -> _models.SBAuthorizationRule: """Returns the specified authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -262,7 +335,7 @@ async def get_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -270,10 +343,9 @@ async def get_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -281,15 +353,14 @@ async def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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 @@ -302,31 +373,28 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat ) -> None: """Deletes a topic authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -334,7 +402,7 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_authorization_rule.metadata['url'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -342,10 +410,9 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -356,8 +423,7 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat 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( @@ -370,31 +436,28 @@ async def list_keys( ) -> _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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -402,7 +465,7 @@ async def list_keys( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -410,10 +473,9 @@ async def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -421,17 +483,16 @@ async def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 - + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore - @distributed_trace_async + @overload async def regenerate_keys( self, resource_group_name: str, @@ -439,39 +500,114 @@ async def regenerate_keys( topic_name: str, authorization_rule_name: str, parameters: _models.RegenerateAccessKeyParameters, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.RegenerateAccessKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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.v2021_06_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2021_06_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateAccessKeyParameters, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: + ~azure.mgmt.servicebus.v2021_06_01_preview.models.RegenerateAccessKeyParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateAccessKeyParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -482,7 +618,8 @@ async def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) @@ -490,10 +627,9 @@ async def regenerate_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -501,15 +637,14 @@ async def regenerate_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 - + 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( @@ -519,12 +654,12 @@ def list_by_namespace( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable[_models.SBTopicListResult]: + ) -> AsyncIterable["_models.SBTopic"]: """Gets all the topics in a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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 @@ -534,32 +669,31 @@ def list_by_namespace( 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) + :return: An iterator like instance of either SBTopic or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBTopicListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBTopic] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBTopicListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + api_version=api_version, + template_url=self.list_by_namespace.metadata["url"], headers=_headers, params=_params, ) @@ -567,18 +701,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -594,10 +721,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -608,49 +733,115 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 + @overload async def create_or_update( self, resource_group_name: str, namespace_name: str, topic_name: str, parameters: _models.SBTopic, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBTopic: """Creates a topic in the specified namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param parameters: Parameters supplied to create a topic resource. + :param parameters: Parameters supplied to create a topic resource. Required. :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBTopic + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBTopic, or the result of cls(response) + :return: SBTopic or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBTopic - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBTopic: + """Creates a topic in the specified namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param parameters: Parameters supplied to create a topic resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2021_06_01_preview.models.SBTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + parameters: Union[_models.SBTopic, IO], + **kwargs: Any + ) -> _models.SBTopic: + """Creates a topic in the specified namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param parameters: Parameters supplied to create a topic resource. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBTopic or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2021_06_01_preview.models.SBTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBTopic] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBTopic] - _json = self._serialize.body(parameters, 'SBTopic') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBTopic") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -660,7 +851,8 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -668,10 +860,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -679,56 +870,48 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBTopic', pipeline_response) + 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 - + 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, - topic_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -736,10 +919,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -750,49 +932,41 @@ async def delete( # pylint: disable=inconsistent-return-statements 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, - namespace_name: str, - topic_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :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) + :return: SBTopic or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBTopic - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBTopic] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBTopic] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -800,10 +974,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -811,12 +984,11 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBTopic', pipeline_response) + 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 - + 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 0c388e2dc7f2..3a1e02213eaa 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 @@ -62,102 +62,100 @@ from ._models_py3 import UserAssignedIdentity from ._models_py3 import UserAssignedIdentityProperties - -from ._service_bus_management_client_enums import ( - AccessRights, - CreatedByType, - DefaultAction, - EndPointProvisioningState, - EntityStatus, - FilterType, - KeyType, - ManagedServiceIdentityType, - MigrationConfigurationName, - NetworkRuleIPAction, - PrivateLinkConnectionStatus, - ProvisioningStateDR, - PublicNetworkAccessFlag, - RoleDisasterRecovery, - SkuName, - SkuTier, - UnavailableReason, -) +from ._service_bus_management_client_enums import AccessRights +from ._service_bus_management_client_enums import CreatedByType +from ._service_bus_management_client_enums import DefaultAction +from ._service_bus_management_client_enums import EndPointProvisioningState +from ._service_bus_management_client_enums import EntityStatus +from ._service_bus_management_client_enums import FilterType +from ._service_bus_management_client_enums import KeyType +from ._service_bus_management_client_enums import ManagedServiceIdentityType +from ._service_bus_management_client_enums import MigrationConfigurationName +from ._service_bus_management_client_enums import NetworkRuleIPAction +from ._service_bus_management_client_enums import PrivateLinkConnectionStatus +from ._service_bus_management_client_enums import ProvisioningStateDR +from ._service_bus_management_client_enums import PublicNetworkAccessFlag +from ._service_bus_management_client_enums import RoleDisasterRecovery +from ._service_bus_management_client_enums import SkuName +from ._service_bus_management_client_enums import SkuTier +from ._service_bus_management_client_enums import UnavailableReason from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'AccessKeys', - 'Action', - 'ArmDisasterRecovery', - 'ArmDisasterRecoveryListResult', - 'CheckNameAvailability', - 'CheckNameAvailabilityResult', - 'ConnectionState', - 'CorrelationFilter', - 'Encryption', - 'ErrorAdditionalInfo', - 'ErrorResponse', - 'ErrorResponseError', - 'FailoverProperties', - 'Identity', - 'KeyVaultProperties', - 'MessageCountDetails', - 'MigrationConfigListResult', - 'MigrationConfigProperties', - 'NWRuleSetIpRules', - 'NWRuleSetVirtualNetworkRules', - 'NetworkRuleSet', - 'NetworkRuleSetListResult', - 'Operation', - 'OperationDisplay', - 'OperationListResult', - 'PrivateEndpoint', - 'PrivateEndpointConnection', - 'PrivateEndpointConnectionListResult', - 'PrivateLinkResource', - 'PrivateLinkResourcesListResult', - 'RegenerateAccessKeyParameters', - 'Resource', - 'ResourceNamespacePatch', - 'Rule', - 'RuleListResult', - 'SBAuthorizationRule', - 'SBAuthorizationRuleListResult', - 'SBClientAffineProperties', - 'SBNamespace', - 'SBNamespaceListResult', - 'SBNamespaceUpdateParameters', - 'SBQueue', - 'SBQueueListResult', - 'SBSku', - 'SBSubscription', - 'SBSubscriptionListResult', - 'SBTopic', - 'SBTopicListResult', - 'SqlFilter', - 'SqlRuleAction', - 'Subnet', - 'SystemData', - 'TrackedResource', - 'UserAssignedIdentity', - 'UserAssignedIdentityProperties', - 'AccessRights', - 'CreatedByType', - 'DefaultAction', - 'EndPointProvisioningState', - 'EntityStatus', - 'FilterType', - 'KeyType', - 'ManagedServiceIdentityType', - 'MigrationConfigurationName', - 'NetworkRuleIPAction', - 'PrivateLinkConnectionStatus', - 'ProvisioningStateDR', - 'PublicNetworkAccessFlag', - 'RoleDisasterRecovery', - 'SkuName', - 'SkuTier', - 'UnavailableReason', + "AccessKeys", + "Action", + "ArmDisasterRecovery", + "ArmDisasterRecoveryListResult", + "CheckNameAvailability", + "CheckNameAvailabilityResult", + "ConnectionState", + "CorrelationFilter", + "Encryption", + "ErrorAdditionalInfo", + "ErrorResponse", + "ErrorResponseError", + "FailoverProperties", + "Identity", + "KeyVaultProperties", + "MessageCountDetails", + "MigrationConfigListResult", + "MigrationConfigProperties", + "NWRuleSetIpRules", + "NWRuleSetVirtualNetworkRules", + "NetworkRuleSet", + "NetworkRuleSetListResult", + "Operation", + "OperationDisplay", + "OperationListResult", + "PrivateEndpoint", + "PrivateEndpointConnection", + "PrivateEndpointConnectionListResult", + "PrivateLinkResource", + "PrivateLinkResourcesListResult", + "RegenerateAccessKeyParameters", + "Resource", + "ResourceNamespacePatch", + "Rule", + "RuleListResult", + "SBAuthorizationRule", + "SBAuthorizationRuleListResult", + "SBClientAffineProperties", + "SBNamespace", + "SBNamespaceListResult", + "SBNamespaceUpdateParameters", + "SBQueue", + "SBQueueListResult", + "SBSku", + "SBSubscription", + "SBSubscriptionListResult", + "SBTopic", + "SBTopicListResult", + "SqlFilter", + "SqlRuleAction", + "Subnet", + "SystemData", + "TrackedResource", + "UserAssignedIdentity", + "UserAssignedIdentityProperties", + "AccessRights", + "CreatedByType", + "DefaultAction", + "EndPointProvisioningState", + "EntityStatus", + "FilterType", + "KeyType", + "ManagedServiceIdentityType", + "MigrationConfigurationName", + "NetworkRuleIPAction", + "PrivateLinkConnectionStatus", + "ProvisioningStateDR", + "PublicNetworkAccessFlag", + "RoleDisasterRecovery", + "SkuName", + "SkuTier", + "UnavailableReason", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() 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 9e3cdc61ff72..ccdd839ef3c8 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 @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -9,15 +10,14 @@ import datetime from typing import Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - import __init__ as _models + from .. import models as _models -class AccessKeys(msrest.serialization.Model): +class AccessKeys(_serialization.Model): """Namespace/ServiceBus Connection String. Variables are only populated by the server, and will be ignored when sending a request. @@ -45,32 +45,28 @@ class AccessKeys(msrest.serialization.Model): """ _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}, + "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) + "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().__init__(**kwargs) self.primary_connection_string = None self.secondary_connection_string = None self.alias_primary_connection_string = None @@ -80,7 +76,7 @@ def __init__( self.key_name = None -class Action(msrest.serialization.Model): +class Action(_serialization.Model): """Represents the filter actions which are allowed for the transformation of a message that have been matched by a filter expression. :ivar sql_expression: SQL expression. e.g. MyProperty='ABC'. @@ -94,9 +90,9 @@ class Action(msrest.serialization.Model): """ _attribute_map = { - 'sql_expression': {'key': 'sqlExpression', 'type': 'str'}, - 'compatibility_level': {'key': 'compatibilityLevel', 'type': 'int'}, - 'requires_preprocessing': {'key': 'requiresPreprocessing', 'type': 'bool'}, + "sql_expression": {"key": "sqlExpression", "type": "str"}, + "compatibility_level": {"key": "compatibilityLevel", "type": "int"}, + "requires_preprocessing": {"key": "requiresPreprocessing", "type": "bool"}, } def __init__( @@ -104,7 +100,7 @@ def __init__( *, sql_expression: Optional[str] = None, compatibility_level: Optional[int] = None, - requires_preprocessing: Optional[bool] = True, + requires_preprocessing: bool = True, **kwargs ): """ @@ -117,13 +113,13 @@ def __init__( preprocessing. :paramtype requires_preprocessing: bool """ - super(Action, self).__init__(**kwargs) + super().__init__(**kwargs) self.sql_expression = sql_expression self.compatibility_level = compatibility_level self.requires_preprocessing = requires_preprocessing -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """The Resource definition for other than namespace. Variables are only populated by the server, and will be ignored when sending a request. @@ -137,24 +133,20 @@ class Resource(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "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'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Resource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -175,11 +167,11 @@ class ArmDisasterRecovery(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'. Known values are: "Accepted", - "Succeeded", "Failed". + "Succeeded", and "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 + :vartype pending_replication_operations_count: int :ivar partner_namespace: ARM Id of the Primary/Secondary eventhub namespace name, which is part of GEO DR pairing. :vartype partner_namespace: str @@ -187,39 +179,33 @@ class ArmDisasterRecovery(Resource): pairing. :vartype alternate_name: str :ivar role: role of namespace in GEO DR - possible values 'Primary' or 'PrimaryNotReplicating' - or 'Secondary'. Known values are: "Primary", "PrimaryNotReplicating", "Secondary". + or 'Secondary'. Known values are: "Primary", "PrimaryNotReplicating", and "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}, + "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'}, + "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": "int"}, + "partner_namespace": {"key": "properties.partnerNamespace", "type": "str"}, + "alternate_name": {"key": "properties.alternateName", "type": "str"}, + "role": {"key": "properties.role", "type": "str"}, } - def __init__( - self, - *, - partner_namespace: Optional[str] = None, - alternate_name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, partner_namespace: Optional[str] = None, 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. @@ -228,7 +214,7 @@ def __init__( pairing. :paramtype alternate_name: str """ - super(ArmDisasterRecovery, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.provisioning_state = None self.pending_replication_operations_count = None @@ -237,7 +223,7 @@ def __init__( self.role = None -class ArmDisasterRecoveryListResult(msrest.serialization.Model): +class ArmDisasterRecoveryListResult(_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. @@ -250,65 +236,55 @@ class ArmDisasterRecoveryListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ArmDisasterRecovery]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ArmDisasterRecovery]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.ArmDisasterRecovery"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.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) + super().__init__(**kwargs) self.value = value self.next_link = None -class CheckNameAvailability(msrest.serialization.Model): +class CheckNameAvailability(_serialization.Model): """Description of a Check Name availability request properties. All required parameters must be populated in order to send to Azure. - :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. + :ivar name: 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. Required. :vartype name: str """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - name: str, - **kwargs - ): + def __init__(self, *, 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. + :keyword name: 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. Required. :paramtype name: str """ - super(CheckNameAvailability, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class CheckNameAvailabilityResult(msrest.serialization.Model): +class CheckNameAvailabilityResult(_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. @@ -319,19 +295,19 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): available; otherwise, false. :vartype name_available: bool :ivar reason: The reason for unavailability of a namespace. Known values are: "None", - "InvalidName", "SubscriptionIsDisabled", "NameInUse", "NameInLockdown", + "InvalidName", "SubscriptionIsDisabled", "NameInUse", "NameInLockdown", and "TooManyNamespaceInCurrentSubscription". :vartype reason: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.UnavailableReason """ _validation = { - 'message': {'readonly': True}, + "message": {"readonly": True}, } _attribute_map = { - 'message': {'key': 'message', 'type': 'str'}, - 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, - 'reason': {'key': 'reason', 'type': 'str'}, + "message": {"key": "message", "type": "str"}, + "name_available": {"key": "nameAvailable", "type": "bool"}, + "reason": {"key": "reason", "type": "str"}, } def __init__( @@ -346,21 +322,21 @@ def __init__( available; otherwise, false. :paramtype name_available: bool :keyword reason: The reason for unavailability of a namespace. Known values are: "None", - "InvalidName", "SubscriptionIsDisabled", "NameInUse", "NameInLockdown", + "InvalidName", "SubscriptionIsDisabled", "NameInUse", "NameInLockdown", and "TooManyNamespaceInCurrentSubscription". :paramtype reason: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.UnavailableReason """ - super(CheckNameAvailabilityResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.message = None self.name_available = name_available self.reason = reason -class ConnectionState(msrest.serialization.Model): +class ConnectionState(_serialization.Model): """ConnectionState information. :ivar status: Status of the connection. Known values are: "Pending", "Approved", "Rejected", - "Disconnected". + and "Disconnected". :vartype status: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.PrivateLinkConnectionStatus :ivar description: Description of the connection state. @@ -368,8 +344,8 @@ class ConnectionState(msrest.serialization.Model): """ _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "status": {"key": "status", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -381,18 +357,18 @@ def __init__( ): """ :keyword status: Status of the connection. Known values are: "Pending", "Approved", "Rejected", - "Disconnected". + and "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) + super().__init__(**kwargs) self.status = status self.description = description -class CorrelationFilter(msrest.serialization.Model): +class CorrelationFilter(_serialization.Model): """Represents the correlation filter expression. :ivar properties: dictionary object for custom filters. @@ -419,16 +395,16 @@ class CorrelationFilter(msrest.serialization.Model): """ _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'}, + "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__( @@ -443,7 +419,7 @@ def __init__( session_id: Optional[str] = None, reply_to_session_id: Optional[str] = None, content_type: Optional[str] = None, - requires_preprocessing: Optional[bool] = True, + requires_preprocessing: bool = True, **kwargs ): """ @@ -469,7 +445,7 @@ def __init__( preprocessing. :paramtype requires_preprocessing: bool """ - super(CorrelationFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.correlation_id = correlation_id self.message_id = message_id @@ -482,14 +458,13 @@ def __init__( self.requires_preprocessing = requires_preprocessing -class Encryption(msrest.serialization.Model): +class Encryption(_serialization.Model): """Properties to configure Encryption. :ivar key_vault_properties: Properties of KeyVault. :vartype key_vault_properties: list[~azure.mgmt.servicebus.v2021_06_01_preview.models.KeyVaultProperties] - :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 + :ivar key_source: Enumerates the possible value of keySource for Encryption. Default value is "Microsoft.KeyVault". :vartype key_source: str :ivar require_infrastructure_encryption: Enable Infrastructure Encryption (Double Encryption). @@ -497,16 +472,16 @@ class Encryption(msrest.serialization.Model): """ _attribute_map = { - 'key_vault_properties': {'key': 'keyVaultProperties', 'type': '[KeyVaultProperties]'}, - 'key_source': {'key': 'keySource', 'type': 'str'}, - 'require_infrastructure_encryption': {'key': 'requireInfrastructureEncryption', 'type': 'bool'}, + "key_vault_properties": {"key": "keyVaultProperties", "type": "[KeyVaultProperties]"}, + "key_source": {"key": "keySource", "type": "str"}, + "require_infrastructure_encryption": {"key": "requireInfrastructureEncryption", "type": "bool"}, } def __init__( self, *, key_vault_properties: Optional[List["_models.KeyVaultProperties"]] = None, - key_source: Optional[str] = "Microsoft.KeyVault", + key_source: str = "Microsoft.KeyVault", require_infrastructure_encryption: Optional[bool] = None, **kwargs ): @@ -514,21 +489,20 @@ def __init__( :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". + :keyword key_source: Enumerates the possible value of keySource for Encryption. 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) + super().__init__(**kwargs) self.key_vault_properties = key_vault_properties self.key_source = key_source self.require_infrastructure_encryption = require_infrastructure_encryption -class ErrorAdditionalInfo(msrest.serialization.Model): +class ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. Variables are only populated by the server, and will be ignored when sending a request. @@ -536,31 +510,27 @@ class ErrorAdditionalInfo(msrest.serialization.Model): :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. - :vartype info: any + :vartype info: JSON """ _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, + "type": {"readonly": True}, + "info": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorAdditionalInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.info = None -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """The resource management error response. :ivar error: The error object. @@ -568,24 +538,19 @@ class ErrorResponse(msrest.serialization.Model): """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponseError'}, + "error": {"key": "error", "type": "ErrorResponseError"}, } - def __init__( - self, - *, - error: Optional["_models.ErrorResponseError"] = None, - **kwargs - ): + def __init__(self, *, error: Optional["_models.ErrorResponseError"] = None, **kwargs): """ :keyword error: The error object. :paramtype error: ~azure.mgmt.servicebus.v2021_06_01_preview.models.ErrorResponseError """ - super(ErrorResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error -class ErrorResponseError(msrest.serialization.Model): +class ErrorResponseError(_serialization.Model): """The error object. Variables are only populated by the server, and will be ignored when sending a request. @@ -604,28 +569,24 @@ class ErrorResponseError(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, + "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]'}, + "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) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.message = None self.target = None @@ -633,7 +594,7 @@ def __init__( self.additional_info = None -class FailoverProperties(msrest.serialization.Model): +class FailoverProperties(_serialization.Model): """Safe failover is to indicate the service should wait for pending replication to finish before switching to the secondary. :ivar is_safe_failover: Safe failover is to indicate the service should wait for pending @@ -642,25 +603,20 @@ class FailoverProperties(msrest.serialization.Model): """ _attribute_map = { - 'is_safe_failover': {'key': 'properties.IsSafeFailover', 'type': 'bool'}, + "is_safe_failover": {"key": "properties.IsSafeFailover", "type": "bool"}, } - def __init__( - self, - *, - is_safe_failover: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, 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) + super().__init__(**kwargs) self.is_safe_failover = is_safe_failover -class Identity(msrest.serialization.Model): +class Identity(_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. @@ -670,7 +626,7 @@ class Identity(msrest.serialization.Model): :ivar tenant_id: TenantId from the KeyVault. :vartype tenant_id: str :ivar type: Type of managed service identity. Known values are: "SystemAssigned", - "UserAssigned", "SystemAssigned, UserAssigned", "None". + "UserAssigned", "SystemAssigned, UserAssigned", and "None". :vartype type: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.ManagedServiceIdentityType :ivar user_assigned_identities: Properties for User Assigned Identities. @@ -679,15 +635,15 @@ class Identity(msrest.serialization.Model): """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, + "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}'}, + "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__( @@ -699,21 +655,21 @@ def __init__( ): """ :keyword type: Type of managed service identity. Known values are: "SystemAssigned", - "UserAssigned", "SystemAssigned, UserAssigned", "None". + "UserAssigned", "SystemAssigned, UserAssigned", and "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) + super().__init__(**kwargs) self.principal_id = None self.tenant_id = None self.type = type self.user_assigned_identities = user_assigned_identities -class KeyVaultProperties(msrest.serialization.Model): +class KeyVaultProperties(_serialization.Model): """Properties to configure keyVault Properties. :ivar key_name: Name of the Key from KeyVault. @@ -728,10 +684,10 @@ class KeyVaultProperties(msrest.serialization.Model): """ _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'}, + "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__( @@ -754,54 +710,50 @@ def __init__( :paramtype identity: ~azure.mgmt.servicebus.v2021_06_01_preview.models.UserAssignedIdentityProperties """ - super(KeyVaultProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_name = key_name self.key_vault_uri = key_vault_uri self.key_version = key_version self.identity = identity -class MessageCountDetails(msrest.serialization.Model): +class MessageCountDetails(_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 + :vartype active_message_count: int :ivar dead_letter_message_count: Number of messages that are dead lettered. - :vartype dead_letter_message_count: long + :vartype dead_letter_message_count: int :ivar scheduled_message_count: Number of scheduled messages. - :vartype scheduled_message_count: long + :vartype scheduled_message_count: int :ivar transfer_message_count: Number of messages transferred to another queue, topic, or subscription. - :vartype transfer_message_count: long + :vartype transfer_message_count: int :ivar transfer_dead_letter_message_count: Number of messages transferred into dead letters. - :vartype transfer_dead_letter_message_count: long + :vartype transfer_dead_letter_message_count: int """ _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}, + "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'}, + "active_message_count": {"key": "activeMessageCount", "type": "int"}, + "dead_letter_message_count": {"key": "deadLetterMessageCount", "type": "int"}, + "scheduled_message_count": {"key": "scheduledMessageCount", "type": "int"}, + "transfer_message_count": {"key": "transferMessageCount", "type": "int"}, + "transfer_dead_letter_message_count": {"key": "transferDeadLetterMessageCount", "type": "int"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(MessageCountDetails, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.active_message_count = None self.dead_letter_message_count = None self.scheduled_message_count = None @@ -809,7 +761,7 @@ def __init__( self.transfer_dead_letter_message_count = None -class MigrationConfigListResult(msrest.serialization.Model): +class MigrationConfigListResult(_serialization.Model): """The result of the List migrationConfigurations operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -823,26 +775,21 @@ class MigrationConfigListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[MigrationConfigProperties]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[MigrationConfigProperties]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.MigrationConfigProperties"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.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) + super().__init__(**kwargs) self.value = value self.next_link = None @@ -863,7 +810,7 @@ class MigrationConfigProperties(Resource): :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 + :vartype pending_replication_operations_count: int :ivar target_namespace: Existing premium Namespace ARM Id name which has no entities, will be used for migration. :vartype target_namespace: str @@ -875,34 +822,28 @@ class MigrationConfigProperties(Resource): """ _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}, + "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'}, + "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": "int"}, + "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, - *, - target_namespace: Optional[str] = None, - post_migration_name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, target_namespace: Optional[str] = None, 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. @@ -910,7 +851,7 @@ def __init__( :keyword post_migration_name: Name to access Standard Namespace after migration. :paramtype post_migration_name: str """ - super(MigrationConfigProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.provisioning_state = None self.pending_replication_operations_count = None @@ -935,7 +876,8 @@ class NetworkRuleSet(Resource): :ivar trusted_service_access_enabled: Value that indicates whether Trusted Service Access is Enabled or not. :vartype trusted_service_access_enabled: bool - :ivar default_action: Default Action for Network Rule Set. Known values are: "Allow", "Deny". + :ivar default_action: Default Action for Network Rule Set. Known values are: "Allow" and + "Deny". :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: @@ -943,28 +885,28 @@ class NetworkRuleSet(Resource): :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. Known values are: "Enabled", "Disabled". Default value: "Enabled". + default it is enabled. Known values are: "Enabled" and "Disabled". :vartype 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}, + "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'}, + "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__( @@ -974,14 +916,14 @@ def __init__( default_action: Optional[Union[str, "_models.DefaultAction"]] = None, virtual_network_rules: Optional[List["_models.NWRuleSetVirtualNetworkRules"]] = None, ip_rules: Optional[List["_models.NWRuleSetIpRules"]] = None, - public_network_access: Optional[Union[str, "_models.PublicNetworkAccessFlag"]] = "Enabled", + public_network_access: Union[str, "_models.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. Known values are: "Allow", + :keyword default_action: Default Action for Network Rule Set. Known values are: "Allow" and "Deny". :paramtype default_action: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.DefaultAction @@ -991,11 +933,11 @@ def __init__( :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. Known values are: "Enabled", "Disabled". Default value: "Enabled". + default it is enabled. Known values are: "Enabled" and "Disabled". :paramtype public_network_access: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.PublicNetworkAccessFlag """ - super(NetworkRuleSet, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.trusted_service_access_enabled = trusted_service_access_enabled self.default_action = default_action @@ -1004,7 +946,7 @@ def __init__( self.public_network_access = public_network_access -class NetworkRuleSetListResult(msrest.serialization.Model): +class NetworkRuleSetListResult(_serialization.Model): """The response of the List NetworkRuleSet operation. :ivar value: Result of the List NetworkRuleSet operation. @@ -1015,16 +957,12 @@ class NetworkRuleSetListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[NetworkRuleSet]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[NetworkRuleSet]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.NetworkRuleSet"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.NetworkRuleSet"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Result of the List NetworkRuleSet operation. @@ -1033,44 +971,40 @@ def __init__( list of NetworkRuleSet. :paramtype next_link: str """ - super(NetworkRuleSetListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class NWRuleSetIpRules(msrest.serialization.Model): +class NWRuleSetIpRules(_serialization.Model): """Description of NetWorkRuleSet - IpRules resource. :ivar ip_mask: IP Mask. :vartype ip_mask: str - :ivar action: The IP Filter Action. Known values are: "Allow". Default value: "Allow". + :ivar action: The IP Filter Action. "Allow" :vartype 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'}, + "ip_mask": {"key": "ipMask", "type": "str"}, + "action": {"key": "action", "type": "str"}, } def __init__( - self, - *, - ip_mask: Optional[str] = None, - action: Optional[Union[str, "_models.NetworkRuleIPAction"]] = "Allow", - **kwargs + self, *, ip_mask: Optional[str] = None, action: Union[str, "_models.NetworkRuleIPAction"] = "Allow", **kwargs ): """ :keyword ip_mask: IP Mask. :paramtype ip_mask: str - :keyword action: The IP Filter Action. Known values are: "Allow". Default value: "Allow". + :keyword action: The IP Filter Action. "Allow" :paramtype action: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.NetworkRuleIPAction """ - super(NWRuleSetIpRules, self).__init__(**kwargs) + super().__init__(**kwargs) self.ip_mask = ip_mask self.action = action -class NWRuleSetVirtualNetworkRules(msrest.serialization.Model): +class NWRuleSetVirtualNetworkRules(_serialization.Model): """Description of VirtualNetworkRules - NetworkRules resource. :ivar subnet: Subnet properties. @@ -1081,8 +1015,8 @@ class NWRuleSetVirtualNetworkRules(msrest.serialization.Model): """ _attribute_map = { - 'subnet': {'key': 'subnet', 'type': 'Subnet'}, - 'ignore_missing_vnet_service_endpoint': {'key': 'ignoreMissingVnetServiceEndpoint', 'type': 'bool'}, + "subnet": {"key": "subnet", "type": "Subnet"}, + "ignore_missing_vnet_service_endpoint": {"key": "ignoreMissingVnetServiceEndpoint", "type": "bool"}, } def __init__( @@ -1099,12 +1033,12 @@ def __init__( VNet Service Endpoint. :paramtype ignore_missing_vnet_service_endpoint: bool """ - super(NWRuleSetVirtualNetworkRules, self).__init__(**kwargs) + super().__init__(**kwargs) self.subnet = subnet self.ignore_missing_vnet_service_endpoint = ignore_missing_vnet_service_endpoint -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """A ServiceBus REST API operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -1116,30 +1050,25 @@ class Operation(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, + "name": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, } - def __init__( - self, - *, - display: Optional["_models.OperationDisplay"] = None, - **kwargs - ): + def __init__(self, *, display: Optional["_models.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) + super().__init__(**kwargs) self.name = None self.display = display -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """The object that represents the operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -1153,30 +1082,26 @@ class OperationDisplay(msrest.serialization.Model): """ _validation = { - 'provider': {'readonly': True}, - 'resource': {'readonly': True}, - 'operation': {'readonly': True}, + "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'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(OperationDisplay, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.provider = None self.resource = None self.operation = None -class OperationListResult(msrest.serialization.Model): +class OperationListResult(_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. @@ -1189,27 +1114,23 @@ class OperationListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(OperationListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class PrivateEndpoint(msrest.serialization.Model): +class PrivateEndpoint(_serialization.Model): """PrivateEndpoint information. :ivar id: The ARM identifier for Private Endpoint. @@ -1217,20 +1138,15 @@ class PrivateEndpoint(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, id: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin """ :keyword id: The ARM identifier for Private Endpoint. :paramtype id: str """ - super(PrivateEndpoint, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id @@ -1253,26 +1169,29 @@ class PrivateEndpointConnection(Resource): :vartype private_link_service_connection_state: ~azure.mgmt.servicebus.v2021_06_01_preview.models.ConnectionState :ivar provisioning_state: Provisioning state of the Private Endpoint Connection. Known values - are: "Creating", "Updating", "Deleting", "Succeeded", "Canceled", "Failed". + are: "Creating", "Updating", "Deleting", "Succeeded", "Canceled", and "Failed". :vartype 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}, + "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'}, + "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__( @@ -1290,18 +1209,18 @@ def __init__( :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. Known - values are: "Creating", "Updating", "Deleting", "Succeeded", "Canceled", "Failed". + values are: "Creating", "Updating", "Deleting", "Succeeded", "Canceled", and "Failed". :paramtype provisioning_state: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.EndPointProvisioningState """ - super(PrivateEndpointConnection, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.private_endpoint = private_endpoint self.private_link_service_connection_state = private_link_service_connection_state self.provisioning_state = provisioning_state -class PrivateEndpointConnectionListResult(msrest.serialization.Model): +class PrivateEndpointConnectionListResult(_serialization.Model): """Result of the list of all private endpoint connections operation. :ivar value: A collection of private endpoint connection resources. @@ -1312,8 +1231,8 @@ class PrivateEndpointConnectionListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateEndpointConnection]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PrivateEndpointConnection]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( @@ -1330,12 +1249,12 @@ def __init__( :keyword next_link: A link for the next page of private endpoint connection resources. :paramtype next_link: str """ - super(PrivateEndpointConnectionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class PrivateLinkResource(msrest.serialization.Model): +class PrivateLinkResource(_serialization.Model): """Information of the private link resource. :ivar id: Fully qualified identifier of the resource. @@ -1353,18 +1272,18 @@ class PrivateLinkResource(msrest.serialization.Model): """ _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]'}, + "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, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin name: Optional[str] = None, type: Optional[str] = None, group_id: Optional[str] = None, @@ -1386,7 +1305,7 @@ def __init__( :keyword required_zone_names: Required Zone Names. :paramtype required_zone_names: list[str] """ - super(PrivateLinkResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.name = name self.type = type @@ -1395,7 +1314,7 @@ def __init__( self.required_zone_names = required_zone_names -class PrivateLinkResourcesListResult(msrest.serialization.Model): +class PrivateLinkResourcesListResult(_serialization.Model): """Result of the List private link resources operation. :ivar value: A collection of private link resources. @@ -1405,16 +1324,12 @@ class PrivateLinkResourcesListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateLinkResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PrivateLinkResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.PrivateLinkResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.PrivateLinkResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: A collection of private link resources. @@ -1422,17 +1337,17 @@ def __init__( :keyword next_link: A link for the next page of private link resources. :paramtype next_link: str """ - super(PrivateLinkResourcesListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class RegenerateAccessKeyParameters(msrest.serialization.Model): +class RegenerateAccessKeyParameters(_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. - :ivar key_type: Required. The access key to regenerate. Known values are: "PrimaryKey", + :ivar key_type: The access key to regenerate. Required. Known values are: "PrimaryKey" and "SecondaryKey". :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 @@ -1441,30 +1356,24 @@ class RegenerateAccessKeyParameters(msrest.serialization.Model): """ _validation = { - 'key_type': {'required': True}, + "key_type": {"required": True}, } _attribute_map = { - 'key_type': {'key': 'keyType', 'type': 'str'}, - 'key': {'key': 'key', 'type': 'str'}, + "key_type": {"key": "keyType", "type": "str"}, + "key": {"key": "key", "type": "str"}, } - def __init__( - self, - *, - key_type: Union[str, "_models.KeyType"], - key: Optional[str] = None, - **kwargs - ): + def __init__(self, *, key_type: Union[str, "_models.KeyType"], key: Optional[str] = None, **kwargs): """ - :keyword key_type: Required. The access key to regenerate. Known values are: "PrimaryKey", + :keyword key_type: The access key to regenerate. Required. Known values are: "PrimaryKey" and "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) + super().__init__(**kwargs) self.key_type = key_type self.key = key @@ -1482,38 +1391,32 @@ class ResourceNamespacePatch(Resource): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "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}'}, + "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, - *, - location: Optional[str] = None, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs): """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(ResourceNamespacePatch, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.tags = tags @@ -1535,7 +1438,7 @@ class Rule(Resource): message that have been matched by a filter expression. :vartype action: ~azure.mgmt.servicebus.v2021_06_01_preview.models.Action :ivar filter_type: Filter type that is evaluated against a BrokeredMessage. Known values are: - "SqlFilter", "CorrelationFilter". + "SqlFilter" and "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 @@ -1545,21 +1448,21 @@ class Rule(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, + "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'}, + "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__( @@ -1576,7 +1479,7 @@ def __init__( 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. Known values - are: "SqlFilter", "CorrelationFilter". + are: "SqlFilter" and "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 @@ -1584,7 +1487,7 @@ def __init__( :paramtype correlation_filter: ~azure.mgmt.servicebus.v2021_06_01_preview.models.CorrelationFilter """ - super(Rule, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.action = action self.filter_type = filter_type @@ -1592,7 +1495,7 @@ def __init__( self.correlation_filter = correlation_filter -class RuleListResult(msrest.serialization.Model): +class RuleListResult(_serialization.Model): """The response of the List rule operation. :ivar value: Result of the List Rules operation. @@ -1603,17 +1506,11 @@ class RuleListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Rule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Rule]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.Rule"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Rule"]] = None, 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] @@ -1621,7 +1518,7 @@ def __init__( list of rules. :paramtype next_link: str """ - super(RuleListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link @@ -1644,36 +1541,31 @@ class SBAuthorizationRule(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, + "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]'}, + "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, - *, - rights: Optional[List[Union[str, "_models.AccessRights"]]] = None, - **kwargs - ): + def __init__(self, *, rights: Optional[List[Union[str, "_models.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) + super().__init__(**kwargs) self.system_data = None self.rights = rights -class SBAuthorizationRuleListResult(msrest.serialization.Model): +class SBAuthorizationRuleListResult(_serialization.Model): """The response to the List Namespace operation. :ivar value: Result of the List Authorization Rules operation. @@ -1684,16 +1576,12 @@ class SBAuthorizationRuleListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SBAuthorizationRule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SBAuthorizationRule]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.SBAuthorizationRule"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.SBAuthorizationRule"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Result of the List Authorization Rules operation. @@ -1702,12 +1590,12 @@ def __init__( list of Authorization Rules. :paramtype next_link: str """ - super(SBAuthorizationRuleListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SBClientAffineProperties(msrest.serialization.Model): +class SBClientAffineProperties(_serialization.Model): """Properties specific to client affine subscriptions. :ivar client_id: Indicates the Client ID of the application that created the client-affine @@ -1722,9 +1610,9 @@ class SBClientAffineProperties(msrest.serialization.Model): """ _attribute_map = { - 'client_id': {'key': 'clientId', 'type': 'str'}, - 'is_durable': {'key': 'isDurable', 'type': 'bool'}, - 'is_shared': {'key': 'isShared', 'type': 'bool'}, + "client_id": {"key": "clientId", "type": "str"}, + "is_durable": {"key": "isDurable", "type": "bool"}, + "is_shared": {"key": "isShared", "type": "bool"}, } def __init__( @@ -1746,7 +1634,7 @@ def __init__( subscription is shared or not. :paramtype is_shared: bool """ - super(SBClientAffineProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.client_id = client_id self.is_durable = is_durable self.is_shared = is_shared @@ -1765,46 +1653,40 @@ class TrackedResource(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :ivar location: Required. The Geo-location where the resource lives. + :ivar location: The Geo-location where the resource lives. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "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}'}, + "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, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword location: Required. The Geo-location where the resource lives. + :keyword location: The Geo-location where the resource lives. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(TrackedResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.tags = tags -class SBNamespace(TrackedResource): +class SBNamespace(TrackedResource): # pylint: disable=too-many-instance-attributes """Description of a namespace resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -1817,9 +1699,9 @@ class SBNamespace(TrackedResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :ivar location: Required. The Geo-location where the resource lives. + :ivar location: The Geo-location where the resource lives. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar sku: Properties of SKU. :vartype sku: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBSku @@ -1853,38 +1735,41 @@ class SBNamespace(TrackedResource): """ _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}, + "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'}, + "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__( @@ -1901,9 +1786,9 @@ def __init__( **kwargs ): """ - :keyword location: Required. The Geo-location where the resource lives. + :keyword location: The Geo-location where the resource lives. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword sku: Properties of SKU. :paramtype sku: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBSku @@ -1921,7 +1806,7 @@ def __init__( namespace. :paramtype disable_local_auth: bool """ - super(SBNamespace, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.sku = sku self.identity = identity self.system_data = None @@ -1937,7 +1822,7 @@ def __init__( self.disable_local_auth = disable_local_auth -class SBNamespaceListResult(msrest.serialization.Model): +class SBNamespaceListResult(_serialization.Model): """The response of the List Namespace operation. :ivar value: Result of the List Namespace operation. @@ -1948,16 +1833,12 @@ class SBNamespaceListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SBNamespace]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SBNamespace]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.SBNamespace"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.SBNamespace"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Result of the List Namespace operation. @@ -1966,12 +1847,12 @@ def __init__( list of Namespaces. :paramtype next_link: str """ - super(SBNamespaceListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SBNamespaceUpdateParameters(ResourceNamespacePatch): +class SBNamespaceUpdateParameters(ResourceNamespacePatch): # pylint: disable=too-many-instance-attributes """Description of a namespace resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -1984,7 +1865,7 @@ class SBNamespaceUpdateParameters(ResourceNamespacePatch): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar sku: Properties of SKU. :vartype sku: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBSku @@ -2016,35 +1897,38 @@ class SBNamespaceUpdateParameters(ResourceNamespacePatch): """ _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}, + "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'}, + "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__( @@ -2063,7 +1947,7 @@ def __init__( """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword sku: Properties of SKU. :paramtype sku: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBSku @@ -2081,7 +1965,7 @@ def __init__( namespace. :paramtype disable_local_auth: bool """ - super(SBNamespaceUpdateParameters, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.sku = sku self.identity = identity self.provisioning_state = None @@ -2096,7 +1980,7 @@ def __init__( self.disable_local_auth = disable_local_auth -class SBQueue(Resource): +class SBQueue(Resource): # pylint: disable=too-many-instance-attributes """Description of queue Resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2119,9 +2003,9 @@ class SBQueue(Resource): to this queue. :vartype accessed_at: ~datetime.datetime :ivar size_in_bytes: The size of the queue, in bytes. - :vartype size_in_bytes: long + :vartype size_in_bytes: int :ivar message_count: The number of messages in the queue. - :vartype message_count: long + :vartype message_count: int :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. @@ -2131,7 +2015,7 @@ class SBQueue(Resource): :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. - :vartype max_message_size_in_kilobytes: long + :vartype max_message_size_in_kilobytes: int :ivar requires_duplicate_detection: A value indicating if this queue requires duplicate detection. :vartype requires_duplicate_detection: bool @@ -2153,7 +2037,7 @@ class SBQueue(Resource): :vartype max_delivery_count: int :ivar status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". + "Deleting", "Renaming", and "Unknown". :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. @@ -2174,48 +2058,51 @@ class SBQueue(Resource): """ _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}, + "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__( + "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": "int"}, + "message_count": {"key": "properties.messageCount", "type": "int"}, + "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": "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__( # pylint: disable=too-many-locals self, *, lock_duration: Optional[datetime.timedelta] = None, @@ -2246,7 +2133,7 @@ def __init__( :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 + :paramtype max_message_size_in_kilobytes: int :keyword requires_duplicate_detection: A value indicating if this queue requires duplicate detection. :paramtype requires_duplicate_detection: bool @@ -2268,7 +2155,7 @@ def __init__( :paramtype max_delivery_count: int :keyword status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". + "Deleting", "Renaming", and "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. @@ -2288,7 +2175,7 @@ def __init__( message. :paramtype forward_dead_lettered_messages_to: str """ - super(SBQueue, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.count_details = None self.created_at = None @@ -2314,7 +2201,7 @@ def __init__( self.forward_dead_lettered_messages_to = forward_dead_lettered_messages_to -class SBQueueListResult(msrest.serialization.Model): +class SBQueueListResult(_serialization.Model): """The response to the List Queues operation. :ivar value: Result of the List Queues operation. @@ -2325,17 +2212,11 @@ class SBQueueListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SBQueue]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SBQueue]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.SBQueue"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.SBQueue"]] = None, 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] @@ -2343,19 +2224,19 @@ def __init__( list of queues. :paramtype next_link: str """ - super(SBQueueListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SBSku(msrest.serialization.Model): +class SBSku(_serialization.Model): """SKU of the namespace. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Name of this SKU. Known values are: "Basic", "Standard", "Premium". + :ivar name: Name of this SKU. Required. Known values are: "Basic", "Standard", and "Premium". :vartype name: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.SkuName - :ivar tier: The billing tier of this particular SKU. Known values are: "Basic", "Standard", + :ivar tier: The billing tier of this particular SKU. Known values are: "Basic", "Standard", and "Premium". :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 @@ -2364,13 +2245,13 @@ class SBSku(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'int'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "capacity": {"key": "capacity", "type": "int"}, } def __init__( @@ -2382,22 +2263,23 @@ def __init__( **kwargs ): """ - :keyword name: Required. Name of this SKU. Known values are: "Basic", "Standard", "Premium". + :keyword name: Name of this SKU. Required. Known values are: "Basic", "Standard", and + "Premium". :paramtype name: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.SkuName :keyword tier: The billing tier of this particular SKU. Known values are: "Basic", "Standard", - "Premium". + and "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) + super().__init__(**kwargs) self.name = name self.tier = tier self.capacity = capacity -class SBSubscription(Resource): +class SBSubscription(Resource): # pylint: disable=too-many-instance-attributes """Description of subscription resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2411,7 +2293,7 @@ class SBSubscription(Resource): :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 + :vartype message_count: int :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. @@ -2442,7 +2324,7 @@ class SBSubscription(Resource): :vartype max_delivery_count: int :ivar status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". + "Deleting", "Renaming", and "Unknown". :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. @@ -2463,41 +2345,47 @@ class SBSubscription(Resource): """ _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}, + "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'}, + "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": "int"}, + "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__( @@ -2542,7 +2430,7 @@ def __init__( :paramtype max_delivery_count: int :keyword status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". + "Deleting", "Renaming", and "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. @@ -2562,7 +2450,7 @@ def __init__( :paramtype client_affine_properties: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBClientAffineProperties """ - super(SBSubscription, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.message_count = None self.created_at = None @@ -2585,7 +2473,7 @@ def __init__( self.client_affine_properties = client_affine_properties -class SBSubscriptionListResult(msrest.serialization.Model): +class SBSubscriptionListResult(_serialization.Model): """The response to the List Subscriptions operation. :ivar value: Result of the List Subscriptions operation. @@ -2596,16 +2484,12 @@ class SBSubscriptionListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SBSubscription]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SBSubscription]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.SBSubscription"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.SBSubscription"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Result of the List Subscriptions operation. @@ -2614,12 +2498,12 @@ def __init__( list of subscriptions. :paramtype next_link: str """ - super(SBSubscriptionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SBTopic(Resource): +class SBTopic(Resource): # pylint: disable=too-many-instance-attributes """Description of topic resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2633,7 +2517,7 @@ class SBTopic(Resource): :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 + :vartype size_in_bytes: int :ivar created_at: Exact time the message was created. :vartype created_at: ~datetime.datetime :ivar updated_at: The exact time the message was updated. @@ -2653,7 +2537,7 @@ class SBTopic(Resource): :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. - :vartype max_message_size_in_kilobytes: long + :vartype max_message_size_in_kilobytes: int :ivar requires_duplicate_detection: Value indicating if this topic requires duplicate detection. :vartype requires_duplicate_detection: bool @@ -2665,7 +2549,7 @@ class SBTopic(Resource): :vartype enable_batched_operations: bool :ivar status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". + "Deleting", "Renaming", and "Unknown". :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 @@ -2681,40 +2565,43 @@ class SBTopic(Resource): """ _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}, + "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'}, + "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": "int"}, + "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": "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__( @@ -2743,7 +2630,7 @@ def __init__( :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 + :paramtype max_message_size_in_kilobytes: int :keyword requires_duplicate_detection: Value indicating if this topic requires duplicate detection. :paramtype requires_duplicate_detection: bool @@ -2755,7 +2642,7 @@ def __init__( :paramtype enable_batched_operations: bool :keyword status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". + "Deleting", "Renaming", and "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 @@ -2769,7 +2656,7 @@ def __init__( topic holds a message in memory temporarily before writing it to persistent storage. :paramtype enable_express: bool """ - super(SBTopic, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.size_in_bytes = None self.created_at = None @@ -2790,7 +2677,7 @@ def __init__( self.enable_express = enable_express -class SBTopicListResult(msrest.serialization.Model): +class SBTopicListResult(_serialization.Model): """The response to the List Topics operation. :ivar value: Result of the List Topics operation. @@ -2801,17 +2688,11 @@ class SBTopicListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SBTopic]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SBTopic]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.SBTopic"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.SBTopic"]] = None, 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] @@ -2819,12 +2700,12 @@ def __init__( list of topics. :paramtype next_link: str """ - super(SBTopicListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SqlFilter(msrest.serialization.Model): +class SqlFilter(_serialization.Model): """Represents a filter which is a composition of an expression and an action that is executed in the pub/sub pipeline. :ivar sql_expression: The SQL expression. e.g. MyProperty='ABC'. @@ -2838,9 +2719,9 @@ class SqlFilter(msrest.serialization.Model): """ _attribute_map = { - 'sql_expression': {'key': 'sqlExpression', 'type': 'str'}, - 'compatibility_level': {'key': 'compatibilityLevel', 'type': 'int'}, - 'requires_preprocessing': {'key': 'requiresPreprocessing', 'type': 'bool'}, + "sql_expression": {"key": "sqlExpression", "type": "str"}, + "compatibility_level": {"key": "compatibilityLevel", "type": "int"}, + "requires_preprocessing": {"key": "requiresPreprocessing", "type": "bool"}, } def __init__( @@ -2848,7 +2729,7 @@ def __init__( *, sql_expression: Optional[str] = None, compatibility_level: Optional[int] = None, - requires_preprocessing: Optional[bool] = True, + requires_preprocessing: bool = True, **kwargs ): """ @@ -2861,7 +2742,7 @@ def __init__( preprocessing. :paramtype requires_preprocessing: bool """ - super(SqlFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.sql_expression = sql_expression self.compatibility_level = compatibility_level self.requires_preprocessing = requires_preprocessing @@ -2881,9 +2762,9 @@ class SqlRuleAction(Action): """ _attribute_map = { - 'sql_expression': {'key': 'sqlExpression', 'type': 'str'}, - 'compatibility_level': {'key': 'compatibilityLevel', 'type': 'int'}, - 'requires_preprocessing': {'key': 'requiresPreprocessing', 'type': 'bool'}, + "sql_expression": {"key": "sqlExpression", "type": "str"}, + "compatibility_level": {"key": "compatibilityLevel", "type": "int"}, + "requires_preprocessing": {"key": "requiresPreprocessing", "type": "bool"}, } def __init__( @@ -2891,7 +2772,7 @@ def __init__( *, sql_expression: Optional[str] = None, compatibility_level: Optional[int] = None, - requires_preprocessing: Optional[bool] = True, + requires_preprocessing: bool = True, **kwargs ): """ @@ -2904,47 +2785,47 @@ def __init__( preprocessing. :paramtype requires_preprocessing: bool """ - super(SqlRuleAction, self).__init__(sql_expression=sql_expression, compatibility_level=compatibility_level, requires_preprocessing=requires_preprocessing, **kwargs) + super().__init__( + sql_expression=sql_expression, + compatibility_level=compatibility_level, + requires_preprocessing=requires_preprocessing, + **kwargs + ) -class Subnet(msrest.serialization.Model): +class Subnet(_serialization.Model): """Properties supplied for Subnet. All required parameters must be populated in order to send to Azure. - :ivar id: Required. Resource ID of Virtual Network Subnet. + :ivar id: Resource ID of Virtual Network Subnet. Required. :vartype id: str """ _validation = { - 'id': {'required': True}, + "id": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: str, - **kwargs - ): + def __init__(self, *, id: str, **kwargs): # pylint: disable=redefined-builtin """ - :keyword id: Required. Resource ID of Virtual Network Subnet. + :keyword id: Resource ID of Virtual Network Subnet. Required. :paramtype id: str """ - super(Subnet, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id -class SystemData(msrest.serialization.Model): +class SystemData(_serialization.Model): """Metadata pertaining to creation and last modification of the resource. :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. Known values are: - "User", "Application", "ManagedIdentity", "Key". + "User", "Application", "ManagedIdentity", and "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). @@ -2952,7 +2833,7 @@ class SystemData(msrest.serialization.Model): :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. Known values - are: "User", "Application", "ManagedIdentity", "Key". + are: "User", "Application", "ManagedIdentity", and "Key". :vartype last_modified_by_type: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.CreatedByType :ivar last_modified_at: The type of identity that last modified the resource. @@ -2960,12 +2841,12 @@ class SystemData(msrest.serialization.Model): """ _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'}, + "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__( @@ -2983,7 +2864,7 @@ def __init__( :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. Known values are: - "User", "Application", "ManagedIdentity", "Key". + "User", "Application", "ManagedIdentity", and "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). @@ -2991,13 +2872,13 @@ def __init__( :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. Known - values are: "User", "Application", "ManagedIdentity", "Key". + values are: "User", "Application", "ManagedIdentity", and "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) + super().__init__(**kwargs) self.created_by = created_by self.created_by_type = created_by_type self.created_at = created_at @@ -3006,7 +2887,7 @@ def __init__( self.last_modified_at = last_modified_at -class UserAssignedIdentity(msrest.serialization.Model): +class UserAssignedIdentity(_serialization.Model): """Recognized Dictionary value. Variables are only populated by the server, and will be ignored when sending a request. @@ -3018,27 +2899,23 @@ class UserAssignedIdentity(msrest.serialization.Model): """ _validation = { - 'principal_id': {'readonly': True}, - 'client_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "client_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'client_id': {'key': 'clientId', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "client_id": {"key": "clientId", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(UserAssignedIdentity, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.principal_id = None self.client_id = None -class UserAssignedIdentityProperties(msrest.serialization.Model): +class UserAssignedIdentityProperties(_serialization.Model): """UserAssignedIdentityProperties. :ivar user_assigned_identity: ARM ID of user Identity selected for encryption. @@ -3046,18 +2923,13 @@ class UserAssignedIdentityProperties(msrest.serialization.Model): """ _attribute_map = { - 'user_assigned_identity': {'key': 'userAssignedIdentity', 'type': 'str'}, + "user_assigned_identity": {"key": "userAssignedIdentity", "type": "str"}, } - def __init__( - self, - *, - user_assigned_identity: Optional[str] = None, - **kwargs - ): + def __init__(self, *, 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) + super().__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/_patch.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/models/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/models/_patch.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/models/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. 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 33112c2ab17d..ce716a014719 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 @@ -11,30 +11,31 @@ class AccessRights(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """AccessRights.""" MANAGE = "Manage" SEND = "Send" LISTEN = "Listen" + class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of identity that created the resource. - """ + """The type of identity that created the resource.""" USER = "User" APPLICATION = "Application" MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" + class DefaultAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Default Action for Network Rule Set - """ + """Default Action for Network Rule Set.""" ALLOW = "Allow" DENY = "Deny" + class EndPointProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Provisioning state of the Private Endpoint Connection. - """ + """Provisioning state of the Private Endpoint Connection.""" CREATING = "Creating" UPDATING = "Updating" @@ -43,9 +44,9 @@ class EndPointProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): CANCELED = "Canceled" FAILED = "Failed" + class EntityStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Entity status. - """ + """Entity status.""" ACTIVE = "Active" DISABLED = "Disabled" @@ -57,92 +58,96 @@ class EntityStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): RENAMING = "Renaming" UNKNOWN = "Unknown" + class FilterType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Rule filter types - """ + """Rule filter types.""" SQL_FILTER = "SqlFilter" CORRELATION_FILTER = "CorrelationFilter" + class KeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The access key to regenerate. - """ + """The access key to regenerate.""" PRIMARY_KEY = "PrimaryKey" SECONDARY_KEY = "SecondaryKey" + class ManagedServiceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Type of managed service identity. - """ + """Type of managed service identity.""" SYSTEM_ASSIGNED = "SystemAssigned" USER_ASSIGNED = "UserAssigned" SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" NONE = "None" + class MigrationConfigurationName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """MigrationConfigurationName.""" _DEFAULT = "$default" + class NetworkRuleIPAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The IP Filter Action - """ + """The IP Filter Action.""" ALLOW = "Allow" + class PrivateLinkConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Status of the connection. - """ + """Status of the connection.""" PENDING = "Pending" APPROVED = "Approved" REJECTED = "Rejected" DISCONNECTED = "Disconnected" + class ProvisioningStateDR(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Provisioning state of the Alias(Disaster Recovery configuration) - possible values 'Accepted' - or 'Succeeded' or 'Failed' + or 'Succeeded' or 'Failed'. """ ACCEPTED = "Accepted" SUCCEEDED = "Succeeded" FAILED = "Failed" + class PublicNetworkAccessFlag(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """This determines if traffic is allowed over public network. By default it is enabled. - """ + """This determines if traffic is allowed over public network. By default it is enabled.""" ENABLED = "Enabled" DISABLED = "Disabled" + class RoleDisasterRecovery(str, Enum, metaclass=CaseInsensitiveEnumMeta): """role of namespace in GEO DR - possible values 'Primary' or 'PrimaryNotReplicating' or - 'Secondary' + 'Secondary'. """ PRIMARY = "Primary" PRIMARY_NOT_REPLICATING = "PrimaryNotReplicating" SECONDARY = "Secondary" + class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Name of this SKU. - """ + """Name of this SKU.""" BASIC = "Basic" STANDARD = "Standard" PREMIUM = "Premium" + class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The billing tier of this particular SKU. - """ + """The billing tier of this particular SKU.""" BASIC = "Basic" STANDARD = "Standard" PREMIUM = "Premium" + class UnavailableReason(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the reason for the unavailability of the service. - """ + """Specifies the reason for the unavailability of the service.""" NONE = "None" INVALID_NAME = "InvalidName" diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/__init__.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/__init__.py index 5559ccd3746c..831edc36bd6b 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/__init__.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/__init__.py @@ -20,17 +20,18 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'NamespacesOperations', - 'PrivateEndpointConnectionsOperations', - 'PrivateLinkResourcesOperations', - 'Operations', - 'DisasterRecoveryConfigsOperations', - 'MigrationConfigsOperations', - 'QueuesOperations', - 'TopicsOperations', - 'RulesOperations', - 'SubscriptionsOperations', + "NamespacesOperations", + "PrivateEndpointConnectionsOperations", + "PrivateLinkResourcesOperations", + "Operations", + "DisasterRecoveryConfigsOperations", + "MigrationConfigsOperations", + "QueuesOperations", + "TopicsOperations", + "RulesOperations", + "SubscriptionsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() 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 b76be6f453d7..d1ce71dcde6e 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 @@ -6,11 +6,16 @@ # 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, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -20,343 +25,293 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") 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: Optional[_models.CheckNameAvailability] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - resource_group_name: str, - namespace_name: str, - alias: str, - subscription_id: str, - *, - json: Optional[_models.ArmDisasterRecovery] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, alias: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - namespace_name: str, - alias: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, alias: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - namespace_name: str, - alias: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, alias: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_break_pairing_request( - resource_group_name: str, - namespace_name: str, - alias: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, alias: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_fail_over_request( - resource_group_name: str, - namespace_name: str, - alias: str, - subscription_id: str, - *, - json: Optional[_models.FailoverProperties] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, alias: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_authorization_rules_request( - resource_group_name: str, - namespace_name: str, - alias: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, alias: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_authorization_rule_request( @@ -370,34 +325,35 @@ def build_get_authorization_rule_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( @@ -411,34 +367,36 @@ def build_list_keys_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class DisasterRecoveryConfigsOperations: """ @@ -459,41 +417,102 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace + @overload def check_name_availability( self, resource_group_name: str, namespace_name: str, parameters: _models.CheckNameAvailability, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Check the give namespace name availability. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters to check availability of the given namespace name. + :param parameters: Parameters to check availability of the given namespace name. Required. :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.CheckNameAvailability + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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.v2021_06_01_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters to check availability of the given namespace name. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :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.v2021_06_01_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, + resource_group_name: str, + namespace_name: str, + parameters: Union[_models.CheckNameAvailability, IO], + **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters to check availability of the given namespace name. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.CheckNameAvailability or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameAvailabilityResult, or the result of cls(response) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResult] - _json = self._serialize.body(parameters, 'CheckNameAvailability') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CheckNameAvailability") request = build_check_name_availability_request( resource_group_name=resource_group_name, @@ -502,7 +521,8 @@ def check_name_availability( api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) @@ -510,10 +530,9 @@ def check_name_availability( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -521,55 +540,49 @@ def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + 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 - + 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, - namespace_name: str, - **kwargs: Any - ) -> Iterable[_models.ArmDisasterRecoveryListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> Iterable["_models.ArmDisasterRecovery"]: """Gets all Alias(Disaster Recovery configurations). - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: An iterator like instance of either ArmDisasterRecovery 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 + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.ArmDisasterRecovery] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ArmDisasterRecoveryListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -577,16 +590,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -602,10 +610,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -616,49 +622,117 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 + @overload def create_or_update( self, resource_group_name: str, namespace_name: str, alias: str, parameters: _models.ArmDisasterRecovery, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Required. :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.ArmDisasterRecovery + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ArmDisasterRecovery or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.ArmDisasterRecovery or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ArmDisasterRecovery or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.ArmDisasterRecovery or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: Union[_models.ArmDisasterRecovery, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). Is + either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.ArmDisasterRecovery or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ArmDisasterRecovery, or the result of cls(response) + :return: ArmDisasterRecovery or None or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.ArmDisasterRecovery or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ArmDisasterRecovery]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ArmDisasterRecovery]] - _json = self._serialize.body(parameters, 'ArmDisasterRecovery') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ArmDisasterRecovery") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -668,7 +742,8 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -676,10 +751,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -689,56 +763,48 @@ def create_or_update( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ArmDisasterRecovery', pipeline_response) + 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 - + 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: str, - namespace_name: str, - alias: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -746,10 +812,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -760,49 +825,41 @@ def delete( # pylint: disable=inconsistent-return-statements 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: str, - namespace_name: str, - alias: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :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) + :return: ArmDisasterRecovery or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.ArmDisasterRecovery - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ArmDisasterRecovery] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ArmDisasterRecovery] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -810,10 +867,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -821,57 +877,49 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ArmDisasterRecovery', pipeline_response) + 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 - + 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: str, - namespace_name: str, - alias: str, - **kwargs: Any + self, 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. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.break_pairing.metadata["url"], headers=_headers, params=_params, ) @@ -879,10 +927,9 @@ def break_pairing( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -893,50 +940,118 @@ def break_pairing( # pylint: disable=inconsistent-return-statements 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 - @distributed_trace + @overload def fail_over( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, alias: str, parameters: Optional[_models.FailoverProperties] = None, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :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 content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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: + """ + + @overload + def fail_over( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Default value is None. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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: + """ + + @distributed_trace + def fail_over( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: Optional[Union[_models.FailoverProperties, IO]] = 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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). Is + either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.FailoverProperties or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - if parameters is not None: - _json = self._serialize.body(parameters, 'FailoverProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "FailoverProperties") + else: + _json = None request = build_fail_over_request( resource_group_name=resource_group_name, @@ -946,7 +1061,8 @@ def fail_over( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, json=_json, - template_url=self.fail_over.metadata['url'], + content=_content, + template_url=self.fail_over.metadata["url"], headers=_headers, params=_params, ) @@ -954,10 +1070,9 @@ def fail_over( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -968,52 +1083,45 @@ def fail_over( # pylint: disable=inconsistent-return-statements 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, - namespace_name: str, - alias: str, - **kwargs: Any - ) -> Iterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, alias: str, **kwargs: Any + ) -> Iterable["_models.SBAuthorizationRule"]: """Gets the authorization rules for a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :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) + :return: An iterator like instance of either SBAuthorizationRule 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 + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) @@ -1021,17 +1129,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -1047,10 +1149,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1061,48 +1161,38 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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: str, - namespace_name: str, - alias: str, - authorization_rule_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -1110,7 +1200,7 @@ def get_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -1118,10 +1208,9 @@ def get_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1129,52 +1218,43 @@ def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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: str, - namespace_name: str, - alias: str, - authorization_rule_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -1182,7 +1262,7 @@ def list_keys( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1190,10 +1270,9 @@ def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1201,12 +1280,11 @@ def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 - + 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 319439294e12..388b6ce3f7e8 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 @@ -6,11 +6,16 @@ # 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, Iterable, Optional, TypeVar, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -22,95 +27,88 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_and_start_migration_request_initial( +def build_create_and_start_migration_request( resource_group_name: str, namespace_name: str, config_name: Union[str, "_models.MigrationConfigurationName"], subscription_id: str, - *, - json: Optional[_models.MigrationConfigProperties] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( @@ -123,33 +121,32 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( @@ -162,33 +159,32 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_complete_migration_request( @@ -201,33 +197,32 @@ def build_complete_migration_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_revert_request( @@ -240,33 +235,33 @@ def build_revert_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class MigrationConfigsOperations: """ @@ -287,46 +282,41 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> Iterable[_models.MigrationConfigListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> Iterable["_models.MigrationConfigProperties"]: """Gets all migrationConfigurations. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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 + :return: An iterator like instance of either MigrationConfigProperties 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 + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigProperties] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MigrationConfigListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -334,16 +324,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -359,10 +344,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -373,35 +356,37 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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: str, namespace_name: str, config_name: Union[str, "_models.MigrationConfigurationName"], - parameters: _models.MigrationConfigProperties, + parameters: Union[_models.MigrationConfigProperties, IO], **kwargs: Any ) -> Optional[_models.MigrationConfigProperties]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.MigrationConfigProperties]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.MigrationConfigProperties]] - _json = self._serialize.body(parameters, 'MigrationConfigProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "MigrationConfigProperties") - request = build_create_and_start_migration_request_initial( + request = build_create_and_start_migration_request( resource_group_name=resource_group_name, namespace_name=namespace_name, config_name=config_name, @@ -409,7 +394,8 @@ def _create_and_start_migration_initial( api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_and_start_migration_initial.metadata['url'], + content=_content, + template_url=self._create_and_start_migration_initial.metadata["url"], headers=_headers, params=_params, ) @@ -417,27 +403,108 @@ def _create_and_start_migration_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) + 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 + _create_and_start_migration_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore + @overload + def begin_create_and_start_migration( + self, + resource_group_name: str, + namespace_name: str, + config_name: Union[str, "_models.MigrationConfigurationName"], + parameters: _models.MigrationConfigProperties, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param config_name: The configuration name. Should always be "$default". "$default" Required. + :type config_name: str or + ~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigurationName + :param parameters: Parameters required to create Migration Configuration. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. + :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: + """ + + @overload + def begin_create_and_start_migration( + self, + resource_group_name: str, + namespace_name: str, + config_name: Union[str, "_models.MigrationConfigurationName"], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param config_name: The configuration name. Should always be "$default". "$default" Required. + :type config_name: str or + ~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigurationName + :param parameters: Parameters required to create Migration Configuration. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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: + """ @distributed_trace def begin_create_and_start_migration( @@ -445,21 +512,26 @@ def begin_create_and_start_migration( resource_group_name: str, namespace_name: str, config_name: Union[str, "_models.MigrationConfigurationName"], - parameters: _models.MigrationConfigProperties, + parameters: Union[_models.MigrationConfigProperties, IO], **kwargs: Any ) -> LROPoller[_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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigurationName - :param parameters: Parameters required to create Migration Configuration. + :param parameters: Parameters required to create Migration Configuration. Is either a model + type or a IO type. Required. :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigProperties + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -472,20 +544,17 @@ def begin_create_and_start_migration( of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigProperties] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.MigrationConfigProperties] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MigrationConfigProperties] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + 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 = self._create_and_start_migration_initial( # type: ignore resource_group_name=resource_group_name, @@ -494,39 +563,35 @@ def begin_create_and_start_migration( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) + deserialized = self._deserialize("MigrationConfigProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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 @@ -538,37 +603,34 @@ def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes a MigrationConfiguration. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -576,10 +638,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -590,8 +651,7 @@ def delete( # pylint: disable=inconsistent-return-statements 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( @@ -603,37 +663,34 @@ def get( ) -> _models.MigrationConfigProperties: """Retrieves Migration Config. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :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) + :return: MigrationConfigProperties or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.MigrationConfigProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MigrationConfigProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MigrationConfigProperties] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -641,10 +698,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -652,15 +708,14 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) + 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 - + 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 @@ -674,37 +729,34 @@ def complete_migration( # pylint: disable=inconsistent-return-statements 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.complete_migration.metadata["url"], headers=_headers, params=_params, ) @@ -712,10 +764,9 @@ def complete_migration( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -726,8 +777,7 @@ def complete_migration( # pylint: disable=inconsistent-return-statements 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 @distributed_trace def revert( # pylint: disable=inconsistent-return-statements @@ -739,37 +789,34 @@ def revert( # pylint: disable=inconsistent-return-statements ) -> None: """This operation reverts Migration. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.revert.metadata["url"], headers=_headers, params=_params, ) @@ -777,10 +824,9 @@ def revert( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -791,5 +837,4 @@ def revert( # pylint: disable=inconsistent-return-statements 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 8157c9b729a3..561a6d184351 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 @@ -6,11 +6,16 @@ # 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, Iterable, Optional, TypeVar, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -22,651 +27,557 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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: + +def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("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'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_resource_group_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces") # pylint: disable=line-too-long + _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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request_initial( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - *, - json: Optional[_models.SBNamespace] = None, - content: Any = None, - **kwargs: Any + +def build_create_or_update_request( + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long + _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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any +def build_delete_request( + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - *, - json: Optional[_models.SBNamespaceUpdateParameters] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_network_rule_set_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - *, - json: Optional[_models.NetworkRuleSet] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_network_rule_set_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_network_rule_sets_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_authorization_rules_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_authorization_rule_request( - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - subscription_id: str, - *, - json: Optional[_models.SBAuthorizationRule] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, authorization_rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_authorization_rule_request( - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, authorization_rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_authorization_rule_request( - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, authorization_rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, authorization_rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_regenerate_keys_request( - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - subscription_id: str, - *, - json: Optional[_models.RegenerateAccessKeyParameters] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, authorization_rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_check_name_availability_request( - subscription_id: str, - *, - json: Optional[_models.CheckNameAvailability] = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: + +def build_check_name_availability_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + class NamespacesOperations: """ @@ -687,38 +598,32 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.SBNamespaceListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.SBNamespace"]: """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) + :return: An iterator like instance of either SBNamespace 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 + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBNamespace] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespaceListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -726,14 +631,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -749,10 +651,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -763,47 +663,39 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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: str, - **kwargs: Any - ) -> Iterable[_models.SBNamespaceListResult]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.SBNamespace"]: """Gets the available namespaces within a resource group. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :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) + :return: An iterator like instance of either SBNamespace 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 + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBNamespace] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespaceListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -811,15 +703,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -835,10 +723,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -849,41 +735,40 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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: str, - namespace_name: str, - parameters: _models.SBNamespace, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, parameters: Union[_models.SBNamespace, IO], **kwargs: Any ) -> Optional[_models.SBNamespace]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.SBNamespace]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.SBNamespace]] - _json = self._serialize.body(parameters, 'SBNamespace') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBNamespace") - request = build_create_or_update_request_initial( + request = build_create_or_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._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) @@ -891,48 +776,89 @@ def _create_or_update_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SBNamespace', pipeline_response) + 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 - + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, namespace_name: str, parameters: _models.SBNamespace, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters supplied to create a namespace resource. + :param parameters: Parameters supplied to create a namespace resource. Required. :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBNamespace + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. + :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: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to create a namespace resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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 @@ -945,20 +871,49 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBNamespace] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, resource_group_name: str, namespace_name: str, parameters: Union[_models.SBNamespace, IO], **kwargs: Any + ) -> LROPoller[_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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to create a namespace resource. Is either a model type + or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBNamespace or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespace] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBNamespace] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + 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 = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, @@ -966,64 +921,54 @@ def begin_create_or_update( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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: str, - namespace_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_request_initial( + request = build_delete_request( 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'], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1031,35 +976,29 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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_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 @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, 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. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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. @@ -1071,92 +1010,77 @@ def begin_delete( # pylint: disable=inconsistent-return-statements 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + 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 = self._delete_initial( # type: ignore resource_group_name=resource_group_name, namespace_name=namespace_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> _models.SBNamespace: + def get(self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: SBNamespace or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBNamespace - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespace] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBNamespace] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -1164,10 +1088,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1175,51 +1098,115 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBNamespace', pipeline_response) + 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 + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + + @overload + def update( + self, + resource_group_name: str, + namespace_name: str, + parameters: _models.SBNamespaceUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> 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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to update a namespace resource. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBNamespaceUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBNamespace or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBNamespace or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> 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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to update a namespace resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBNamespace or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBNamespace or None + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def update( self, resource_group_name: str, namespace_name: str, - parameters: _models.SBNamespaceUpdateParameters, + parameters: Union[_models.SBNamespaceUpdateParameters, IO], **kwargs: Any ) -> 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters supplied to update a namespace resource. + :param parameters: Parameters supplied to update a namespace resource. Is either a model type + or a IO type. Required. :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBNamespaceUpdateParameters + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBNamespace, or the result of cls(response) + :return: SBNamespace or None or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBNamespace or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.SBNamespace]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.SBNamespace]] - _json = self._serialize.body(parameters, 'SBNamespaceUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBNamespaceUpdateParameters") request = build_update_request( resource_group_name=resource_group_name, @@ -1228,7 +1215,8 @@ def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -1236,10 +1224,9 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -1249,53 +1236,113 @@ def update( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SBNamespace', pipeline_response) + 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 + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - - @distributed_trace + @overload def create_or_update_network_rule_set( self, resource_group_name: str, namespace_name: str, parameters: _models.NetworkRuleSet, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.NetworkRuleSet: """Create or update NetworkRuleSet for a Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: The Namespace IpFilterRule. + :param parameters: The Namespace IpFilterRule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.NetworkRuleSet + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: NetworkRuleSet, or the result of cls(response) + :return: NetworkRuleSet or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.NetworkRuleSet - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def create_or_update_network_rule_set( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NetworkRuleSet: + """Create or update NetworkRuleSet for a Namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: The Namespace IpFilterRule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2021_06_01_preview.models.NetworkRuleSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_network_rule_set( + self, + resource_group_name: str, + namespace_name: str, + parameters: Union[_models.NetworkRuleSet, IO], + **kwargs: Any + ) -> _models.NetworkRuleSet: + """Create or update NetworkRuleSet for a Namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: The Namespace IpFilterRule. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.NetworkRuleSet or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2021_06_01_preview.models.NetworkRuleSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkRuleSet] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.NetworkRuleSet] - _json = self._serialize.body(parameters, 'NetworkRuleSet') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "NetworkRuleSet") request = build_create_or_update_network_rule_set_request( resource_group_name=resource_group_name, @@ -1304,7 +1351,8 @@ def create_or_update_network_rule_set( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_network_rule_set.metadata['url'], + content=_content, + template_url=self.create_or_update_network_rule_set.metadata["url"], headers=_headers, params=_params, ) @@ -1312,10 +1360,9 @@ def create_or_update_network_rule_set( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1323,52 +1370,45 @@ def create_or_update_network_rule_set( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('NetworkRuleSet', pipeline_response) + 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 - + 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: str, - namespace_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: NetworkRuleSet or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.NetworkRuleSet - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkRuleSet] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.NetworkRuleSet] - 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'], + template_url=self.get_network_rule_set.metadata["url"], headers=_headers, params=_params, ) @@ -1376,10 +1416,9 @@ def get_network_rule_set( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1387,55 +1426,49 @@ def get_network_rule_set( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('NetworkRuleSet', pipeline_response) + 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 - + 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, - namespace_name: str, - **kwargs: Any - ) -> Iterable[_models.NetworkRuleSetListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> Iterable["_models.NetworkRuleSet"]: """Gets list of NetworkRuleSet for a Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: An iterator like instance of either NetworkRuleSet 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 + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.NetworkRuleSet] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkRuleSetListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_network_rule_sets.metadata["url"], headers=_headers, params=_params, ) @@ -1443,16 +1476,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -1468,10 +1496,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1482,51 +1508,44 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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: str, - namespace_name: str, - **kwargs: Any - ) -> Iterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> Iterable["_models.SBAuthorizationRule"]: """Gets the authorization rules for a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: An iterator like instance of either SBAuthorizationRule 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 + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) @@ -1534,16 +1553,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -1559,10 +1573,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1573,49 +1585,115 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 + @overload def create_or_update_authorization_rule( self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, parameters: _models.SBAuthorizationRule, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2021_06_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: Union[_models.SBAuthorizationRule, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2021_06_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - _json = self._serialize.body(parameters, 'SBAuthorizationRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBAuthorizationRule") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -1625,7 +1703,8 @@ def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -1633,10 +1712,9 @@ def create_or_update_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1644,56 +1722,48 @@ def create_or_update_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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: str, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -1701,10 +1771,9 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1715,49 +1784,41 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements 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: str, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - 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'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -1765,10 +1826,9 @@ def get_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1776,56 +1836,48 @@ def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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: str, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - 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'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1833,10 +1885,9 @@ def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1844,54 +1895,122 @@ def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 - + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys"} # type: ignore - @distributed_trace + @overload def regenerate_keys( self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, parameters: _models.RegenerateAccessKeyParameters, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.RegenerateAccessKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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.v2021_06_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2021_06_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateAccessKeyParameters, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: + ~azure.mgmt.servicebus.v2021_06_01_preview.models.RegenerateAccessKeyParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateAccessKeyParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -1901,7 +2020,8 @@ def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1909,10 +2029,9 @@ def regenerate_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1920,51 +2039,91 @@ def regenerate_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 + regenerate_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore + + @overload + def check_name_availability( + self, parameters: _models.CheckNameAvailability, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + :param parameters: Parameters to check availability of the given namespace name. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.CheckNameAvailability + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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.v2021_06_01_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param parameters: Parameters to check availability of the given namespace name. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :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.v2021_06_01_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def check_name_availability( - self, - parameters: _models.CheckNameAvailability, - **kwargs: Any + self, parameters: Union[_models.CheckNameAvailability, IO], **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Check the give namespace name availability. - :param parameters: Parameters to check availability of the given namespace name. - :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.CheckNameAvailability + :param parameters: Parameters to check availability of the given namespace name. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.CheckNameAvailability or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameAvailabilityResult, or the result of cls(response) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResult] - _json = self._serialize.body(parameters, 'CheckNameAvailability') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _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'], + content=_content, + template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) @@ -1972,10 +2131,9 @@ def check_name_availability( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1983,12 +2141,11 @@ def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + 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 - + 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 638354888069..d6c8ef684a0e 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 @@ -7,10 +7,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- 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 urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -20,38 +25,34 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +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: + +def build_list_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.ServiceBus/operations") # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class Operations: """ @@ -72,36 +73,31 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.OperationListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """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) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -109,13 +105,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -131,10 +125,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -145,8 +137,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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/_patch.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_patch.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_06_01_preview/operations/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. 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 4ed15ed51fa4..44fafd1eb4d0 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 @@ -6,11 +6,16 @@ # 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, Iterable, Optional, TypeVar, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -22,134 +27,130 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - subscription_id: str, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, - *, - json: Optional[_models.PrivateEndpointConnection] = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( +def build_delete_request( resource_group_name: str, namespace_name: str, - subscription_id: str, private_endpoint_connection_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( @@ -162,33 +163,35 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class PrivateEndpointConnectionsOperations: """ @@ -209,46 +212,41 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> Iterable[_models.PrivateEndpointConnectionListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> Iterable["_models.PrivateEndpointConnection"]: """Gets the available PrivateEndpointConnections within a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: An iterator like instance of either PrivateEndpointConnection 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 + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnectionListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -256,16 +254,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -281,10 +274,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -295,60 +286,129 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 + @overload def create_or_update( self, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, parameters: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.PrivateEndpointConnection: """Creates or updates PrivateEndpointConnections of service namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param private_endpoint_connection_name: The PrivateEndpointConnection name. + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. :type private_endpoint_connection_name: str :param parameters: Parameters supplied to update Status of PrivateEndPoint Connection to - namespace resource. + namespace resource. Required. :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.PrivateEndpointConnection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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.v2021_06_01_preview.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Creates or updates PrivateEndpointConnections of service namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. + :type private_endpoint_connection_name: str + :param parameters: Parameters supplied to update Status of PrivateEndPoint Connection to + namespace resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateEndpointConnection, or the result of cls(response) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + parameters: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Creates or updates PrivateEndpointConnections of service namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. + :type private_endpoint_connection_name: str + :param parameters: Parameters supplied to update Status of PrivateEndPoint Connection to + namespace resource. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.PrivateEndpointConnection + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2021_06_01_preview.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - _json = self._serialize.body(parameters, 'PrivateEndpointConnection') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _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, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -356,10 +416,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -368,45 +427,37 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + 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 - + 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: str, - namespace_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_request_initial( + request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, - subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) @@ -414,37 +465,32 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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_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 @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + def begin_delete( + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param private_endpoint_connection_name: The PrivateEndpointConnection name. + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. :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. @@ -456,97 +502,83 @@ def begin_delete( # pylint: disable=inconsistent-return-statements 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + 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 = self._delete_initial( # type: ignore 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, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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: str, - namespace_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param private_endpoint_connection_name: The PrivateEndpointConnection name. + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. :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) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -554,10 +586,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -565,12 +596,11 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + 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 - + 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 572b3efe134c..648a1e005a80 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 @@ -8,9 +8,13 @@ # -------------------------------------------------------------------------- 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.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,48 +23,48 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class PrivateLinkResourcesOperations: """ @@ -81,43 +85,36 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def get( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: PrivateLinkResourcesListResult or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.PrivateLinkResourcesListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourcesListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResourcesListResult] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -125,10 +122,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -136,12 +132,11 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateLinkResourcesListResult', pipeline_response) + 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 - + 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 a25f0af9205b..b46048ff6b87 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 @@ -6,11 +6,16 @@ # 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, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -20,50 +25,48 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") 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 + resource_group_name: str, namespace_name: str, queue_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_authorization_rule_request( @@ -72,47 +75,43 @@ def build_create_or_update_authorization_rule_request( queue_name: str, authorization_rule_name: str, subscription_id: str, - *, - json: Optional[_models.SBAuthorizationRule] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_authorization_rule_request( @@ -126,34 +125,35 @@ def build_delete_authorization_rule_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_authorization_rule_request( @@ -167,34 +167,35 @@ def build_get_authorization_rule_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( @@ -208,34 +209,35 @@ def build_list_keys_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_regenerate_keys_request( @@ -244,47 +246,43 @@ def build_regenerate_keys_request( queue_name: str, authorization_rule_name: str, subscription_id: str, - *, - json: Optional[_models.RegenerateAccessKeyParameters] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_namespace_request( @@ -299,161 +297,141 @@ def build_list_by_namespace_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if skip is not None: - _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', maximum=1000, minimum=0) + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", maximum=1000, minimum=0) if top is not None: - _params['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - resource_group_name: str, - namespace_name: str, - queue_name: str, - subscription_id: str, - *, - json: Optional[_models.SBQueue] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, queue_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - namespace_name: str, - queue_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, queue_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - namespace_name: str, - queue_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, queue_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class QueuesOperations: """ @@ -474,50 +452,43 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - **kwargs: Any - ) -> Iterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, queue_name: str, **kwargs: Any + ) -> Iterable["_models.SBAuthorizationRule"]: """Gets all authorization rules for a queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :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) + :return: An iterator like instance of either SBAuthorizationRule 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 + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) @@ -525,17 +496,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -551,10 +516,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -565,13 +528,11 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 + @overload def create_or_update_authorization_rule( self, resource_group_name: str, @@ -579,38 +540,112 @@ def create_or_update_authorization_rule( queue_name: str, authorization_rule_name: str, parameters: _models.SBAuthorizationRule, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBAuthorizationRule: """Creates an authorization rule for a queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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.v2021_06_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for a queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: Union[_models.SBAuthorizationRule, IO], + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for a queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2021_06_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - _json = self._serialize.body(parameters, 'SBAuthorizationRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBAuthorizationRule") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -621,7 +656,8 @@ def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -629,10 +665,9 @@ def create_or_update_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -640,15 +675,14 @@ def create_or_update_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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 @@ -661,31 +695,28 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes a queue authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -693,7 +724,7 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_authorization_rule.metadata['url'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -701,10 +732,9 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -715,8 +745,7 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements 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( @@ -729,31 +758,28 @@ def get_authorization_rule( ) -> _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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -761,7 +787,7 @@ def get_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -769,10 +795,9 @@ def get_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -780,15 +805,14 @@ def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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( @@ -801,31 +825,28 @@ def list_keys( ) -> _models.AccessKeys: """Primary and secondary connection strings to the queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -833,7 +854,7 @@ def list_keys( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -841,10 +862,9 @@ def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -852,17 +872,16 @@ def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 - + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore - @distributed_trace + @overload def regenerate_keys( self, resource_group_name: str, @@ -870,39 +889,114 @@ def regenerate_keys( queue_name: str, authorization_rule_name: str, parameters: _models.RegenerateAccessKeyParameters, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.RegenerateAccessKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2021_06_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateAccessKeyParameters, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: + ~azure.mgmt.servicebus.v2021_06_01_preview.models.RegenerateAccessKeyParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2021_06_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateAccessKeyParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -913,7 +1007,8 @@ def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) @@ -921,10 +1016,9 @@ def regenerate_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -932,15 +1026,14 @@ def regenerate_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 - + 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( @@ -950,12 +1043,12 @@ def list_by_namespace( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable[_models.SBQueueListResult]: + ) -> Iterable["_models.SBQueue"]: """Gets the queues within a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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 @@ -965,32 +1058,30 @@ def list_by_namespace( 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] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either SBQueue or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBQueue] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBQueueListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + api_version=api_version, + template_url=self.list_by_namespace.metadata["url"], headers=_headers, params=_params, ) @@ -998,18 +1089,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -1025,10 +1109,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1039,49 +1121,115 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 + @overload def create_or_update( self, resource_group_name: str, namespace_name: str, queue_name: str, parameters: _models.SBQueue, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param parameters: Parameters supplied to create or update a queue resource. + :param parameters: Parameters supplied to create or update a queue resource. Required. :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBQueue + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBQueue, or the result of cls(response) + :return: SBQueue or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param parameters: Parameters supplied to create or update a queue resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2021_06_01_preview.models.SBQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + parameters: Union[_models.SBQueue, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param parameters: Parameters supplied to create or update a queue resource. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBQueue or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2021_06_01_preview.models.SBQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBQueue] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBQueue] - _json = self._serialize.body(parameters, 'SBQueue') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBQueue") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -1091,7 +1239,8 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -1099,10 +1248,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1110,56 +1258,48 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBQueue', pipeline_response) + 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 - + 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: str, - namespace_name: str, - queue_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -1167,10 +1307,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1181,49 +1320,39 @@ def delete( # pylint: disable=inconsistent-return-statements 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: str, - namespace_name: str, - queue_name: str, - **kwargs: Any - ) -> _models.SBQueue: + def get(self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :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) + :return: SBQueue or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBQueue] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBQueue] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -1231,10 +1360,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1242,12 +1370,11 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBQueue', pipeline_response) + 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 - + 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 c468fa9d4ef7..fd78a512fa38 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 @@ -6,11 +6,16 @@ # 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, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -20,13 +25,16 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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_subscriptions_request( resource_group_name: str, namespace_name: str, @@ -41,38 +49,37 @@ def build_list_by_subscriptions_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if skip is not None: - _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', maximum=1000, minimum=0) + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", maximum=1000, minimum=0) if top is not None: - _params['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( @@ -82,48 +89,42 @@ def build_create_or_update_request( subscription_name: str, rule_name: str, subscription_id: str, - *, - json: Optional[_models.Rule] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( @@ -138,35 +139,34 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( @@ -181,35 +181,35 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class RulesOperations: """ @@ -230,7 +230,6 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_by_subscriptions( self, @@ -241,16 +240,16 @@ def list_by_subscriptions( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable[_models.RuleListResult]: + ) -> Iterable["_models.Rule"]: """List all the rules within given topic-subscription. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :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 @@ -260,34 +259,32 @@ def list_by_subscriptions( 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] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Rule or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.Rule] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.RuleListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + api_version=api_version, + template_url=self.list_by_subscriptions.metadata["url"], headers=_headers, params=_params, ) @@ -295,20 +292,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -324,10 +312,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -338,13 +324,11 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 + @overload def create_or_update( self, resource_group_name: str, @@ -353,40 +337,120 @@ def create_or_update( subscription_name: str, rule_name: str, parameters: _models.Rule, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param rule_name: The rule name. + :param rule_name: The rule name. Required. :type rule_name: str - :param parameters: Parameters supplied to create a rule. + :param parameters: Parameters supplied to create a rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.Rule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Rule, or the result of cls(response) + :return: Rule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.Rule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param rule_name: The rule name. Required. + :type rule_name: str + :param parameters: Parameters supplied to create a rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2021_06_01_preview.models.Rule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + parameters: Union[_models.Rule, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param rule_name: The rule name. Required. + :type rule_name: str + :param parameters: Parameters supplied to create a rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.Rule or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2021_06_01_preview.models.Rule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Rule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Rule] - _json = self._serialize.body(parameters, 'Rule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Rule") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -398,7 +462,8 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -406,10 +471,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -417,15 +481,14 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Rule', pipeline_response) + 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 - + 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 @@ -439,33 +502,30 @@ def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes an existing rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param rule_name: The rule name. + :param rule_name: The rule name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -474,7 +534,7 @@ def delete( # pylint: disable=inconsistent-return-statements rule_name=rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -482,10 +542,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -496,8 +555,7 @@ def delete( # pylint: disable=inconsistent-return-statements 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( @@ -511,33 +569,30 @@ def get( ) -> _models.Rule: """Retrieves the description for the specified rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param rule_name: The rule name. + :param rule_name: The rule name. Required. :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) + :return: Rule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.Rule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Rule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Rule] - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -546,7 +601,7 @@ def get( rule_name=rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -554,10 +609,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -565,12 +619,11 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Rule', pipeline_response) + 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 - + 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 239045d04608..920f33b640d4 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 @@ -6,11 +6,16 @@ # 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, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -20,13 +25,16 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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_topic_request( resource_group_name: str, namespace_name: str, @@ -40,37 +48,36 @@ def build_list_by_topic_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if skip is not None: - _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', maximum=1000, minimum=0) + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", maximum=1000, minimum=0) if top is not None: - _params['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( @@ -79,47 +86,41 @@ def build_create_or_update_request( topic_name: str, subscription_name: str, subscription_id: str, - *, - json: Optional[_models.SBSubscription] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( @@ -133,34 +134,33 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( @@ -174,34 +174,34 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class SubscriptionsOperations: """ @@ -222,7 +222,6 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_by_topic( self, @@ -232,14 +231,14 @@ def list_by_topic( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable[_models.SBSubscriptionListResult]: + ) -> Iterable["_models.SBSubscription"]: """List all the subscriptions under a specified topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :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 @@ -249,34 +248,32 @@ def list_by_topic( 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) + :return: An iterator like instance of either SBSubscription 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 + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBSubscription] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBSubscriptionListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + api_version=api_version, + template_url=self.list_by_topic.metadata["url"], headers=_headers, params=_params, ) @@ -284,19 +281,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -312,10 +301,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -326,13 +313,11 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 + @overload def create_or_update( self, resource_group_name: str, @@ -340,38 +325,112 @@ def create_or_update( topic_name: str, subscription_name: str, parameters: _models.SBSubscription, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBSubscription: """Creates a topic subscription. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param parameters: Parameters supplied to create a subscription resource. + :param parameters: Parameters supplied to create a subscription resource. Required. :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBSubscription + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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.v2021_06_01_preview.models.SBSubscription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBSubscription: + """Creates a topic subscription. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param parameters: Parameters supplied to create a subscription resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2021_06_01_preview.models.SBSubscription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + parameters: Union[_models.SBSubscription, IO], + **kwargs: Any + ) -> _models.SBSubscription: + """Creates a topic subscription. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param parameters: Parameters supplied to create a subscription resource. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBSubscription or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBSubscription, or the result of cls(response) + :return: SBSubscription or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBSubscription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBSubscription] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBSubscription] - _json = self._serialize.body(parameters, 'SBSubscription') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBSubscription") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -382,7 +441,8 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -390,10 +450,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -401,52 +460,43 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBSubscription', pipeline_response) + 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 - + 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: str, - namespace_name: str, - topic_name: str, - subscription_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -454,7 +504,7 @@ def delete( # pylint: disable=inconsistent-return-statements subscription_name=subscription_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -462,10 +512,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -476,45 +525,36 @@ def delete( # pylint: disable=inconsistent-return-statements 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: str, - namespace_name: str, - topic_name: str, - subscription_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :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) + :return: SBSubscription or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBSubscription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBSubscription] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBSubscription] - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -522,7 +562,7 @@ def get( subscription_name=subscription_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -530,10 +570,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -541,12 +580,11 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBSubscription', pipeline_response) + 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 - + 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 ff59f799cffb..57724f8d7bc4 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 @@ -6,11 +6,16 @@ # 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, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -20,50 +25,48 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") 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 + resource_group_name: str, namespace_name: str, topic_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_authorization_rule_request( @@ -72,47 +75,43 @@ def build_create_or_update_authorization_rule_request( topic_name: str, authorization_rule_name: str, subscription_id: str, - *, - json: Optional[_models.SBAuthorizationRule] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_authorization_rule_request( @@ -126,34 +125,35 @@ def build_get_authorization_rule_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_authorization_rule_request( @@ -167,34 +167,35 @@ def build_delete_authorization_rule_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( @@ -208,34 +209,35 @@ def build_list_keys_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_regenerate_keys_request( @@ -244,47 +246,43 @@ def build_regenerate_keys_request( topic_name: str, authorization_rule_name: str, subscription_id: str, - *, - json: Optional[_models.RegenerateAccessKeyParameters] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_namespace_request( @@ -299,161 +297,141 @@ def build_list_by_namespace_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if skip is not None: - _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', maximum=1000, minimum=0) + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", maximum=1000, minimum=0) if top is not None: - _params['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_id: str, - *, - json: Optional[_models.SBTopic] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, topic_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, topic_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, topic_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class TopicsOperations: """ @@ -474,50 +452,43 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - **kwargs: Any - ) -> Iterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, topic_name: str, **kwargs: Any + ) -> Iterable["_models.SBAuthorizationRule"]: """Gets authorization rules for a topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :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) + :return: An iterator like instance of either SBAuthorizationRule 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 + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) @@ -525,17 +496,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -551,10 +516,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -565,13 +528,11 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 + @overload def create_or_update_authorization_rule( self, resource_group_name: str, @@ -579,38 +540,112 @@ def create_or_update_authorization_rule( topic_name: str, authorization_rule_name: str, parameters: _models.SBAuthorizationRule, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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.v2021_06_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: Union[_models.SBAuthorizationRule, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2021_06_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - _json = self._serialize.body(parameters, 'SBAuthorizationRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBAuthorizationRule") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -621,7 +656,8 @@ def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -629,10 +665,9 @@ def create_or_update_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -640,15 +675,14 @@ def create_or_update_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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( @@ -661,31 +695,28 @@ def get_authorization_rule( ) -> _models.SBAuthorizationRule: """Returns the specified authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -693,7 +724,7 @@ def get_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -701,10 +732,9 @@ def get_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -712,15 +742,14 @@ def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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 @@ -733,31 +762,28 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes a topic authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -765,7 +791,7 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_authorization_rule.metadata['url'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -773,10 +799,9 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -787,8 +812,7 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements 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( @@ -801,31 +825,28 @@ def list_keys( ) -> _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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -833,7 +854,7 @@ def list_keys( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -841,10 +862,9 @@ def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -852,17 +872,16 @@ def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 - + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore - @distributed_trace + @overload def regenerate_keys( self, resource_group_name: str, @@ -870,39 +889,114 @@ def regenerate_keys( topic_name: str, authorization_rule_name: str, parameters: _models.RegenerateAccessKeyParameters, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.RegenerateAccessKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2021_06_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateAccessKeyParameters, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: + ~azure.mgmt.servicebus.v2021_06_01_preview.models.RegenerateAccessKeyParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2021_06_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateAccessKeyParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -913,7 +1007,8 @@ def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) @@ -921,10 +1016,9 @@ def regenerate_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -932,15 +1026,14 @@ def regenerate_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 - + 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( @@ -950,12 +1043,12 @@ def list_by_namespace( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable[_models.SBTopicListResult]: + ) -> Iterable["_models.SBTopic"]: """Gets all the topics in a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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 @@ -965,32 +1058,30 @@ def list_by_namespace( 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] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either SBTopic or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_06_01_preview.models.SBTopic] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBTopicListResult] + api_version = kwargs.pop("api_version", _params.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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + api_version=api_version, + template_url=self.list_by_namespace.metadata["url"], headers=_headers, params=_params, ) @@ -998,18 +1089,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -1025,10 +1109,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1039,49 +1121,115 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 + @overload def create_or_update( self, resource_group_name: str, namespace_name: str, topic_name: str, parameters: _models.SBTopic, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBTopic: """Creates a topic in the specified namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param parameters: Parameters supplied to create a topic resource. + :param parameters: Parameters supplied to create a topic resource. Required. :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBTopic + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBTopic, or the result of cls(response) + :return: SBTopic or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBTopic - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBTopic: + """Creates a topic in the specified namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param parameters: Parameters supplied to create a topic resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2021_06_01_preview.models.SBTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + parameters: Union[_models.SBTopic, IO], + **kwargs: Any + ) -> _models.SBTopic: + """Creates a topic in the specified namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param parameters: Parameters supplied to create a topic resource. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBTopic or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2021_06_01_preview.models.SBTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBTopic] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBTopic] - _json = self._serialize.body(parameters, 'SBTopic') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBTopic") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -1091,7 +1239,8 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -1099,10 +1248,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1110,56 +1258,48 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBTopic', pipeline_response) + 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 - + 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: str, - namespace_name: str, - topic_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -1167,10 +1307,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1181,49 +1320,39 @@ def delete( # pylint: disable=inconsistent-return-statements 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: str, - namespace_name: str, - topic_name: str, - **kwargs: Any - ) -> _models.SBTopic: + def get(self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :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) + :return: SBTopic or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_06_01_preview.models.SBTopic - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBTopic] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBTopic] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -1231,10 +1360,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1242,12 +1370,11 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBTopic', pipeline_response) + 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 - + 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_11_01/__init__.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/__init__.py index 221541a00fb6..2a82b6cb6f69 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/__init__.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/__init__.py @@ -17,7 +17,8 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['ServiceBusManagementClient'] + +__all__ = ["ServiceBusManagementClient"] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/_configuration.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/_configuration.py index ab694134b482..e24f67631e6d 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/_configuration.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/_configuration.py @@ -25,24 +25,19 @@ class ServiceBusManagementClientConfiguration(Configuration): # pylint: disable Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :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. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2021-11-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(ServiceBusManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + api_version = kwargs.pop("api_version", "2021-11-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -52,23 +47,24 @@ def __init__( self.credential = credential self.subscription_id = subscription_id 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.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-servicebus/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> None - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(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_11_01/_metadata.json b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/_metadata.json index 50b90d818445..5f7cb574f842 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/_metadata.json +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/_metadata.json @@ -10,20 +10,20 @@ "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\"], \"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\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ServiceBusManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ServiceBusManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", + "signature": "subscription_id: str,", + "description": "Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", + "description": "Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/_patch.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/_patch.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/_service_bus_management_client.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/_service_bus_management_client.py index c02b067a6f3b..9d6a65b6495b 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/_service_bus_management_client.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/_service_bus_management_client.py @@ -9,20 +9,31 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import ServiceBusManagementClientConfiguration -from .operations import DisasterRecoveryConfigsOperations, MigrationConfigsOperations, NamespacesOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, QueuesOperations, RulesOperations, SubscriptionsOperations, TopicsOperations +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: # pylint: disable=too-many-instance-attributes + +class ServiceBusManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Azure Service Bus client for managing Namespace. :ivar namespaces: NamespacesOperations operations @@ -49,10 +60,10 @@ class ServiceBusManagementClient: # pylint: disable=too-many-instance-attribu :vartype rules: azure.mgmt.servicebus.v2021_11_01.operations.RulesOperations :ivar subscriptions: SubscriptionsOperations operations :vartype subscriptions: azure.mgmt.servicebus.v2021_11_01.operations.SubscriptionsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :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. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -70,50 +81,35 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ServiceBusManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + 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._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.namespaces = NamespacesOperations( - 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.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.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: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -122,7 +118,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/_vendor.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/_vendor.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/_vendor.py @@ -7,6 +7,7 @@ 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) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): 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 - ] + 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_11_01/_version.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/_version.py index 920456322fa1..9f1dc6e309ba 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/_version.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "8.1.0" +VERSION = "0.0.0 (it should be stable)" diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/__init__.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/__init__.py index e7dd87df1f93..ba757410f14a 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/__init__.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/__init__.py @@ -14,7 +14,8 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['ServiceBusManagementClient'] + +__all__ = ["ServiceBusManagementClient"] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/_configuration.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/_configuration.py index b2b6c2baf561..162dc6b0171e 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/_configuration.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/_configuration.py @@ -25,24 +25,19 @@ class ServiceBusManagementClientConfiguration(Configuration): # pylint: disable Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :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. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2021-11-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(ServiceBusManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + api_version = kwargs.pop("api_version", "2021-11-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -52,22 +47,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id 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.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-servicebus/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, - **kwargs: Any - ) -> None: - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(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_11_01/aio/_patch.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/_patch.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/_service_bus_management_client.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/_service_bus_management_client.py index ec9ebf8c6e76..8f9afc161a86 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/_service_bus_management_client.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/_service_bus_management_client.py @@ -9,20 +9,31 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import ServiceBusManagementClientConfiguration -from .operations import DisasterRecoveryConfigsOperations, MigrationConfigsOperations, NamespacesOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, QueuesOperations, RulesOperations, SubscriptionsOperations, TopicsOperations +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: # pylint: disable=too-many-instance-attributes + +class ServiceBusManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Azure Service Bus client for managing Namespace. :ivar namespaces: NamespacesOperations operations @@ -50,10 +61,10 @@ class ServiceBusManagementClient: # pylint: disable=too-many-instance-attribu :ivar subscriptions: SubscriptionsOperations operations :vartype subscriptions: azure.mgmt.servicebus.v2021_11_01.aio.operations.SubscriptionsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :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. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -71,50 +82,35 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ServiceBusManagementClientConfiguration(credential=credential, subscription_id=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._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.namespaces = NamespacesOperations( - 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.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.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 - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -123,7 +119,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/__init__.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/__init__.py index 5559ccd3746c..831edc36bd6b 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/__init__.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/__init__.py @@ -20,17 +20,18 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'NamespacesOperations', - 'PrivateEndpointConnectionsOperations', - 'PrivateLinkResourcesOperations', - 'Operations', - 'DisasterRecoveryConfigsOperations', - 'MigrationConfigsOperations', - 'QueuesOperations', - 'TopicsOperations', - 'RulesOperations', - 'SubscriptionsOperations', + "NamespacesOperations", + "PrivateEndpointConnectionsOperations", + "PrivateLinkResourcesOperations", + "Operations", + "DisasterRecoveryConfigsOperations", + "MigrationConfigsOperations", + "QueuesOperations", + "TopicsOperations", + "RulesOperations", + "SubscriptionsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_disaster_recovery_configs_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_disaster_recovery_configs_operations.py index 1b72791221cd..8dd72e36e89e 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_disaster_recovery_configs_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_disaster_recovery_configs_operations.py @@ -6,10 +6,17 @@ # 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, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +27,23 @@ 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') +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]] + class DisasterRecoveryConfigsOperations: """ .. warning:: @@ -43,46 +63,40 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.ArmDisasterRecoveryListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ArmDisasterRecovery"]: """Gets all Alias(Disaster Recovery configurations). - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: An iterator like instance of either ArmDisasterRecovery or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.ArmDisasterRecoveryListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.ArmDisasterRecovery] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ArmDisasterRecoveryListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -90,16 +104,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -115,10 +124,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -129,49 +136,117 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 + @overload async def create_or_update( self, resource_group_name: str, namespace_name: str, alias: str, parameters: _models.ArmDisasterRecovery, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Required. :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.ArmDisasterRecovery + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ArmDisasterRecovery or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.ArmDisasterRecovery or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ArmDisasterRecovery, or the result of cls(response) + :return: ArmDisasterRecovery or None or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.ArmDisasterRecovery or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: Union[_models.ArmDisasterRecovery, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). Is + either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.ArmDisasterRecovery or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ArmDisasterRecovery or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.ArmDisasterRecovery or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ArmDisasterRecovery]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ArmDisasterRecovery]] - _json = self._serialize.body(parameters, 'ArmDisasterRecovery') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ArmDisasterRecovery") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -181,7 +256,8 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -189,10 +265,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -202,56 +277,48 @@ async def create_or_update( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ArmDisasterRecovery', pipeline_response) + 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 - + 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, - alias: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -259,10 +326,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -273,49 +339,41 @@ async def delete( # pylint: disable=inconsistent-return-statements 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, - namespace_name: str, - alias: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :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) + :return: ArmDisasterRecovery or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.ArmDisasterRecovery - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ArmDisasterRecovery] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ArmDisasterRecovery] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -323,10 +381,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -334,57 +391,49 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ArmDisasterRecovery', pipeline_response) + 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 - + 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, - alias: str, - **kwargs: Any + self, 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. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.break_pairing.metadata["url"], headers=_headers, params=_params, ) @@ -392,10 +441,9 @@ async def break_pairing( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -406,50 +454,118 @@ async def break_pairing( # pylint: disable=inconsistent-return-statements 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 - @distributed_trace_async + @overload async def fail_over( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, alias: str, parameters: Optional[_models.FailoverProperties] = None, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). Default value is None. :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.FailoverProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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: + """ + + @overload + async def fail_over( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Default value is None. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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: + """ + + @distributed_trace_async + async def fail_over( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: Optional[Union[_models.FailoverProperties, IO]] = 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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). Is + either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.FailoverProperties or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - if parameters is not None: - _json = self._serialize.body(parameters, 'FailoverProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "FailoverProperties") + else: + _json = None request = build_fail_over_request( resource_group_name=resource_group_name, @@ -459,7 +575,8 @@ async def fail_over( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, json=_json, - template_url=self.fail_over.metadata['url'], + content=_content, + template_url=self.fail_over.metadata["url"], headers=_headers, params=_params, ) @@ -467,10 +584,9 @@ async def fail_over( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -481,52 +597,45 @@ async def fail_over( # pylint: disable=inconsistent-return-statements 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, - namespace_name: str, - alias: str, - **kwargs: Any - ) -> AsyncIterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, alias: str, **kwargs: Any + ) -> AsyncIterable["_models.SBAuthorizationRule"]: """Gets the authorization rules for a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :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) + :return: An iterator like instance of either SBAuthorizationRule or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) @@ -534,17 +643,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -560,10 +663,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -574,48 +675,38 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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, - namespace_name: str, - alias: str, - authorization_rule_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -623,7 +714,7 @@ async def get_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -631,10 +722,9 @@ async def get_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -642,52 +732,43 @@ async def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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, - namespace_name: str, - alias: str, - authorization_rule_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -695,7 +776,7 @@ async def list_keys( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -703,10 +784,9 @@ async def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -714,50 +794,111 @@ async def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 - + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}/listKeys"} # type: ignore - @distributed_trace_async + @overload async def check_name_availability( self, resource_group_name: str, namespace_name: str, parameters: _models.CheckNameAvailability, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Check the give namespace name availability. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters to check availability of the given namespace name. + :param parameters: Parameters to check availability of the given namespace name. Required. :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.CheckNameAvailability + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameAvailabilityResult, or the result of cls(response) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + async def check_name_availability( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters to check availability of the given namespace name. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :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.v2021_11_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, + resource_group_name: str, + namespace_name: str, + parameters: Union[_models.CheckNameAvailability, IO], + **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters to check availability of the given namespace name. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.CheckNameAvailability or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :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.v2021_11_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResult] - _json = self._serialize.body(parameters, 'CheckNameAvailability') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CheckNameAvailability") request = build_check_name_availability_request( resource_group_name=resource_group_name, @@ -766,7 +907,8 @@ async def check_name_availability( api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) @@ -774,10 +916,9 @@ async def check_name_availability( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -785,12 +926,11 @@ async def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + 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 - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/CheckNameAvailability"} # type: ignore diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_migration_configs_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_migration_configs_operations.py index 10db2092c99f..dc37beed0a23 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_migration_configs_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_migration_configs_operations.py @@ -6,10 +6,17 @@ # 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, Optional, TypeVar, Union, cast +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +29,19 @@ 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') +from ...operations._migration_configs_operations import ( + build_complete_migration_request, + build_create_and_start_migration_request, + 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]] + class MigrationConfigsOperations: """ .. warning:: @@ -45,46 +61,41 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.MigrationConfigListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.MigrationConfigProperties"]: """Gets all migrationConfigurations. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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 + :return: An iterator like instance of either MigrationConfigProperties or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.MigrationConfigListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.MigrationConfigProperties] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MigrationConfigListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -92,16 +103,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -117,10 +123,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -131,35 +135,37 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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, resource_group_name: str, namespace_name: str, config_name: Union[str, "_models.MigrationConfigurationName"], - parameters: _models.MigrationConfigProperties, + parameters: Union[_models.MigrationConfigProperties, IO], **kwargs: Any ) -> Optional[_models.MigrationConfigProperties]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.MigrationConfigProperties]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.MigrationConfigProperties]] - _json = self._serialize.body(parameters, 'MigrationConfigProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "MigrationConfigProperties") - request = build_create_and_start_migration_request_initial( + request = build_create_and_start_migration_request( resource_group_name=resource_group_name, namespace_name=namespace_name, config_name=config_name, @@ -167,7 +173,8 @@ async def _create_and_start_migration_initial( api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_and_start_migration_initial.metadata['url'], + content=_content, + template_url=self._create_and_start_migration_initial.metadata["url"], headers=_headers, params=_params, ) @@ -175,48 +182,92 @@ async def _create_and_start_migration_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) + 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 - + _create_and_start_migration_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore - @distributed_trace_async + @overload async def begin_create_and_start_migration( self, resource_group_name: str, namespace_name: str, config_name: Union[str, "_models.MigrationConfigurationName"], parameters: _models.MigrationConfigProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2021_11_01.models.MigrationConfigurationName - :param parameters: Parameters required to create Migration Configuration. + :param parameters: Parameters required to create Migration Configuration. Required. :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.MigrationConfigProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. + :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_11_01.models.MigrationConfigProperties] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_and_start_migration( + self, + resource_group_name: str, + namespace_name: str, + config_name: Union[str, "_models.MigrationConfigurationName"], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> 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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param config_name: The configuration name. Should always be "$default". "$default" Required. + :type config_name: str or ~azure.mgmt.servicebus.v2021_11_01.models.MigrationConfigurationName + :param parameters: Parameters required to create Migration Configuration. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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 @@ -229,20 +280,56 @@ async def begin_create_and_start_migration( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicebus.v2021_11_01.models.MigrationConfigProperties] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_and_start_migration( + self, + resource_group_name: str, + namespace_name: str, + config_name: Union[str, "_models.MigrationConfigurationName"], + parameters: Union[_models.MigrationConfigProperties, IO], + **kwargs: Any + ) -> 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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param config_name: The configuration name. Should always be "$default". "$default" Required. + :type config_name: str or ~azure.mgmt.servicebus.v2021_11_01.models.MigrationConfigurationName + :param parameters: Parameters required to create Migration Configuration. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.MigrationConfigProperties or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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_11_01.models.MigrationConfigProperties] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.MigrationConfigProperties] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MigrationConfigProperties] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + 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( # type: ignore resource_group_name=resource_group_name, @@ -251,39 +338,35 @@ async def begin_create_and_start_migration( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) + deserialized = self._deserialize("MigrationConfigProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, 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 + deserialization_callback=get_long_running_output, ) 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 + begin_create_and_start_migration.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -295,36 +378,33 @@ async def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes a MigrationConfiguration. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2021_11_01.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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -332,10 +412,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -346,8 +425,7 @@ async def delete( # pylint: disable=inconsistent-return-statements 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( @@ -359,36 +437,33 @@ async def get( ) -> _models.MigrationConfigProperties: """Retrieves Migration Config. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2021_11_01.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) + :return: MigrationConfigProperties or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.MigrationConfigProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MigrationConfigProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MigrationConfigProperties] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -396,10 +471,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -407,15 +481,14 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) + 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 - + 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 @@ -429,36 +502,33 @@ async def complete_migration( # pylint: disable=inconsistent-return-statements 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2021_11_01.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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.complete_migration.metadata["url"], headers=_headers, params=_params, ) @@ -466,10 +536,9 @@ async def complete_migration( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -480,8 +549,7 @@ async def complete_migration( # pylint: disable=inconsistent-return-statements 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 @distributed_trace_async async def revert( # pylint: disable=inconsistent-return-statements @@ -493,36 +561,33 @@ async def revert( # pylint: disable=inconsistent-return-statements ) -> None: """This operation reverts Migration. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2021_11_01.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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.revert.metadata["url"], headers=_headers, params=_params, ) @@ -530,10 +595,9 @@ async def revert( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -544,5 +608,4 @@ async def revert( # pylint: disable=inconsistent-return-statements 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_11_01/aio/operations/_namespaces_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_namespaces_operations.py index e50611106812..b7080954a2d0 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_namespaces_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_namespaces_operations.py @@ -6,10 +6,17 @@ # 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, Optional, TypeVar, Union, cast +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +29,29 @@ 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') +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, + build_delete_authorization_rule_request, + build_delete_request, + 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]] + class NamespacesOperations: """ .. warning:: @@ -45,38 +71,32 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.SBNamespaceListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.SBNamespace"]: """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) + :return: An iterator like instance of either SBNamespace or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.SBNamespaceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.SBNamespace] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespaceListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -84,14 +104,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -107,10 +124,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -121,47 +136,39 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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, - **kwargs: Any - ) -> AsyncIterable[_models.SBNamespaceListResult]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.SBNamespace"]: """Gets the available namespaces within a resource group. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :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) + :return: An iterator like instance of either SBNamespace or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.SBNamespaceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.SBNamespace] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespaceListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -169,15 +176,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -193,10 +196,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -207,41 +208,40 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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, - resource_group_name: str, - namespace_name: str, - parameters: _models.SBNamespace, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, parameters: Union[_models.SBNamespace, IO], **kwargs: Any ) -> Optional[_models.SBNamespace]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.SBNamespace]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.SBNamespace]] - _json = self._serialize.body(parameters, 'SBNamespace') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBNamespace") - request = build_create_or_update_request_initial( + request = build_create_or_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._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) @@ -249,48 +249,121 @@ async def _create_or_update_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SBNamespace', pipeline_response) + 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 - + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - @distributed_trace_async + @overload async def begin_create_or_update( self, resource_group_name: str, namespace_name: str, parameters: _models.SBNamespace, + *, + content_type: str = "application/json", **kwargs: Any ) -> 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters supplied to create a namespace resource. + :param parameters: Parameters supplied to create a namespace resource. Required. :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.SBNamespace + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. + :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_11_01.models.SBNamespace] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> 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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to create a namespace resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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_11_01.models.SBNamespace] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, resource_group_name: str, namespace_name: str, parameters: Union[_models.SBNamespace, IO], **kwargs: Any + ) -> 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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to create a namespace resource. Is either a model type + or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.SBNamespace or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -303,20 +376,17 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicebus.v2021_11_01.models.SBNamespace] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespace] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBNamespace] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + 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( # type: ignore resource_group_name=resource_group_name, @@ -324,64 +394,54 @@ async def begin_create_or_update( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, 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 + deserialization_callback=get_long_running_output, ) 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 + 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, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_request_initial( + request = build_delete_request( 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'], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) @@ -389,35 +449,29 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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_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 @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete(self, resource_group_name: str, namespace_name: str, **kwargs: Any) -> 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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. @@ -429,92 +483,77 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + 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( # type: ignore resource_group_name=resource_group_name, namespace_name=namespace_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, 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 + deserialization_callback=get_long_running_output, ) 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 + 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, - namespace_name: str, - **kwargs: Any - ) -> _models.SBNamespace: + async def get(self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: SBNamespace or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBNamespace - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespace] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBNamespace] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -522,10 +561,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -533,51 +571,114 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBNamespace', pipeline_response) + 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 - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - @distributed_trace_async + @overload async def update( self, resource_group_name: str, namespace_name: str, parameters: _models.SBNamespaceUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters supplied to update a namespace resource. + :param parameters: Parameters supplied to update a namespace resource. Required. :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.SBNamespaceUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBNamespace, or the result of cls(response) + :return: SBNamespace or None or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBNamespace or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + async def update( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> 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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to update a namespace resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBNamespace or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBNamespace or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + namespace_name: str, + parameters: Union[_models.SBNamespaceUpdateParameters, IO], + **kwargs: Any + ) -> 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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to update a namespace resource. Is either a model type + or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.SBNamespaceUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBNamespace or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBNamespace or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.SBNamespace]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.SBNamespace]] - _json = self._serialize.body(parameters, 'SBNamespaceUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBNamespaceUpdateParameters") request = build_update_request( resource_group_name=resource_group_name, @@ -586,7 +687,8 @@ async def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -594,10 +696,9 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -607,53 +708,113 @@ async def update( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SBNamespace', pipeline_response) + 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 - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - @distributed_trace_async + @overload async def create_or_update_network_rule_set( self, resource_group_name: str, namespace_name: str, parameters: _models.NetworkRuleSet, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.NetworkRuleSet: """Create or update NetworkRuleSet for a Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: The Namespace IpFilterRule. + :param parameters: The Namespace IpFilterRule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.NetworkRuleSet + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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.v2021_11_01.models.NetworkRuleSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_network_rule_set( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NetworkRuleSet: + """Create or update NetworkRuleSet for a Namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: The Namespace IpFilterRule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: NetworkRuleSet, or the result of cls(response) + :return: NetworkRuleSet or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.NetworkRuleSet - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace_async + async def create_or_update_network_rule_set( + self, + resource_group_name: str, + namespace_name: str, + parameters: Union[_models.NetworkRuleSet, IO], + **kwargs: Any + ) -> _models.NetworkRuleSet: + """Create or update NetworkRuleSet for a Namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: The Namespace IpFilterRule. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.NetworkRuleSet or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2021_11_01.models.NetworkRuleSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkRuleSet] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.NetworkRuleSet] - _json = self._serialize.body(parameters, 'NetworkRuleSet') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "NetworkRuleSet") request = build_create_or_update_network_rule_set_request( resource_group_name=resource_group_name, @@ -662,7 +823,8 @@ async def create_or_update_network_rule_set( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_network_rule_set.metadata['url'], + content=_content, + template_url=self.create_or_update_network_rule_set.metadata["url"], headers=_headers, params=_params, ) @@ -670,10 +832,9 @@ async def create_or_update_network_rule_set( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -681,52 +842,45 @@ async def create_or_update_network_rule_set( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('NetworkRuleSet', pipeline_response) + 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 - + 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, - namespace_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: NetworkRuleSet or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.NetworkRuleSet - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkRuleSet] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.NetworkRuleSet] - 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'], + template_url=self.get_network_rule_set.metadata["url"], headers=_headers, params=_params, ) @@ -734,10 +888,9 @@ async def get_network_rule_set( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -745,55 +898,49 @@ async def get_network_rule_set( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('NetworkRuleSet', pipeline_response) + 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 - + 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, - namespace_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.NetworkRuleSetListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.NetworkRuleSet"]: """Gets list of NetworkRuleSet for a Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: An iterator like instance of either NetworkRuleSet or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.NetworkRuleSetListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.NetworkRuleSet] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkRuleSetListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_network_rule_sets.metadata["url"], headers=_headers, params=_params, ) @@ -801,16 +948,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -826,10 +968,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -840,51 +980,44 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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, - namespace_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SBAuthorizationRule"]: """Gets the authorization rules for a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: An iterator like instance of either SBAuthorizationRule or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) @@ -892,16 +1025,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -917,10 +1045,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -931,49 +1057,115 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 + @overload async def create_or_update_authorization_rule( self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, parameters: _models.SBAuthorizationRule, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2021_11_01.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: Union[_models.SBAuthorizationRule, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2021_11_01.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - _json = self._serialize.body(parameters, 'SBAuthorizationRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBAuthorizationRule") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -983,7 +1175,8 @@ async def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -991,10 +1184,9 @@ async def create_or_update_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1002,56 +1194,48 @@ async def create_or_update_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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, - authorization_rule_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -1059,10 +1243,9 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1073,49 +1256,41 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat 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, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - 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'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -1123,10 +1298,9 @@ async def get_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1134,56 +1308,48 @@ async def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - 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'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1191,10 +1357,9 @@ async def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1202,53 +1367,120 @@ async def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 - + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys"} # type: ignore - @distributed_trace_async + @overload async def regenerate_keys( self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, parameters: _models.RegenerateAccessKeyParameters, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.RegenerateAccessKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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.v2021_11_01.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace_async + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateAccessKeyParameters, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.RegenerateAccessKeyParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2021_11_01.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateAccessKeyParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -1258,7 +1490,8 @@ async def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1266,10 +1499,9 @@ async def regenerate_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1277,51 +1509,91 @@ async def regenerate_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 + regenerate_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore + @overload + async def check_name_availability( + self, parameters: _models.CheckNameAvailability, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param parameters: Parameters to check availability of the given namespace name. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.CheckNameAvailability + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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.v2021_11_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param parameters: Parameters to check availability of the given namespace name. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :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.v2021_11_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def check_name_availability( - self, - parameters: _models.CheckNameAvailability, - **kwargs: Any + self, parameters: Union[_models.CheckNameAvailability, IO], **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Check the give namespace name availability. - :param parameters: Parameters to check availability of the given namespace name. - :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.CheckNameAvailability + :param parameters: Parameters to check availability of the given namespace name. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.CheckNameAvailability or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameAvailabilityResult, or the result of cls(response) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResult] - _json = self._serialize.body(parameters, 'CheckNameAvailability') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _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'], + content=_content, + template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) @@ -1329,10 +1601,9 @@ async def check_name_availability( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1340,12 +1611,11 @@ async def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + 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 - + 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_11_01/aio/operations/_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_operations.py index fdc33b7967a6..57c99446c516 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_operations.py @@ -7,9 +7,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +27,11 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class Operations: """ .. warning:: @@ -42,36 +51,31 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.OperationListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """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) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -79,13 +83,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -101,10 +103,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -115,8 +115,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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_11_01/aio/operations/_patch.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_patch.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_private_endpoint_connections_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_private_endpoint_connections_operations.py index df8a2914a8d2..49ff1a21e934 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_private_endpoint_connections_operations.py @@ -6,10 +6,17 @@ # 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, Optional, TypeVar, Union, cast +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +29,17 @@ 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') +from ...operations._private_endpoint_connections_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class PrivateEndpointConnectionsOperations: """ .. warning:: @@ -45,46 +59,41 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.PrivateEndpointConnectionListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PrivateEndpointConnection"]: """Gets the available PrivateEndpointConnections within a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.PrivateEndpointConnectionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnectionListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # 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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -92,16 +101,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -117,10 +121,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -131,60 +133,128 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 + @overload async def create_or_update( self, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, parameters: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.PrivateEndpointConnection: """Creates or updates PrivateEndpointConnections of service namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param private_endpoint_connection_name: The PrivateEndpointConnection name. + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. :type private_endpoint_connection_name: str :param parameters: Parameters supplied to update Status of PrivateEndPoint Connection to - namespace resource. + namespace resource. Required. :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.PrivateEndpointConnection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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.v2021_11_01.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Creates or updates PrivateEndpointConnections of service namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. + :type private_endpoint_connection_name: str + :param parameters: Parameters supplied to update Status of PrivateEndPoint Connection to + namespace resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2021_11_01.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + parameters: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Creates or updates PrivateEndpointConnections of service namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. + :type private_endpoint_connection_name: str + :param parameters: Parameters supplied to update Status of PrivateEndPoint Connection to + namespace resource. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.PrivateEndpointConnection or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateEndpointConnection, or the result of cls(response) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - _json = self._serialize.body(parameters, 'PrivateEndpointConnection') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _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, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -192,10 +262,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -204,48 +273,40 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + 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 - + 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, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_request_initial( + request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, - subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) @@ -253,37 +314,32 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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_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 @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes an existing Private Endpoint Connection. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param private_endpoint_connection_name: The PrivateEndpointConnection name. + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. :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. @@ -295,97 +351,83 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + 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( # type: ignore 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, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, 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 + deserialization_callback=get_long_running_output, ) 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 + 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, - namespace_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param private_endpoint_connection_name: The PrivateEndpointConnection name. + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. :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) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -393,10 +435,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -404,12 +445,11 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + 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 - + 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_11_01/aio/operations/_private_link_resources_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_private_link_resources_operations.py index ad4b657278b9..3eb72576eba3 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_private_link_resources_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_private_link_resources_operations.py @@ -8,7 +8,13 @@ # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Optional, TypeVar -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -19,9 +25,11 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._private_link_resources_operations import build_get_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class PrivateLinkResourcesOperations: """ .. warning:: @@ -41,43 +49,36 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async async def get( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: PrivateLinkResourcesListResult or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.PrivateLinkResourcesListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourcesListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResourcesListResult] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -85,10 +86,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -96,12 +96,11 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateLinkResourcesListResult', pipeline_response) + 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 - + 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_11_01/aio/operations/_queues_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_queues_operations.py index 483fd0d85122..02fe8b895c9f 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_queues_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_queues_operations.py @@ -6,10 +6,17 @@ # 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, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +27,23 @@ 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') +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]] + class QueuesOperations: """ .. warning:: @@ -43,50 +63,43 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, queue_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SBAuthorizationRule"]: """Gets all authorization rules for a queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :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) + :return: An iterator like instance of either SBAuthorizationRule or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) @@ -94,17 +107,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -120,10 +127,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -134,13 +139,11 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 + @overload async def create_or_update_authorization_rule( self, resource_group_name: str, @@ -148,38 +151,112 @@ async def create_or_update_authorization_rule( queue_name: str, authorization_rule_name: str, parameters: _models.SBAuthorizationRule, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBAuthorizationRule: """Creates an authorization rule for a queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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.v2021_11_01.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for a queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace_async + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: Union[_models.SBAuthorizationRule, IO], + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for a queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2021_11_01.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - _json = self._serialize.body(parameters, 'SBAuthorizationRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBAuthorizationRule") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -190,7 +267,8 @@ async def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -198,10 +276,9 @@ async def create_or_update_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -209,15 +286,14 @@ async def create_or_update_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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 @@ -230,31 +306,28 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat ) -> None: """Deletes a queue authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -262,7 +335,7 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_authorization_rule.metadata['url'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -270,10 +343,9 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -284,8 +356,7 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat 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( @@ -298,31 +369,28 @@ async def get_authorization_rule( ) -> _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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -330,7 +398,7 @@ async def get_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -338,10 +406,9 @@ async def get_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -349,15 +416,14 @@ async def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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( @@ -370,31 +436,28 @@ async def list_keys( ) -> _models.AccessKeys: """Primary and secondary connection strings to the queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -402,7 +465,7 @@ async def list_keys( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -410,10 +473,9 @@ async def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -421,17 +483,16 @@ async def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 - + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore - @distributed_trace_async + @overload async def regenerate_keys( self, resource_group_name: str, @@ -439,38 +500,112 @@ async def regenerate_keys( queue_name: str, authorization_rule_name: str, parameters: _models.RegenerateAccessKeyParameters, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.RegenerateAccessKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2021_11_01.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateAccessKeyParameters, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.RegenerateAccessKeyParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2021_11_01.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateAccessKeyParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -481,7 +616,8 @@ async def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) @@ -489,10 +625,9 @@ async def regenerate_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -500,15 +635,14 @@ async def regenerate_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 - + 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( @@ -518,12 +652,12 @@ def list_by_namespace( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable[_models.SBQueueListResult]: + ) -> AsyncIterable["_models.SBQueue"]: """Gets the queues within a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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 @@ -533,32 +667,31 @@ def list_by_namespace( 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) + :return: An iterator like instance of either SBQueue or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.SBQueueListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.SBQueue] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBQueueListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + api_version=api_version, + template_url=self.list_by_namespace.metadata["url"], headers=_headers, params=_params, ) @@ -566,18 +699,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -593,10 +719,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -607,49 +731,115 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 + @overload async def create_or_update( self, resource_group_name: str, namespace_name: str, queue_name: str, parameters: _models.SBQueue, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param parameters: Parameters supplied to create or update a queue resource. + :param parameters: Parameters supplied to create or update a queue resource. Required. :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.SBQueue + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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.v2021_11_01.models.SBQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param parameters: Parameters supplied to create or update a queue resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBQueue, or the result of cls(response) + :return: SBQueue or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + parameters: Union[_models.SBQueue, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param parameters: Parameters supplied to create or update a queue resource. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.SBQueue or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2021_11_01.models.SBQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBQueue] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBQueue] - _json = self._serialize.body(parameters, 'SBQueue') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBQueue") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -659,7 +849,8 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -667,10 +858,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -678,56 +868,48 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBQueue', pipeline_response) + 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 - + 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, - queue_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -735,10 +917,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -749,49 +930,41 @@ async def delete( # pylint: disable=inconsistent-return-statements 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, - namespace_name: str, - queue_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :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) + :return: SBQueue or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBQueue] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBQueue] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -799,10 +972,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -810,12 +982,11 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBQueue', pipeline_response) + 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 - + 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_11_01/aio/operations/_rules_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_rules_operations.py index a0a5ee36616d..fb89aac5b17a 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_rules_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_rules_operations.py @@ -6,10 +6,17 @@ # 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, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +27,17 @@ 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') +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]] + class RulesOperations: """ .. warning:: @@ -43,7 +57,6 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_by_subscriptions( self, @@ -54,16 +67,16 @@ def list_by_subscriptions( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable[_models.RuleListResult]: + ) -> AsyncIterable["_models.Rule"]: """List all the rules within given topic-subscription. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :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 @@ -73,34 +86,32 @@ def list_by_subscriptions( 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_11_01.models.RuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Rule or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.Rule] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.RuleListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + api_version=api_version, + template_url=self.list_by_subscriptions.metadata["url"], headers=_headers, params=_params, ) @@ -108,20 +119,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -137,10 +139,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -151,13 +151,11 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 + @overload async def create_or_update( self, resource_group_name: str, @@ -166,40 +164,120 @@ async def create_or_update( subscription_name: str, rule_name: str, parameters: _models.Rule, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param rule_name: The rule name. + :param rule_name: The rule name. Required. :type rule_name: str - :param parameters: Parameters supplied to create a rule. + :param parameters: Parameters supplied to create a rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.Rule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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.v2021_11_01.models.Rule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param rule_name: The rule name. Required. + :type rule_name: str + :param parameters: Parameters supplied to create a rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2021_11_01.models.Rule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + parameters: Union[_models.Rule, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param rule_name: The rule name. Required. + :type rule_name: str + :param parameters: Parameters supplied to create a rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.Rule or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Rule, or the result of cls(response) + :return: Rule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.Rule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Rule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Rule] - _json = self._serialize.body(parameters, 'Rule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Rule") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -211,7 +289,8 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -219,10 +298,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -230,15 +308,14 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Rule', pipeline_response) + 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 - + 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 @@ -252,33 +329,30 @@ async def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes an existing rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param rule_name: The rule name. + :param rule_name: The rule name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -287,7 +361,7 @@ async def delete( # pylint: disable=inconsistent-return-statements rule_name=rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -295,10 +369,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -309,8 +382,7 @@ async def delete( # pylint: disable=inconsistent-return-statements 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( @@ -324,33 +396,30 @@ async def get( ) -> _models.Rule: """Retrieves the description for the specified rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param rule_name: The rule name. + :param rule_name: The rule name. Required. :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) + :return: Rule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.Rule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Rule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Rule] - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -359,7 +428,7 @@ async def get( rule_name=rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -367,10 +436,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -378,12 +446,11 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Rule', pipeline_response) + 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 - + 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_11_01/aio/operations/_subscriptions_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_subscriptions_operations.py index 608bc9c2ced5..f186f8e85693 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_subscriptions_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_subscriptions_operations.py @@ -6,10 +6,17 @@ # 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, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +27,17 @@ 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') +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]] + class SubscriptionsOperations: """ .. warning:: @@ -43,7 +57,6 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_by_topic( self, @@ -53,14 +66,14 @@ def list_by_topic( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable[_models.SBSubscriptionListResult]: + ) -> AsyncIterable["_models.SBSubscription"]: """List all the subscriptions under a specified topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :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 @@ -70,34 +83,32 @@ def list_by_topic( 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) + :return: An iterator like instance of either SBSubscription or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.SBSubscriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.SBSubscription] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBSubscriptionListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + api_version=api_version, + template_url=self.list_by_topic.metadata["url"], headers=_headers, params=_params, ) @@ -105,19 +116,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -133,10 +136,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -147,13 +148,11 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 + @overload async def create_or_update( self, resource_group_name: str, @@ -161,38 +160,112 @@ async def create_or_update( topic_name: str, subscription_name: str, parameters: _models.SBSubscription, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBSubscription: """Creates a topic subscription. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param parameters: Parameters supplied to create a subscription resource. + :param parameters: Parameters supplied to create a subscription resource. Required. :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.SBSubscription + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBSubscription, or the result of cls(response) + :return: SBSubscription or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBSubscription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBSubscription: + """Creates a topic subscription. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param parameters: Parameters supplied to create a subscription resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2021_11_01.models.SBSubscription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + parameters: Union[_models.SBSubscription, IO], + **kwargs: Any + ) -> _models.SBSubscription: + """Creates a topic subscription. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param parameters: Parameters supplied to create a subscription resource. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.SBSubscription or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2021_11_01.models.SBSubscription + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBSubscription] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBSubscription] - _json = self._serialize.body(parameters, 'SBSubscription') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBSubscription") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -203,7 +276,8 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -211,10 +285,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -222,52 +295,43 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBSubscription', pipeline_response) + 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 - + 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, - topic_name: str, - subscription_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -275,7 +339,7 @@ async def delete( # pylint: disable=inconsistent-return-statements subscription_name=subscription_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -283,10 +347,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -297,45 +360,36 @@ async def delete( # pylint: disable=inconsistent-return-statements 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, - namespace_name: str, - topic_name: str, - subscription_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :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) + :return: SBSubscription or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBSubscription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBSubscription] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBSubscription] - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -343,7 +397,7 @@ async def get( subscription_name=subscription_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -351,10 +405,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -362,12 +415,11 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBSubscription', pipeline_response) + 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 - + 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_11_01/aio/operations/_topics_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_topics_operations.py index 5bc983be15ea..92a797c6896b 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_topics_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/aio/operations/_topics_operations.py @@ -6,10 +6,17 @@ # 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, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +27,23 @@ 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') +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]] + class TopicsOperations: """ .. warning:: @@ -43,50 +63,43 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, topic_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SBAuthorizationRule"]: """Gets authorization rules for a topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :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) + :return: An iterator like instance of either SBAuthorizationRule or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) @@ -94,17 +107,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -120,10 +127,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -134,13 +139,11 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 + @overload async def create_or_update_authorization_rule( self, resource_group_name: str, @@ -148,38 +151,112 @@ async def create_or_update_authorization_rule( topic_name: str, authorization_rule_name: str, parameters: _models.SBAuthorizationRule, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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.v2021_11_01.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace_async + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: Union[_models.SBAuthorizationRule, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2021_11_01.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - _json = self._serialize.body(parameters, 'SBAuthorizationRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBAuthorizationRule") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -190,7 +267,8 @@ async def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -198,10 +276,9 @@ async def create_or_update_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -209,15 +286,14 @@ async def create_or_update_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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( @@ -230,31 +306,28 @@ async def get_authorization_rule( ) -> _models.SBAuthorizationRule: """Returns the specified authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -262,7 +335,7 @@ async def get_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -270,10 +343,9 @@ async def get_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -281,15 +353,14 @@ async def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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 @@ -302,31 +373,28 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat ) -> None: """Deletes a topic authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -334,7 +402,7 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_authorization_rule.metadata['url'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -342,10 +410,9 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -356,8 +423,7 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat 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( @@ -370,31 +436,28 @@ async def list_keys( ) -> _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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -402,7 +465,7 @@ async def list_keys( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -410,10 +473,9 @@ async def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -421,17 +483,16 @@ async def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 - + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore - @distributed_trace_async + @overload async def regenerate_keys( self, resource_group_name: str, @@ -439,38 +500,112 @@ async def regenerate_keys( topic_name: str, authorization_rule_name: str, parameters: _models.RegenerateAccessKeyParameters, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.RegenerateAccessKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2021_11_01.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateAccessKeyParameters, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.RegenerateAccessKeyParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2021_11_01.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateAccessKeyParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -481,7 +616,8 @@ async def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) @@ -489,10 +625,9 @@ async def regenerate_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -500,15 +635,14 @@ async def regenerate_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 - + 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( @@ -518,12 +652,12 @@ def list_by_namespace( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable[_models.SBTopicListResult]: + ) -> AsyncIterable["_models.SBTopic"]: """Gets all the topics in a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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 @@ -533,32 +667,31 @@ def list_by_namespace( 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) + :return: An iterator like instance of either SBTopic or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.SBTopicListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.SBTopic] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBTopicListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + api_version=api_version, + template_url=self.list_by_namespace.metadata["url"], headers=_headers, params=_params, ) @@ -566,18 +699,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -593,10 +719,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -607,49 +731,115 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 + @overload async def create_or_update( self, resource_group_name: str, namespace_name: str, topic_name: str, parameters: _models.SBTopic, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBTopic: """Creates a topic in the specified namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param parameters: Parameters supplied to create a topic resource. + :param parameters: Parameters supplied to create a topic resource. Required. :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.SBTopic + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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.v2021_11_01.models.SBTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBTopic: + """Creates a topic in the specified namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param parameters: Parameters supplied to create a topic resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBTopic, or the result of cls(response) + :return: SBTopic or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBTopic - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + parameters: Union[_models.SBTopic, IO], + **kwargs: Any + ) -> _models.SBTopic: + """Creates a topic in the specified namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param parameters: Parameters supplied to create a topic resource. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.SBTopic or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2021_11_01.models.SBTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBTopic] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBTopic] - _json = self._serialize.body(parameters, 'SBTopic') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBTopic") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -659,7 +849,8 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -667,10 +858,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -678,56 +868,48 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBTopic', pipeline_response) + 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 - + 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, - topic_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -735,10 +917,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -749,49 +930,41 @@ async def delete( # pylint: disable=inconsistent-return-statements 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, - namespace_name: str, - topic_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :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) + :return: SBTopic or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBTopic - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBTopic] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBTopic] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -799,10 +972,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -810,12 +982,11 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBTopic', pipeline_response) + 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 - + 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_11_01/models/__init__.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/models/__init__.py index 078e68dd0be7..0f802b0b1027 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/models/__init__.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/models/__init__.py @@ -63,103 +63,101 @@ from ._models_py3 import UserAssignedIdentity from ._models_py3 import UserAssignedIdentityProperties - -from ._service_bus_management_client_enums import ( - AccessRights, - CreatedByType, - DefaultAction, - EndPointProvisioningState, - EntityStatus, - FilterType, - KeyType, - ManagedServiceIdentityType, - MigrationConfigurationName, - NetworkRuleIPAction, - PrivateLinkConnectionStatus, - ProvisioningStateDR, - PublicNetworkAccessFlag, - RoleDisasterRecovery, - SkuName, - SkuTier, - UnavailableReason, -) +from ._service_bus_management_client_enums import AccessRights +from ._service_bus_management_client_enums import CreatedByType +from ._service_bus_management_client_enums import DefaultAction +from ._service_bus_management_client_enums import EndPointProvisioningState +from ._service_bus_management_client_enums import EntityStatus +from ._service_bus_management_client_enums import FilterType +from ._service_bus_management_client_enums import KeyType +from ._service_bus_management_client_enums import ManagedServiceIdentityType +from ._service_bus_management_client_enums import MigrationConfigurationName +from ._service_bus_management_client_enums import NetworkRuleIPAction +from ._service_bus_management_client_enums import PrivateLinkConnectionStatus +from ._service_bus_management_client_enums import ProvisioningStateDR +from ._service_bus_management_client_enums import PublicNetworkAccessFlag +from ._service_bus_management_client_enums import RoleDisasterRecovery +from ._service_bus_management_client_enums import SkuName +from ._service_bus_management_client_enums import SkuTier +from ._service_bus_management_client_enums import UnavailableReason from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'AccessKeys', - 'Action', - 'ArmDisasterRecovery', - 'ArmDisasterRecoveryListResult', - 'CheckNameAvailability', - 'CheckNameAvailabilityResult', - 'ConnectionState', - 'CorrelationFilter', - 'Encryption', - 'ErrorAdditionalInfo', - 'ErrorResponse', - 'ErrorResponseError', - 'FailoverProperties', - 'Identity', - 'KeyVaultProperties', - 'MessageCountDetails', - 'MigrationConfigListResult', - 'MigrationConfigProperties', - 'NWRuleSetIpRules', - 'NWRuleSetVirtualNetworkRules', - 'NetworkRuleSet', - 'NetworkRuleSetListResult', - 'Operation', - 'OperationDisplay', - 'OperationListResult', - 'PrivateEndpoint', - 'PrivateEndpointConnection', - 'PrivateEndpointConnectionListResult', - 'PrivateLinkResource', - 'PrivateLinkResourcesListResult', - 'ProxyResource', - 'RegenerateAccessKeyParameters', - 'Resource', - 'ResourceNamespacePatch', - 'Rule', - 'RuleListResult', - 'SBAuthorizationRule', - 'SBAuthorizationRuleListResult', - 'SBClientAffineProperties', - 'SBNamespace', - 'SBNamespaceListResult', - 'SBNamespaceUpdateParameters', - 'SBQueue', - 'SBQueueListResult', - 'SBSku', - 'SBSubscription', - 'SBSubscriptionListResult', - 'SBTopic', - 'SBTopicListResult', - 'SqlFilter', - 'SqlRuleAction', - 'Subnet', - 'SystemData', - 'TrackedResource', - 'UserAssignedIdentity', - 'UserAssignedIdentityProperties', - 'AccessRights', - 'CreatedByType', - 'DefaultAction', - 'EndPointProvisioningState', - 'EntityStatus', - 'FilterType', - 'KeyType', - 'ManagedServiceIdentityType', - 'MigrationConfigurationName', - 'NetworkRuleIPAction', - 'PrivateLinkConnectionStatus', - 'ProvisioningStateDR', - 'PublicNetworkAccessFlag', - 'RoleDisasterRecovery', - 'SkuName', - 'SkuTier', - 'UnavailableReason', + "AccessKeys", + "Action", + "ArmDisasterRecovery", + "ArmDisasterRecoveryListResult", + "CheckNameAvailability", + "CheckNameAvailabilityResult", + "ConnectionState", + "CorrelationFilter", + "Encryption", + "ErrorAdditionalInfo", + "ErrorResponse", + "ErrorResponseError", + "FailoverProperties", + "Identity", + "KeyVaultProperties", + "MessageCountDetails", + "MigrationConfigListResult", + "MigrationConfigProperties", + "NWRuleSetIpRules", + "NWRuleSetVirtualNetworkRules", + "NetworkRuleSet", + "NetworkRuleSetListResult", + "Operation", + "OperationDisplay", + "OperationListResult", + "PrivateEndpoint", + "PrivateEndpointConnection", + "PrivateEndpointConnectionListResult", + "PrivateLinkResource", + "PrivateLinkResourcesListResult", + "ProxyResource", + "RegenerateAccessKeyParameters", + "Resource", + "ResourceNamespacePatch", + "Rule", + "RuleListResult", + "SBAuthorizationRule", + "SBAuthorizationRuleListResult", + "SBClientAffineProperties", + "SBNamespace", + "SBNamespaceListResult", + "SBNamespaceUpdateParameters", + "SBQueue", + "SBQueueListResult", + "SBSku", + "SBSubscription", + "SBSubscriptionListResult", + "SBTopic", + "SBTopicListResult", + "SqlFilter", + "SqlRuleAction", + "Subnet", + "SystemData", + "TrackedResource", + "UserAssignedIdentity", + "UserAssignedIdentityProperties", + "AccessRights", + "CreatedByType", + "DefaultAction", + "EndPointProvisioningState", + "EntityStatus", + "FilterType", + "KeyType", + "ManagedServiceIdentityType", + "MigrationConfigurationName", + "NetworkRuleIPAction", + "PrivateLinkConnectionStatus", + "ProvisioningStateDR", + "PublicNetworkAccessFlag", + "RoleDisasterRecovery", + "SkuName", + "SkuTier", + "UnavailableReason", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/models/_models_py3.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/models/_models_py3.py index 9149f29eb3f1..e40aa5e705f0 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/models/_models_py3.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -7,17 +8,22 @@ # -------------------------------------------------------------------------- import datetime +import sys from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - import __init__ as _models + from .. import models as _models +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class AccessKeys(msrest.serialization.Model): +class AccessKeys(_serialization.Model): """Namespace/ServiceBus Connection String. Variables are only populated by the server, and will be ignored when sending a request. @@ -45,32 +51,28 @@ class AccessKeys(msrest.serialization.Model): """ _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}, + "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) + "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().__init__(**kwargs) self.primary_connection_string = None self.secondary_connection_string = None self.alias_primary_connection_string = None @@ -80,7 +82,7 @@ def __init__( self.key_name = None -class Action(msrest.serialization.Model): +class Action(_serialization.Model): """Represents the filter actions which are allowed for the transformation of a message that have been matched by a filter expression. :ivar sql_expression: SQL expression. e.g. MyProperty='ABC'. @@ -94,9 +96,9 @@ class Action(msrest.serialization.Model): """ _attribute_map = { - 'sql_expression': {'key': 'sqlExpression', 'type': 'str'}, - 'compatibility_level': {'key': 'compatibilityLevel', 'type': 'int'}, - 'requires_preprocessing': {'key': 'requiresPreprocessing', 'type': 'bool'}, + "sql_expression": {"key": "sqlExpression", "type": "str"}, + "compatibility_level": {"key": "compatibilityLevel", "type": "int"}, + "requires_preprocessing": {"key": "requiresPreprocessing", "type": "bool"}, } def __init__( @@ -104,7 +106,7 @@ def __init__( *, sql_expression: Optional[str] = None, compatibility_level: Optional[int] = None, - requires_preprocessing: Optional[bool] = True, + requires_preprocessing: bool = True, **kwargs ): """ @@ -117,13 +119,13 @@ def __init__( preprocessing. :paramtype requires_preprocessing: bool """ - super(Action, self).__init__(**kwargs) + super().__init__(**kwargs) self.sql_expression = sql_expression self.compatibility_level = compatibility_level self.requires_preprocessing = requires_preprocessing -class ProxyResource(msrest.serialization.Model): +class ProxyResource(_serialization.Model): """Common fields that are returned in the response for all Azure Resource Manager resources. Variables are only populated by the server, and will be ignored when sending a request. @@ -141,26 +143,22 @@ class ProxyResource(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ProxyResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -186,11 +184,11 @@ class ArmDisasterRecovery(ProxyResource): :vartype system_data: ~azure.mgmt.servicebus.v2021_11_01.models.SystemData :ivar provisioning_state: Provisioning state of the Alias(Disaster Recovery configuration) - possible values 'Accepted' or 'Succeeded' or 'Failed'. Known values are: "Accepted", - "Succeeded", "Failed". + "Succeeded", and "Failed". :vartype provisioning_state: str or ~azure.mgmt.servicebus.v2021_11_01.models.ProvisioningStateDR :ivar pending_replication_operations_count: Number of entities pending to be replicated. - :vartype pending_replication_operations_count: long + :vartype pending_replication_operations_count: int :ivar partner_namespace: ARM Id of the Primary/Secondary eventhub namespace name, which is part of GEO DR pairing. :vartype partner_namespace: str @@ -198,41 +196,35 @@ class ArmDisasterRecovery(ProxyResource): pairing. :vartype alternate_name: str :ivar role: role of namespace in GEO DR - possible values 'Primary' or 'PrimaryNotReplicating' - or 'Secondary'. Known values are: "Primary", "PrimaryNotReplicating", "Secondary". + or 'Secondary'. Known values are: "Primary", "PrimaryNotReplicating", and "Secondary". :vartype role: str or ~azure.mgmt.servicebus.v2021_11_01.models.RoleDisasterRecovery """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'pending_replication_operations_count': {'readonly': True}, - 'role': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"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'}, - 'location': {'key': 'location', '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'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "pending_replication_operations_count": {"key": "properties.pendingReplicationOperationsCount", "type": "int"}, + "partner_namespace": {"key": "properties.partnerNamespace", "type": "str"}, + "alternate_name": {"key": "properties.alternateName", "type": "str"}, + "role": {"key": "properties.role", "type": "str"}, } - def __init__( - self, - *, - partner_namespace: Optional[str] = None, - alternate_name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, partner_namespace: Optional[str] = None, 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. @@ -241,7 +233,7 @@ def __init__( pairing. :paramtype alternate_name: str """ - super(ArmDisasterRecovery, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.provisioning_state = None self.pending_replication_operations_count = None @@ -250,7 +242,7 @@ def __init__( self.role = None -class ArmDisasterRecoveryListResult(msrest.serialization.Model): +class ArmDisasterRecoveryListResult(_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. @@ -263,65 +255,55 @@ class ArmDisasterRecoveryListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ArmDisasterRecovery]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ArmDisasterRecovery]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.ArmDisasterRecovery"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.ArmDisasterRecovery"]] = None, **kwargs): """ :keyword value: List of Alias(Disaster Recovery configurations). :paramtype value: list[~azure.mgmt.servicebus.v2021_11_01.models.ArmDisasterRecovery] """ - super(ArmDisasterRecoveryListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class CheckNameAvailability(msrest.serialization.Model): +class CheckNameAvailability(_serialization.Model): """Description of a Check Name availability request properties. All required parameters must be populated in order to send to Azure. - :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. + :ivar name: 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. Required. :vartype name: str """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - name: str, - **kwargs - ): + def __init__(self, *, 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. + :keyword name: 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. Required. :paramtype name: str """ - super(CheckNameAvailability, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class CheckNameAvailabilityResult(msrest.serialization.Model): +class CheckNameAvailabilityResult(_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. @@ -332,19 +314,19 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): available; otherwise, false. :vartype name_available: bool :ivar reason: The reason for unavailability of a namespace. Known values are: "None", - "InvalidName", "SubscriptionIsDisabled", "NameInUse", "NameInLockdown", + "InvalidName", "SubscriptionIsDisabled", "NameInUse", "NameInLockdown", and "TooManyNamespaceInCurrentSubscription". :vartype reason: str or ~azure.mgmt.servicebus.v2021_11_01.models.UnavailableReason """ _validation = { - 'message': {'readonly': True}, + "message": {"readonly": True}, } _attribute_map = { - 'message': {'key': 'message', 'type': 'str'}, - 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, - 'reason': {'key': 'reason', 'type': 'str'}, + "message": {"key": "message", "type": "str"}, + "name_available": {"key": "nameAvailable", "type": "bool"}, + "reason": {"key": "reason", "type": "str"}, } def __init__( @@ -359,29 +341,29 @@ def __init__( available; otherwise, false. :paramtype name_available: bool :keyword reason: The reason for unavailability of a namespace. Known values are: "None", - "InvalidName", "SubscriptionIsDisabled", "NameInUse", "NameInLockdown", + "InvalidName", "SubscriptionIsDisabled", "NameInUse", "NameInLockdown", and "TooManyNamespaceInCurrentSubscription". :paramtype reason: str or ~azure.mgmt.servicebus.v2021_11_01.models.UnavailableReason """ - super(CheckNameAvailabilityResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.message = None self.name_available = name_available self.reason = reason -class ConnectionState(msrest.serialization.Model): +class ConnectionState(_serialization.Model): """ConnectionState information. :ivar status: Status of the connection. Known values are: "Pending", "Approved", "Rejected", - "Disconnected". + and "Disconnected". :vartype status: str or ~azure.mgmt.servicebus.v2021_11_01.models.PrivateLinkConnectionStatus :ivar description: Description of the connection state. :vartype description: str """ _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "status": {"key": "status", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -393,17 +375,17 @@ def __init__( ): """ :keyword status: Status of the connection. Known values are: "Pending", "Approved", "Rejected", - "Disconnected". + and "Disconnected". :paramtype status: str or ~azure.mgmt.servicebus.v2021_11_01.models.PrivateLinkConnectionStatus :keyword description: Description of the connection state. :paramtype description: str """ - super(ConnectionState, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status self.description = description -class CorrelationFilter(msrest.serialization.Model): +class CorrelationFilter(_serialization.Model): """Represents the correlation filter expression. :ivar properties: dictionary object for custom filters. @@ -430,16 +412,16 @@ class CorrelationFilter(msrest.serialization.Model): """ _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'}, + "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__( @@ -454,7 +436,7 @@ def __init__( session_id: Optional[str] = None, reply_to_session_id: Optional[str] = None, content_type: Optional[str] = None, - requires_preprocessing: Optional[bool] = True, + requires_preprocessing: bool = True, **kwargs ): """ @@ -480,7 +462,7 @@ def __init__( preprocessing. :paramtype requires_preprocessing: bool """ - super(CorrelationFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.correlation_id = correlation_id self.message_id = message_id @@ -493,14 +475,13 @@ def __init__( self.requires_preprocessing = requires_preprocessing -class Encryption(msrest.serialization.Model): +class Encryption(_serialization.Model): """Properties to configure Encryption. :ivar key_vault_properties: Properties of KeyVault. :vartype key_vault_properties: list[~azure.mgmt.servicebus.v2021_11_01.models.KeyVaultProperties] - :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 + :ivar key_source: Enumerates the possible value of keySource for Encryption. Default value is "Microsoft.KeyVault". :vartype key_source: str :ivar require_infrastructure_encryption: Enable Infrastructure Encryption (Double Encryption). @@ -508,16 +489,16 @@ class Encryption(msrest.serialization.Model): """ _attribute_map = { - 'key_vault_properties': {'key': 'keyVaultProperties', 'type': '[KeyVaultProperties]'}, - 'key_source': {'key': 'keySource', 'type': 'str'}, - 'require_infrastructure_encryption': {'key': 'requireInfrastructureEncryption', 'type': 'bool'}, + "key_vault_properties": {"key": "keyVaultProperties", "type": "[KeyVaultProperties]"}, + "key_source": {"key": "keySource", "type": "str"}, + "require_infrastructure_encryption": {"key": "requireInfrastructureEncryption", "type": "bool"}, } def __init__( self, *, key_vault_properties: Optional[List["_models.KeyVaultProperties"]] = None, - key_source: Optional[str] = "Microsoft.KeyVault", + key_source: str = "Microsoft.KeyVault", require_infrastructure_encryption: Optional[bool] = None, **kwargs ): @@ -525,21 +506,20 @@ def __init__( :keyword key_vault_properties: Properties of KeyVault. :paramtype key_vault_properties: list[~azure.mgmt.servicebus.v2021_11_01.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". + :keyword key_source: Enumerates the possible value of keySource for Encryption. 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) + super().__init__(**kwargs) self.key_vault_properties = key_vault_properties self.key_source = key_source self.require_infrastructure_encryption = require_infrastructure_encryption -class ErrorAdditionalInfo(msrest.serialization.Model): +class ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. Variables are only populated by the server, and will be ignored when sending a request. @@ -547,31 +527,27 @@ class ErrorAdditionalInfo(msrest.serialization.Model): :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. - :vartype info: any + :vartype info: JSON """ _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, + "type": {"readonly": True}, + "info": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorAdditionalInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.info = None -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """The resource management error response. :ivar error: The error object. @@ -579,24 +555,19 @@ class ErrorResponse(msrest.serialization.Model): """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponseError'}, + "error": {"key": "error", "type": "ErrorResponseError"}, } - def __init__( - self, - *, - error: Optional["_models.ErrorResponseError"] = None, - **kwargs - ): + def __init__(self, *, error: Optional["_models.ErrorResponseError"] = None, **kwargs): """ :keyword error: The error object. :paramtype error: ~azure.mgmt.servicebus.v2021_11_01.models.ErrorResponseError """ - super(ErrorResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error -class ErrorResponseError(msrest.serialization.Model): +class ErrorResponseError(_serialization.Model): """The error object. Variables are only populated by the server, and will be ignored when sending a request. @@ -614,28 +585,24 @@ class ErrorResponseError(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, + "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]'}, + "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) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.message = None self.target = None @@ -643,7 +610,7 @@ def __init__( self.additional_info = None -class FailoverProperties(msrest.serialization.Model): +class FailoverProperties(_serialization.Model): """Safe failover is to indicate the service should wait for pending replication to finish before switching to the secondary. :ivar is_safe_failover: Safe failover is to indicate the service should wait for pending @@ -652,25 +619,20 @@ class FailoverProperties(msrest.serialization.Model): """ _attribute_map = { - 'is_safe_failover': {'key': 'properties.IsSafeFailover', 'type': 'bool'}, + "is_safe_failover": {"key": "properties.IsSafeFailover", "type": "bool"}, } - def __init__( - self, - *, - is_safe_failover: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, 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) + super().__init__(**kwargs) self.is_safe_failover = is_safe_failover -class Identity(msrest.serialization.Model): +class Identity(_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. @@ -680,7 +642,7 @@ class Identity(msrest.serialization.Model): :ivar tenant_id: TenantId from the KeyVault. :vartype tenant_id: str :ivar type: Type of managed service identity. Known values are: "SystemAssigned", - "UserAssigned", "SystemAssigned, UserAssigned", "None". + "UserAssigned", "SystemAssigned, UserAssigned", and "None". :vartype type: str or ~azure.mgmt.servicebus.v2021_11_01.models.ManagedServiceIdentityType :ivar user_assigned_identities: Properties for User Assigned Identities. :vartype user_assigned_identities: dict[str, @@ -688,15 +650,15 @@ class Identity(msrest.serialization.Model): """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, + "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}'}, + "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__( @@ -708,20 +670,20 @@ def __init__( ): """ :keyword type: Type of managed service identity. Known values are: "SystemAssigned", - "UserAssigned", "SystemAssigned, UserAssigned", "None". + "UserAssigned", "SystemAssigned, UserAssigned", and "None". :paramtype type: str or ~azure.mgmt.servicebus.v2021_11_01.models.ManagedServiceIdentityType :keyword user_assigned_identities: Properties for User Assigned Identities. :paramtype user_assigned_identities: dict[str, ~azure.mgmt.servicebus.v2021_11_01.models.UserAssignedIdentity] """ - super(Identity, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = None self.tenant_id = None self.type = type self.user_assigned_identities = user_assigned_identities -class KeyVaultProperties(msrest.serialization.Model): +class KeyVaultProperties(_serialization.Model): """Properties to configure keyVault Properties. :ivar key_name: Name of the Key from KeyVault. @@ -735,10 +697,10 @@ class KeyVaultProperties(msrest.serialization.Model): """ _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'}, + "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__( @@ -760,54 +722,50 @@ def __init__( :keyword identity: :paramtype identity: ~azure.mgmt.servicebus.v2021_11_01.models.UserAssignedIdentityProperties """ - super(KeyVaultProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_name = key_name self.key_vault_uri = key_vault_uri self.key_version = key_version self.identity = identity -class MessageCountDetails(msrest.serialization.Model): +class MessageCountDetails(_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 + :vartype active_message_count: int :ivar dead_letter_message_count: Number of messages that are dead lettered. - :vartype dead_letter_message_count: long + :vartype dead_letter_message_count: int :ivar scheduled_message_count: Number of scheduled messages. - :vartype scheduled_message_count: long + :vartype scheduled_message_count: int :ivar transfer_message_count: Number of messages transferred to another queue, topic, or subscription. - :vartype transfer_message_count: long + :vartype transfer_message_count: int :ivar transfer_dead_letter_message_count: Number of messages transferred into dead letters. - :vartype transfer_dead_letter_message_count: long + :vartype transfer_dead_letter_message_count: int """ _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}, + "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'}, + "active_message_count": {"key": "activeMessageCount", "type": "int"}, + "dead_letter_message_count": {"key": "deadLetterMessageCount", "type": "int"}, + "scheduled_message_count": {"key": "scheduledMessageCount", "type": "int"}, + "transfer_message_count": {"key": "transferMessageCount", "type": "int"}, + "transfer_dead_letter_message_count": {"key": "transferDeadLetterMessageCount", "type": "int"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(MessageCountDetails, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.active_message_count = None self.dead_letter_message_count = None self.scheduled_message_count = None @@ -815,7 +773,7 @@ def __init__( self.transfer_dead_letter_message_count = None -class MigrationConfigListResult(msrest.serialization.Model): +class MigrationConfigListResult(_serialization.Model): """The result of the List migrationConfigurations operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -828,25 +786,20 @@ class MigrationConfigListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[MigrationConfigProperties]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[MigrationConfigProperties]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.MigrationConfigProperties"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.MigrationConfigProperties"]] = None, **kwargs): """ :keyword value: List of Migration Configs. :paramtype value: list[~azure.mgmt.servicebus.v2021_11_01.models.MigrationConfigProperties] """ - super(MigrationConfigListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None @@ -871,7 +824,7 @@ class MigrationConfigProperties(ProxyResource): :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 + :vartype pending_replication_operations_count: int :ivar target_namespace: Existing premium Namespace ARM Id name which has no entities, will be used for migration. :vartype target_namespace: str @@ -883,36 +836,30 @@ class MigrationConfigProperties(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'pending_replication_operations_count': {'readonly': True}, - 'migration_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"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'}, - 'location': {'key': 'location', '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'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "pending_replication_operations_count": {"key": "properties.pendingReplicationOperationsCount", "type": "int"}, + "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, - *, - target_namespace: Optional[str] = None, - post_migration_name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, target_namespace: Optional[str] = None, 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. @@ -920,7 +867,7 @@ def __init__( :keyword post_migration_name: Name to access Standard Namespace after migration. :paramtype post_migration_name: str """ - super(MigrationConfigProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.provisioning_state = None self.pending_replication_operations_count = None @@ -949,7 +896,8 @@ class NetworkRuleSet(ProxyResource): :ivar trusted_service_access_enabled: Value that indicates whether Trusted Service Access is Enabled or not. :vartype trusted_service_access_enabled: bool - :ivar default_action: Default Action for Network Rule Set. Known values are: "Allow", "Deny". + :ivar default_action: Default Action for Network Rule Set. Known values are: "Allow" and + "Deny". :vartype default_action: str or ~azure.mgmt.servicebus.v2021_11_01.models.DefaultAction :ivar virtual_network_rules: List VirtualNetwork Rules. :vartype virtual_network_rules: @@ -957,30 +905,30 @@ class NetworkRuleSet(ProxyResource): :ivar ip_rules: List of IpRules. :vartype ip_rules: list[~azure.mgmt.servicebus.v2021_11_01.models.NWRuleSetIpRules] :ivar public_network_access: This determines if traffic is allowed over public network. By - default it is enabled. Known values are: "Enabled", "Disabled". Default value: "Enabled". + default it is enabled. Known values are: "Enabled" and "Disabled". :vartype public_network_access: str or ~azure.mgmt.servicebus.v2021_11_01.models.PublicNetworkAccessFlag """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'readonly': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"readonly": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', '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'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "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__( @@ -990,14 +938,14 @@ def __init__( default_action: Optional[Union[str, "_models.DefaultAction"]] = None, virtual_network_rules: Optional[List["_models.NWRuleSetVirtualNetworkRules"]] = None, ip_rules: Optional[List["_models.NWRuleSetIpRules"]] = None, - public_network_access: Optional[Union[str, "_models.PublicNetworkAccessFlag"]] = "Enabled", + public_network_access: Union[str, "_models.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. Known values are: "Allow", + :keyword default_action: Default Action for Network Rule Set. Known values are: "Allow" and "Deny". :paramtype default_action: str or ~azure.mgmt.servicebus.v2021_11_01.models.DefaultAction :keyword virtual_network_rules: List VirtualNetwork Rules. @@ -1006,11 +954,11 @@ def __init__( :keyword ip_rules: List of IpRules. :paramtype ip_rules: list[~azure.mgmt.servicebus.v2021_11_01.models.NWRuleSetIpRules] :keyword public_network_access: This determines if traffic is allowed over public network. By - default it is enabled. Known values are: "Enabled", "Disabled". Default value: "Enabled". + default it is enabled. Known values are: "Enabled" and "Disabled". :paramtype public_network_access: str or ~azure.mgmt.servicebus.v2021_11_01.models.PublicNetworkAccessFlag """ - super(NetworkRuleSet, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.trusted_service_access_enabled = trusted_service_access_enabled self.default_action = default_action @@ -1019,7 +967,7 @@ def __init__( self.public_network_access = public_network_access -class NetworkRuleSetListResult(msrest.serialization.Model): +class NetworkRuleSetListResult(_serialization.Model): """The response of the List NetworkRuleSet operation. :ivar value: Result of the List NetworkRuleSet operation. @@ -1030,16 +978,12 @@ class NetworkRuleSetListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[NetworkRuleSet]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[NetworkRuleSet]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.NetworkRuleSet"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.NetworkRuleSet"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Result of the List NetworkRuleSet operation. @@ -1048,44 +992,40 @@ def __init__( list of NetworkRuleSet. :paramtype next_link: str """ - super(NetworkRuleSetListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class NWRuleSetIpRules(msrest.serialization.Model): +class NWRuleSetIpRules(_serialization.Model): """Description of NetWorkRuleSet - IpRules resource. :ivar ip_mask: IP Mask. :vartype ip_mask: str - :ivar action: The IP Filter Action. Known values are: "Allow". Default value: "Allow". + :ivar action: The IP Filter Action. "Allow" :vartype action: str or ~azure.mgmt.servicebus.v2021_11_01.models.NetworkRuleIPAction """ _attribute_map = { - 'ip_mask': {'key': 'ipMask', 'type': 'str'}, - 'action': {'key': 'action', 'type': 'str'}, + "ip_mask": {"key": "ipMask", "type": "str"}, + "action": {"key": "action", "type": "str"}, } def __init__( - self, - *, - ip_mask: Optional[str] = None, - action: Optional[Union[str, "_models.NetworkRuleIPAction"]] = "Allow", - **kwargs + self, *, ip_mask: Optional[str] = None, action: Union[str, "_models.NetworkRuleIPAction"] = "Allow", **kwargs ): """ :keyword ip_mask: IP Mask. :paramtype ip_mask: str - :keyword action: The IP Filter Action. Known values are: "Allow". Default value: "Allow". + :keyword action: The IP Filter Action. "Allow" :paramtype action: str or ~azure.mgmt.servicebus.v2021_11_01.models.NetworkRuleIPAction """ - super(NWRuleSetIpRules, self).__init__(**kwargs) + super().__init__(**kwargs) self.ip_mask = ip_mask self.action = action -class NWRuleSetVirtualNetworkRules(msrest.serialization.Model): +class NWRuleSetVirtualNetworkRules(_serialization.Model): """Description of VirtualNetworkRules - NetworkRules resource. :ivar subnet: Subnet properties. @@ -1096,8 +1036,8 @@ class NWRuleSetVirtualNetworkRules(msrest.serialization.Model): """ _attribute_map = { - 'subnet': {'key': 'subnet', 'type': 'Subnet'}, - 'ignore_missing_vnet_service_endpoint': {'key': 'ignoreMissingVnetServiceEndpoint', 'type': 'bool'}, + "subnet": {"key": "subnet", "type": "Subnet"}, + "ignore_missing_vnet_service_endpoint": {"key": "ignoreMissingVnetServiceEndpoint", "type": "bool"}, } def __init__( @@ -1114,12 +1054,12 @@ def __init__( VNet Service Endpoint. :paramtype ignore_missing_vnet_service_endpoint: bool """ - super(NWRuleSetVirtualNetworkRules, self).__init__(**kwargs) + super().__init__(**kwargs) self.subnet = subnet self.ignore_missing_vnet_service_endpoint = ignore_missing_vnet_service_endpoint -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """A Service Bus REST API operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -1133,19 +1073,19 @@ class Operation(msrest.serialization.Model): :ivar origin: Origin of the operation. :vartype origin: str :ivar properties: Properties of the operation. - :vartype properties: any + :vartype properties: JSON """ _validation = { - 'name': {'readonly': True}, + "name": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - 'origin': {'key': 'origin', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'object'}, + "name": {"key": "name", "type": "str"}, + "is_data_action": {"key": "isDataAction", "type": "bool"}, + "display": {"key": "display", "type": "OperationDisplay"}, + "origin": {"key": "origin", "type": "str"}, + "properties": {"key": "properties", "type": "object"}, } def __init__( @@ -1154,7 +1094,7 @@ def __init__( is_data_action: Optional[bool] = None, display: Optional["_models.OperationDisplay"] = None, origin: Optional[str] = None, - properties: Optional[Any] = None, + properties: Optional[JSON] = None, **kwargs ): """ @@ -1165,9 +1105,9 @@ def __init__( :keyword origin: Origin of the operation. :paramtype origin: str :keyword properties: Properties of the operation. - :paramtype properties: any + :paramtype properties: JSON """ - super(Operation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = None self.is_data_action = is_data_action self.display = display @@ -1175,7 +1115,7 @@ def __init__( self.properties = properties -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """Operation display payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -1191,33 +1131,29 @@ class OperationDisplay(msrest.serialization.Model): """ _validation = { - 'provider': {'readonly': True}, - 'resource': {'readonly': True}, - 'operation': {'readonly': True}, - 'description': {'readonly': True}, + "provider": {"readonly": True}, + "resource": {"readonly": True}, + "operation": {"readonly": True}, + "description": {"readonly": True}, } _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(OperationDisplay, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.provider = None self.resource = None self.operation = None self.description = None -class OperationListResult(msrest.serialization.Model): +class OperationListResult(_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. @@ -1230,27 +1166,23 @@ class OperationListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(OperationListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class PrivateEndpoint(msrest.serialization.Model): +class PrivateEndpoint(_serialization.Model): """PrivateEndpoint information. :ivar id: The ARM identifier for Private Endpoint. @@ -1258,20 +1190,15 @@ class PrivateEndpoint(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, id: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin """ :keyword id: The ARM identifier for Private Endpoint. :paramtype id: str """ - super(PrivateEndpoint, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id @@ -1298,28 +1225,31 @@ class PrivateEndpointConnection(ProxyResource): :vartype private_link_service_connection_state: ~azure.mgmt.servicebus.v2021_11_01.models.ConnectionState :ivar provisioning_state: Provisioning state of the Private Endpoint Connection. Known values - are: "Creating", "Updating", "Deleting", "Succeeded", "Canceled", "Failed". + are: "Creating", "Updating", "Deleting", "Succeeded", "Canceled", and "Failed". :vartype provisioning_state: str or ~azure.mgmt.servicebus.v2021_11_01.models.EndPointProvisioningState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'readonly': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"readonly": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', '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'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "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__( @@ -1337,18 +1267,18 @@ def __init__( :paramtype private_link_service_connection_state: ~azure.mgmt.servicebus.v2021_11_01.models.ConnectionState :keyword provisioning_state: Provisioning state of the Private Endpoint Connection. Known - values are: "Creating", "Updating", "Deleting", "Succeeded", "Canceled", "Failed". + values are: "Creating", "Updating", "Deleting", "Succeeded", "Canceled", and "Failed". :paramtype provisioning_state: str or ~azure.mgmt.servicebus.v2021_11_01.models.EndPointProvisioningState """ - super(PrivateEndpointConnection, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.private_endpoint = private_endpoint self.private_link_service_connection_state = private_link_service_connection_state self.provisioning_state = provisioning_state -class PrivateEndpointConnectionListResult(msrest.serialization.Model): +class PrivateEndpointConnectionListResult(_serialization.Model): """Result of the list of all private endpoint connections operation. :ivar value: A collection of private endpoint connection resources. @@ -1358,8 +1288,8 @@ class PrivateEndpointConnectionListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateEndpointConnection]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PrivateEndpointConnection]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( @@ -1375,12 +1305,12 @@ def __init__( :keyword next_link: A link for the next page of private endpoint connection resources. :paramtype next_link: str """ - super(PrivateEndpointConnectionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class PrivateLinkResource(msrest.serialization.Model): +class PrivateLinkResource(_serialization.Model): """Information of the private link resource. :ivar id: Fully qualified identifier of the resource. @@ -1398,18 +1328,18 @@ class PrivateLinkResource(msrest.serialization.Model): """ _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]'}, + "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, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin name: Optional[str] = None, type: Optional[str] = None, group_id: Optional[str] = None, @@ -1431,7 +1361,7 @@ def __init__( :keyword required_zone_names: Required Zone Names. :paramtype required_zone_names: list[str] """ - super(PrivateLinkResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.name = name self.type = type @@ -1440,7 +1370,7 @@ def __init__( self.required_zone_names = required_zone_names -class PrivateLinkResourcesListResult(msrest.serialization.Model): +class PrivateLinkResourcesListResult(_serialization.Model): """Result of the List private link resources operation. :ivar value: A collection of private link resources. @@ -1450,16 +1380,12 @@ class PrivateLinkResourcesListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateLinkResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PrivateLinkResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.PrivateLinkResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.PrivateLinkResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: A collection of private link resources. @@ -1467,17 +1393,17 @@ def __init__( :keyword next_link: A link for the next page of private link resources. :paramtype next_link: str """ - super(PrivateLinkResourcesListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class RegenerateAccessKeyParameters(msrest.serialization.Model): +class RegenerateAccessKeyParameters(_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. - :ivar key_type: Required. The access key to regenerate. Known values are: "PrimaryKey", + :ivar key_type: The access key to regenerate. Required. Known values are: "PrimaryKey" and "SecondaryKey". :vartype key_type: str or ~azure.mgmt.servicebus.v2021_11_01.models.KeyType :ivar key: Optional, if the key value provided, is reset for KeyType value or autogenerate Key @@ -1486,35 +1412,29 @@ class RegenerateAccessKeyParameters(msrest.serialization.Model): """ _validation = { - 'key_type': {'required': True}, + "key_type": {"required": True}, } _attribute_map = { - 'key_type': {'key': 'keyType', 'type': 'str'}, - 'key': {'key': 'key', 'type': 'str'}, + "key_type": {"key": "keyType", "type": "str"}, + "key": {"key": "key", "type": "str"}, } - def __init__( - self, - *, - key_type: Union[str, "_models.KeyType"], - key: Optional[str] = None, - **kwargs - ): + def __init__(self, *, key_type: Union[str, "_models.KeyType"], key: Optional[str] = None, **kwargs): """ - :keyword key_type: Required. The access key to regenerate. Known values are: "PrimaryKey", + :keyword key_type: The access key to regenerate. Required. Known values are: "PrimaryKey" and "SecondaryKey". :paramtype key_type: str or ~azure.mgmt.servicebus.v2021_11_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) + super().__init__(**kwargs) self.key_type = key_type self.key = key -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """The Resource definition for other than namespace. Variables are only populated by the server, and will be ignored when sending a request. @@ -1528,24 +1448,20 @@ class Resource(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "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'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Resource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -1564,38 +1480,32 @@ class ResourceNamespacePatch(Resource): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "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}'}, + "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, - *, - location: Optional[str] = None, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs): """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(ResourceNamespacePatch, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.tags = tags @@ -1621,7 +1531,7 @@ class Rule(ProxyResource): message that have been matched by a filter expression. :vartype action: ~azure.mgmt.servicebus.v2021_11_01.models.Action :ivar filter_type: Filter type that is evaluated against a BrokeredMessage. Known values are: - "SqlFilter", "CorrelationFilter". + "SqlFilter" and "CorrelationFilter". :vartype filter_type: str or ~azure.mgmt.servicebus.v2021_11_01.models.FilterType :ivar sql_filter: Properties of sqlFilter. :vartype sql_filter: ~azure.mgmt.servicebus.v2021_11_01.models.SqlFilter @@ -1630,23 +1540,23 @@ class Rule(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'readonly': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"readonly": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', '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'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "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__( @@ -1663,14 +1573,14 @@ def __init__( message that have been matched by a filter expression. :paramtype action: ~azure.mgmt.servicebus.v2021_11_01.models.Action :keyword filter_type: Filter type that is evaluated against a BrokeredMessage. Known values - are: "SqlFilter", "CorrelationFilter". + are: "SqlFilter" and "CorrelationFilter". :paramtype filter_type: str or ~azure.mgmt.servicebus.v2021_11_01.models.FilterType :keyword sql_filter: Properties of sqlFilter. :paramtype sql_filter: ~azure.mgmt.servicebus.v2021_11_01.models.SqlFilter :keyword correlation_filter: Properties of correlationFilter. :paramtype correlation_filter: ~azure.mgmt.servicebus.v2021_11_01.models.CorrelationFilter """ - super(Rule, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.action = action self.filter_type = filter_type @@ -1678,7 +1588,7 @@ def __init__( self.correlation_filter = correlation_filter -class RuleListResult(msrest.serialization.Model): +class RuleListResult(_serialization.Model): """The response of the List rule operation. :ivar value: Result of the List Rules operation. @@ -1689,17 +1599,11 @@ class RuleListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Rule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Rule]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.Rule"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Rule"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: Result of the List Rules operation. :paramtype value: list[~azure.mgmt.servicebus.v2021_11_01.models.Rule] @@ -1707,7 +1611,7 @@ def __init__( list of rules. :paramtype next_link: str """ - super(RuleListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link @@ -1734,38 +1638,33 @@ class SBAuthorizationRule(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'readonly': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"readonly": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'rights': {'key': 'properties.rights', 'type': '[str]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "rights": {"key": "properties.rights", "type": "[str]"}, } - def __init__( - self, - *, - rights: Optional[List[Union[str, "_models.AccessRights"]]] = None, - **kwargs - ): + def __init__(self, *, rights: Optional[List[Union[str, "_models.AccessRights"]]] = None, **kwargs): """ :keyword rights: The rights associated with the rule. :paramtype rights: list[str or ~azure.mgmt.servicebus.v2021_11_01.models.AccessRights] """ - super(SBAuthorizationRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.rights = rights -class SBAuthorizationRuleListResult(msrest.serialization.Model): +class SBAuthorizationRuleListResult(_serialization.Model): """The response to the List Namespace operation. :ivar value: Result of the List Authorization Rules operation. @@ -1776,16 +1675,12 @@ class SBAuthorizationRuleListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SBAuthorizationRule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SBAuthorizationRule]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.SBAuthorizationRule"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.SBAuthorizationRule"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Result of the List Authorization Rules operation. @@ -1794,12 +1689,12 @@ def __init__( list of Authorization Rules. :paramtype next_link: str """ - super(SBAuthorizationRuleListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SBClientAffineProperties(msrest.serialization.Model): +class SBClientAffineProperties(_serialization.Model): """Properties specific to client affine subscriptions. :ivar client_id: Indicates the Client ID of the application that created the client-affine @@ -1814,9 +1709,9 @@ class SBClientAffineProperties(msrest.serialization.Model): """ _attribute_map = { - 'client_id': {'key': 'clientId', 'type': 'str'}, - 'is_durable': {'key': 'isDurable', 'type': 'bool'}, - 'is_shared': {'key': 'isShared', 'type': 'bool'}, + "client_id": {"key": "clientId", "type": "str"}, + "is_durable": {"key": "isDurable", "type": "bool"}, + "is_shared": {"key": "isShared", "type": "bool"}, } def __init__( @@ -1838,7 +1733,7 @@ def __init__( subscription is shared or not. :paramtype is_shared: bool """ - super(SBClientAffineProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.client_id = client_id self.is_durable = is_durable self.is_shared = is_shared @@ -1857,46 +1752,40 @@ class TrackedResource(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :ivar location: Required. The Geo-location where the resource lives. + :ivar location: The Geo-location where the resource lives. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "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}'}, + "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, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword location: Required. The Geo-location where the resource lives. + :keyword location: The Geo-location where the resource lives. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(TrackedResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.tags = tags -class SBNamespace(TrackedResource): +class SBNamespace(TrackedResource): # pylint: disable=too-many-instance-attributes """Description of a namespace resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -1909,9 +1798,9 @@ class SBNamespace(TrackedResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :ivar location: Required. The Geo-location where the resource lives. + :ivar location: The Geo-location where the resource lives. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar sku: Properties of SKU. :vartype sku: ~azure.mgmt.servicebus.v2021_11_01.models.SBSku @@ -1947,39 +1836,42 @@ class SBNamespace(TrackedResource): """ _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}, + "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'}, - 'alternate_name': {'key': 'properties.alternateName', 'type': 'str'}, + "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"}, + "alternate_name": {"key": "properties.alternateName", "type": "str"}, } def __init__( @@ -1997,9 +1889,9 @@ def __init__( **kwargs ): """ - :keyword location: Required. The Geo-location where the resource lives. + :keyword location: The Geo-location where the resource lives. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword sku: Properties of SKU. :paramtype sku: ~azure.mgmt.servicebus.v2021_11_01.models.SBSku @@ -2019,7 +1911,7 @@ def __init__( :keyword alternate_name: Alternate name for namespace. :paramtype alternate_name: str """ - super(SBNamespace, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.sku = sku self.identity = identity self.system_data = None @@ -2036,7 +1928,7 @@ def __init__( self.alternate_name = alternate_name -class SBNamespaceListResult(msrest.serialization.Model): +class SBNamespaceListResult(_serialization.Model): """The response of the List Namespace operation. :ivar value: Result of the List Namespace operation. @@ -2047,16 +1939,12 @@ class SBNamespaceListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SBNamespace]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SBNamespace]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.SBNamespace"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.SBNamespace"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Result of the List Namespace operation. @@ -2065,12 +1953,12 @@ def __init__( list of Namespaces. :paramtype next_link: str """ - super(SBNamespaceListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SBNamespaceUpdateParameters(ResourceNamespacePatch): +class SBNamespaceUpdateParameters(ResourceNamespacePatch): # pylint: disable=too-many-instance-attributes """Description of a namespace resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2083,7 +1971,7 @@ class SBNamespaceUpdateParameters(ResourceNamespacePatch): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar sku: Properties of SKU. :vartype sku: ~azure.mgmt.servicebus.v2021_11_01.models.SBSku @@ -2114,35 +2002,38 @@ class SBNamespaceUpdateParameters(ResourceNamespacePatch): """ _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}, + "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'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, - 'private_endpoint_connections': {'key': 'properties.privateEndpointConnections', 'type': '[PrivateEndpointConnection]'}, - 'disable_local_auth': {'key': 'properties.disableLocalAuth', 'type': 'bool'}, - 'alternate_name': {'key': 'properties.alternateName', 'type': 'str'}, + "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"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "private_endpoint_connections": { + "key": "properties.privateEndpointConnections", + "type": "[PrivateEndpointConnection]", + }, + "disable_local_auth": {"key": "properties.disableLocalAuth", "type": "bool"}, + "alternate_name": {"key": "properties.alternateName", "type": "str"}, } def __init__( @@ -2161,7 +2052,7 @@ def __init__( """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword sku: Properties of SKU. :paramtype sku: ~azure.mgmt.servicebus.v2021_11_01.models.SBSku @@ -2178,7 +2069,7 @@ def __init__( :keyword alternate_name: Alternate name for namespace. :paramtype alternate_name: str """ - super(SBNamespaceUpdateParameters, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.sku = sku self.identity = identity self.provisioning_state = None @@ -2193,7 +2084,7 @@ def __init__( self.alternate_name = alternate_name -class SBQueue(ProxyResource): +class SBQueue(ProxyResource): # pylint: disable=too-many-instance-attributes """Description of queue Resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2220,9 +2111,9 @@ class SBQueue(ProxyResource): to this queue. :vartype accessed_at: ~datetime.datetime :ivar size_in_bytes: The size of the queue, in bytes. - :vartype size_in_bytes: long + :vartype size_in_bytes: int :ivar message_count: The number of messages in the queue. - :vartype message_count: long + :vartype message_count: int :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. @@ -2232,7 +2123,7 @@ class SBQueue(ProxyResource): :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. - :vartype max_message_size_in_kilobytes: long + :vartype max_message_size_in_kilobytes: int :ivar requires_duplicate_detection: A value indicating if this queue requires duplicate detection. :vartype requires_duplicate_detection: bool @@ -2254,7 +2145,7 @@ class SBQueue(ProxyResource): :vartype max_delivery_count: int :ivar status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". + "Deleting", "Renaming", and "Unknown". :vartype status: str or ~azure.mgmt.servicebus.v2021_11_01.models.EntityStatus :ivar enable_batched_operations: Value that indicates whether server-side batched operations are enabled. @@ -2275,50 +2166,53 @@ class SBQueue(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'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}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"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'}, - 'location': {'key': 'location', '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__( + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "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": "int"}, + "message_count": {"key": "properties.messageCount", "type": "int"}, + "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": "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__( # pylint: disable=too-many-locals self, *, lock_duration: Optional[datetime.timedelta] = None, @@ -2349,7 +2243,7 @@ def __init__( :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 + :paramtype max_message_size_in_kilobytes: int :keyword requires_duplicate_detection: A value indicating if this queue requires duplicate detection. :paramtype requires_duplicate_detection: bool @@ -2371,7 +2265,7 @@ def __init__( :paramtype max_delivery_count: int :keyword status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". + "Deleting", "Renaming", and "Unknown". :paramtype status: str or ~azure.mgmt.servicebus.v2021_11_01.models.EntityStatus :keyword enable_batched_operations: Value that indicates whether server-side batched operations are enabled. @@ -2391,7 +2285,7 @@ def __init__( message. :paramtype forward_dead_lettered_messages_to: str """ - super(SBQueue, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.count_details = None self.created_at = None @@ -2417,7 +2311,7 @@ def __init__( self.forward_dead_lettered_messages_to = forward_dead_lettered_messages_to -class SBQueueListResult(msrest.serialization.Model): +class SBQueueListResult(_serialization.Model): """The response to the List Queues operation. :ivar value: Result of the List Queues operation. @@ -2428,17 +2322,11 @@ class SBQueueListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SBQueue]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SBQueue]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.SBQueue"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.SBQueue"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: Result of the List Queues operation. :paramtype value: list[~azure.mgmt.servicebus.v2021_11_01.models.SBQueue] @@ -2446,19 +2334,19 @@ def __init__( list of queues. :paramtype next_link: str """ - super(SBQueueListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SBSku(msrest.serialization.Model): +class SBSku(_serialization.Model): """SKU of the namespace. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Name of this SKU. Known values are: "Basic", "Standard", "Premium". + :ivar name: Name of this SKU. Required. Known values are: "Basic", "Standard", and "Premium". :vartype name: str or ~azure.mgmt.servicebus.v2021_11_01.models.SkuName - :ivar tier: The billing tier of this particular SKU. Known values are: "Basic", "Standard", + :ivar tier: The billing tier of this particular SKU. Known values are: "Basic", "Standard", and "Premium". :vartype tier: str or ~azure.mgmt.servicebus.v2021_11_01.models.SkuTier :ivar capacity: The specified messaging units for the tier. For Premium tier, capacity are 1,2 @@ -2467,13 +2355,13 @@ class SBSku(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'int'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "capacity": {"key": "capacity", "type": "int"}, } def __init__( @@ -2485,22 +2373,23 @@ def __init__( **kwargs ): """ - :keyword name: Required. Name of this SKU. Known values are: "Basic", "Standard", "Premium". + :keyword name: Name of this SKU. Required. Known values are: "Basic", "Standard", and + "Premium". :paramtype name: str or ~azure.mgmt.servicebus.v2021_11_01.models.SkuName :keyword tier: The billing tier of this particular SKU. Known values are: "Basic", "Standard", - "Premium". + and "Premium". :paramtype tier: str or ~azure.mgmt.servicebus.v2021_11_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) + super().__init__(**kwargs) self.name = name self.tier = tier self.capacity = capacity -class SBSubscription(ProxyResource): +class SBSubscription(ProxyResource): # pylint: disable=too-many-instance-attributes """Description of subscription resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2518,7 +2407,7 @@ class SBSubscription(ProxyResource): :ivar system_data: The system meta data relating to this resource. :vartype system_data: ~azure.mgmt.servicebus.v2021_11_01.models.SystemData :ivar message_count: Number of messages. - :vartype message_count: long + :vartype message_count: int :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. @@ -2549,7 +2438,7 @@ class SBSubscription(ProxyResource): :vartype max_delivery_count: int :ivar status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". + "Deleting", "Renaming", and "Unknown". :vartype status: str or ~azure.mgmt.servicebus.v2021_11_01.models.EntityStatus :ivar enable_batched_operations: Value that indicates whether server-side batched operations are enabled. @@ -2570,46 +2459,52 @@ class SBSubscription(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'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}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"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'}, - 'location': {'key': 'location', '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__( + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "message_count": {"key": "properties.messageCount", "type": "int"}, + "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__( # pylint: disable=too-many-locals self, *, lock_duration: Optional[datetime.timedelta] = None, @@ -2651,7 +2546,7 @@ def __init__( :paramtype max_delivery_count: int :keyword status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". + "Deleting", "Renaming", and "Unknown". :paramtype status: str or ~azure.mgmt.servicebus.v2021_11_01.models.EntityStatus :keyword enable_batched_operations: Value that indicates whether server-side batched operations are enabled. @@ -2671,7 +2566,7 @@ def __init__( :paramtype client_affine_properties: ~azure.mgmt.servicebus.v2021_11_01.models.SBClientAffineProperties """ - super(SBSubscription, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.message_count = None self.created_at = None @@ -2694,7 +2589,7 @@ def __init__( self.client_affine_properties = client_affine_properties -class SBSubscriptionListResult(msrest.serialization.Model): +class SBSubscriptionListResult(_serialization.Model): """The response to the List Subscriptions operation. :ivar value: Result of the List Subscriptions operation. @@ -2705,16 +2600,12 @@ class SBSubscriptionListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SBSubscription]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SBSubscription]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.SBSubscription"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.SBSubscription"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Result of the List Subscriptions operation. @@ -2723,12 +2614,12 @@ def __init__( list of subscriptions. :paramtype next_link: str """ - super(SBSubscriptionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SBTopic(ProxyResource): +class SBTopic(ProxyResource): # pylint: disable=too-many-instance-attributes """Description of topic resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2746,7 +2637,7 @@ class SBTopic(ProxyResource): :ivar system_data: The system meta data relating to this resource. :vartype system_data: ~azure.mgmt.servicebus.v2021_11_01.models.SystemData :ivar size_in_bytes: Size of the topic, in bytes. - :vartype size_in_bytes: long + :vartype size_in_bytes: int :ivar created_at: Exact time the message was created. :vartype created_at: ~datetime.datetime :ivar updated_at: The exact time the message was updated. @@ -2766,7 +2657,7 @@ class SBTopic(ProxyResource): :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. - :vartype max_message_size_in_kilobytes: long + :vartype max_message_size_in_kilobytes: int :ivar requires_duplicate_detection: Value indicating if this topic requires duplicate detection. :vartype requires_duplicate_detection: bool @@ -2778,7 +2669,7 @@ class SBTopic(ProxyResource): :vartype enable_batched_operations: bool :ivar status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". + "Deleting", "Renaming", and "Unknown". :vartype status: str or ~azure.mgmt.servicebus.v2021_11_01.models.EntityStatus :ivar support_ordering: Value that indicates whether the topic supports ordering. :vartype support_ordering: bool @@ -2794,42 +2685,45 @@ class SBTopic(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'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}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"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'}, - 'location': {'key': 'location', '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'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "size_in_bytes": {"key": "properties.sizeInBytes", "type": "int"}, + "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": "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__( @@ -2858,7 +2752,7 @@ def __init__( :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 + :paramtype max_message_size_in_kilobytes: int :keyword requires_duplicate_detection: Value indicating if this topic requires duplicate detection. :paramtype requires_duplicate_detection: bool @@ -2870,7 +2764,7 @@ def __init__( :paramtype enable_batched_operations: bool :keyword status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". + "Deleting", "Renaming", and "Unknown". :paramtype status: str or ~azure.mgmt.servicebus.v2021_11_01.models.EntityStatus :keyword support_ordering: Value that indicates whether the topic supports ordering. :paramtype support_ordering: bool @@ -2884,7 +2778,7 @@ def __init__( topic holds a message in memory temporarily before writing it to persistent storage. :paramtype enable_express: bool """ - super(SBTopic, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.size_in_bytes = None self.created_at = None @@ -2905,7 +2799,7 @@ def __init__( self.enable_express = enable_express -class SBTopicListResult(msrest.serialization.Model): +class SBTopicListResult(_serialization.Model): """The response to the List Topics operation. :ivar value: Result of the List Topics operation. @@ -2916,17 +2810,11 @@ class SBTopicListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SBTopic]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SBTopic]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.SBTopic"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.SBTopic"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: Result of the List Topics operation. :paramtype value: list[~azure.mgmt.servicebus.v2021_11_01.models.SBTopic] @@ -2934,12 +2822,12 @@ def __init__( list of topics. :paramtype next_link: str """ - super(SBTopicListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SqlFilter(msrest.serialization.Model): +class SqlFilter(_serialization.Model): """Represents a filter which is a composition of an expression and an action that is executed in the pub/sub pipeline. :ivar sql_expression: The SQL expression. e.g. MyProperty='ABC'. @@ -2953,9 +2841,9 @@ class SqlFilter(msrest.serialization.Model): """ _attribute_map = { - 'sql_expression': {'key': 'sqlExpression', 'type': 'str'}, - 'compatibility_level': {'key': 'compatibilityLevel', 'type': 'int'}, - 'requires_preprocessing': {'key': 'requiresPreprocessing', 'type': 'bool'}, + "sql_expression": {"key": "sqlExpression", "type": "str"}, + "compatibility_level": {"key": "compatibilityLevel", "type": "int"}, + "requires_preprocessing": {"key": "requiresPreprocessing", "type": "bool"}, } def __init__( @@ -2963,7 +2851,7 @@ def __init__( *, sql_expression: Optional[str] = None, compatibility_level: Optional[int] = None, - requires_preprocessing: Optional[bool] = True, + requires_preprocessing: bool = True, **kwargs ): """ @@ -2976,7 +2864,7 @@ def __init__( preprocessing. :paramtype requires_preprocessing: bool """ - super(SqlFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.sql_expression = sql_expression self.compatibility_level = compatibility_level self.requires_preprocessing = requires_preprocessing @@ -2996,9 +2884,9 @@ class SqlRuleAction(Action): """ _attribute_map = { - 'sql_expression': {'key': 'sqlExpression', 'type': 'str'}, - 'compatibility_level': {'key': 'compatibilityLevel', 'type': 'int'}, - 'requires_preprocessing': {'key': 'requiresPreprocessing', 'type': 'bool'}, + "sql_expression": {"key": "sqlExpression", "type": "str"}, + "compatibility_level": {"key": "compatibilityLevel", "type": "int"}, + "requires_preprocessing": {"key": "requiresPreprocessing", "type": "bool"}, } def __init__( @@ -3006,7 +2894,7 @@ def __init__( *, sql_expression: Optional[str] = None, compatibility_level: Optional[int] = None, - requires_preprocessing: Optional[bool] = True, + requires_preprocessing: bool = True, **kwargs ): """ @@ -3019,66 +2907,66 @@ def __init__( preprocessing. :paramtype requires_preprocessing: bool """ - super(SqlRuleAction, self).__init__(sql_expression=sql_expression, compatibility_level=compatibility_level, requires_preprocessing=requires_preprocessing, **kwargs) + super().__init__( + sql_expression=sql_expression, + compatibility_level=compatibility_level, + requires_preprocessing=requires_preprocessing, + **kwargs + ) -class Subnet(msrest.serialization.Model): +class Subnet(_serialization.Model): """Properties supplied for Subnet. All required parameters must be populated in order to send to Azure. - :ivar id: Required. Resource ID of Virtual Network Subnet. + :ivar id: Resource ID of Virtual Network Subnet. Required. :vartype id: str """ _validation = { - 'id': {'required': True}, + "id": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: str, - **kwargs - ): + def __init__(self, *, id: str, **kwargs): # pylint: disable=redefined-builtin """ - :keyword id: Required. Resource ID of Virtual Network Subnet. + :keyword id: Resource ID of Virtual Network Subnet. Required. :paramtype id: str """ - super(Subnet, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id -class SystemData(msrest.serialization.Model): +class SystemData(_serialization.Model): """Metadata pertaining to creation and last modification of the resource. :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. Known values are: - "User", "Application", "ManagedIdentity", "Key". + "User", "Application", "ManagedIdentity", and "Key". :vartype created_by_type: str or ~azure.mgmt.servicebus.v2021_11_01.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. Known values - are: "User", "Application", "ManagedIdentity", "Key". + are: "User", "Application", "ManagedIdentity", and "Key". :vartype last_modified_by_type: str or ~azure.mgmt.servicebus.v2021_11_01.models.CreatedByType :ivar last_modified_at: The type of identity that last modified the resource. :vartype 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'}, + "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__( @@ -3096,20 +2984,20 @@ def __init__( :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. Known values are: - "User", "Application", "ManagedIdentity", "Key". + "User", "Application", "ManagedIdentity", and "Key". :paramtype created_by_type: str or ~azure.mgmt.servicebus.v2021_11_01.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. Known - values are: "User", "Application", "ManagedIdentity", "Key". + values are: "User", "Application", "ManagedIdentity", and "Key". :paramtype last_modified_by_type: str or ~azure.mgmt.servicebus.v2021_11_01.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) + super().__init__(**kwargs) self.created_by = created_by self.created_by_type = created_by_type self.created_at = created_at @@ -3118,7 +3006,7 @@ def __init__( self.last_modified_at = last_modified_at -class UserAssignedIdentity(msrest.serialization.Model): +class UserAssignedIdentity(_serialization.Model): """Recognized Dictionary value. Variables are only populated by the server, and will be ignored when sending a request. @@ -3130,27 +3018,23 @@ class UserAssignedIdentity(msrest.serialization.Model): """ _validation = { - 'principal_id': {'readonly': True}, - 'client_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "client_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'client_id': {'key': 'clientId', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "client_id": {"key": "clientId", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(UserAssignedIdentity, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.principal_id = None self.client_id = None -class UserAssignedIdentityProperties(msrest.serialization.Model): +class UserAssignedIdentityProperties(_serialization.Model): """UserAssignedIdentityProperties. :ivar user_assigned_identity: ARM ID of user Identity selected for encryption. @@ -3158,18 +3042,13 @@ class UserAssignedIdentityProperties(msrest.serialization.Model): """ _attribute_map = { - 'user_assigned_identity': {'key': 'userAssignedIdentity', 'type': 'str'}, + "user_assigned_identity": {"key": "userAssignedIdentity", "type": "str"}, } - def __init__( - self, - *, - user_assigned_identity: Optional[str] = None, - **kwargs - ): + def __init__(self, *, 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) + super().__init__(**kwargs) self.user_assigned_identity = user_assigned_identity diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/models/_patch.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/models/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/models/_patch.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/models/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/models/_service_bus_management_client_enums.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/models/_service_bus_management_client_enums.py index 33112c2ab17d..ce716a014719 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/models/_service_bus_management_client_enums.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/models/_service_bus_management_client_enums.py @@ -11,30 +11,31 @@ class AccessRights(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """AccessRights.""" MANAGE = "Manage" SEND = "Send" LISTEN = "Listen" + class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of identity that created the resource. - """ + """The type of identity that created the resource.""" USER = "User" APPLICATION = "Application" MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" + class DefaultAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Default Action for Network Rule Set - """ + """Default Action for Network Rule Set.""" ALLOW = "Allow" DENY = "Deny" + class EndPointProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Provisioning state of the Private Endpoint Connection. - """ + """Provisioning state of the Private Endpoint Connection.""" CREATING = "Creating" UPDATING = "Updating" @@ -43,9 +44,9 @@ class EndPointProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): CANCELED = "Canceled" FAILED = "Failed" + class EntityStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Entity status. - """ + """Entity status.""" ACTIVE = "Active" DISABLED = "Disabled" @@ -57,92 +58,96 @@ class EntityStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): RENAMING = "Renaming" UNKNOWN = "Unknown" + class FilterType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Rule filter types - """ + """Rule filter types.""" SQL_FILTER = "SqlFilter" CORRELATION_FILTER = "CorrelationFilter" + class KeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The access key to regenerate. - """ + """The access key to regenerate.""" PRIMARY_KEY = "PrimaryKey" SECONDARY_KEY = "SecondaryKey" + class ManagedServiceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Type of managed service identity. - """ + """Type of managed service identity.""" SYSTEM_ASSIGNED = "SystemAssigned" USER_ASSIGNED = "UserAssigned" SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" NONE = "None" + class MigrationConfigurationName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """MigrationConfigurationName.""" _DEFAULT = "$default" + class NetworkRuleIPAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The IP Filter Action - """ + """The IP Filter Action.""" ALLOW = "Allow" + class PrivateLinkConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Status of the connection. - """ + """Status of the connection.""" PENDING = "Pending" APPROVED = "Approved" REJECTED = "Rejected" DISCONNECTED = "Disconnected" + class ProvisioningStateDR(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Provisioning state of the Alias(Disaster Recovery configuration) - possible values 'Accepted' - or 'Succeeded' or 'Failed' + or 'Succeeded' or 'Failed'. """ ACCEPTED = "Accepted" SUCCEEDED = "Succeeded" FAILED = "Failed" + class PublicNetworkAccessFlag(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """This determines if traffic is allowed over public network. By default it is enabled. - """ + """This determines if traffic is allowed over public network. By default it is enabled.""" ENABLED = "Enabled" DISABLED = "Disabled" + class RoleDisasterRecovery(str, Enum, metaclass=CaseInsensitiveEnumMeta): """role of namespace in GEO DR - possible values 'Primary' or 'PrimaryNotReplicating' or - 'Secondary' + 'Secondary'. """ PRIMARY = "Primary" PRIMARY_NOT_REPLICATING = "PrimaryNotReplicating" SECONDARY = "Secondary" + class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Name of this SKU. - """ + """Name of this SKU.""" BASIC = "Basic" STANDARD = "Standard" PREMIUM = "Premium" + class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The billing tier of this particular SKU. - """ + """The billing tier of this particular SKU.""" BASIC = "Basic" STANDARD = "Standard" PREMIUM = "Premium" + class UnavailableReason(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the reason for the unavailability of the service. - """ + """Specifies the reason for the unavailability of the service.""" NONE = "None" INVALID_NAME = "InvalidName" diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/__init__.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/__init__.py index 5559ccd3746c..831edc36bd6b 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/__init__.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/__init__.py @@ -20,17 +20,18 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'NamespacesOperations', - 'PrivateEndpointConnectionsOperations', - 'PrivateLinkResourcesOperations', - 'Operations', - 'DisasterRecoveryConfigsOperations', - 'MigrationConfigsOperations', - 'QueuesOperations', - 'TopicsOperations', - 'RulesOperations', - 'SubscriptionsOperations', + "NamespacesOperations", + "PrivateEndpointConnectionsOperations", + "PrivateLinkResourcesOperations", + "Operations", + "DisasterRecoveryConfigsOperations", + "MigrationConfigsOperations", + "QueuesOperations", + "TopicsOperations", + "RulesOperations", + "SubscriptionsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_disaster_recovery_configs_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_disaster_recovery_configs_operations.py index a669afa805d6..ce045084ecf4 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_disaster_recovery_configs_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_disaster_recovery_configs_operations.py @@ -6,11 +6,16 @@ # 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, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -20,298 +25,257 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - resource_group_name: str, - namespace_name: str, - alias: str, - subscription_id: str, - *, - json: Optional[_models.ArmDisasterRecovery] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, alias: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - namespace_name: str, - alias: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, alias: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - namespace_name: str, - alias: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, alias: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_break_pairing_request( - resource_group_name: str, - namespace_name: str, - alias: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, alias: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_fail_over_request( - resource_group_name: str, - namespace_name: str, - alias: str, - subscription_id: str, - *, - json: Optional[_models.FailoverProperties] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, alias: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_authorization_rules_request( - resource_group_name: str, - namespace_name: str, - alias: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, alias: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_authorization_rule_request( @@ -325,34 +289,35 @@ def build_get_authorization_rule_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( @@ -366,79 +331,72 @@ def build_list_keys_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_check_name_availability_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - *, - json: Optional[_models.CheckNameAvailability] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + class DisasterRecoveryConfigsOperations: """ @@ -459,46 +417,40 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> Iterable[_models.ArmDisasterRecoveryListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> Iterable["_models.ArmDisasterRecovery"]: """Gets all Alias(Disaster Recovery configurations). - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: An iterator like instance of either ArmDisasterRecovery or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.ArmDisasterRecoveryListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.ArmDisasterRecovery] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ArmDisasterRecoveryListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -506,16 +458,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -531,10 +478,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -545,49 +490,117 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 + @overload def create_or_update( self, resource_group_name: str, namespace_name: str, alias: str, parameters: _models.ArmDisasterRecovery, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Required. :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.ArmDisasterRecovery + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ArmDisasterRecovery or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.ArmDisasterRecovery or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ArmDisasterRecovery or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.ArmDisasterRecovery or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: Union[_models.ArmDisasterRecovery, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). Is + either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.ArmDisasterRecovery or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ArmDisasterRecovery, or the result of cls(response) + :return: ArmDisasterRecovery or None or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.ArmDisasterRecovery or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ArmDisasterRecovery]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ArmDisasterRecovery]] - _json = self._serialize.body(parameters, 'ArmDisasterRecovery') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ArmDisasterRecovery") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -597,7 +610,8 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -605,10 +619,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -618,56 +631,48 @@ def create_or_update( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ArmDisasterRecovery', pipeline_response) + 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 - + 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: str, - namespace_name: str, - alias: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -675,10 +680,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -689,49 +693,41 @@ def delete( # pylint: disable=inconsistent-return-statements 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: str, - namespace_name: str, - alias: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :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) + :return: ArmDisasterRecovery or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.ArmDisasterRecovery - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ArmDisasterRecovery] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ArmDisasterRecovery] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -739,10 +735,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -750,57 +745,49 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ArmDisasterRecovery', pipeline_response) + 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 - + 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: str, - namespace_name: str, - alias: str, - **kwargs: Any + self, 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. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.break_pairing.metadata["url"], headers=_headers, params=_params, ) @@ -808,10 +795,9 @@ def break_pairing( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -822,50 +808,118 @@ def break_pairing( # pylint: disable=inconsistent-return-statements 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 - @distributed_trace + @overload def fail_over( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, alias: str, parameters: Optional[_models.FailoverProperties] = None, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). Default value is None. :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.FailoverProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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: + """ + + @overload + def fail_over( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Default value is None. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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: + """ + + @distributed_trace + def fail_over( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: Optional[Union[_models.FailoverProperties, IO]] = 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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). Is + either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.FailoverProperties or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - if parameters is not None: - _json = self._serialize.body(parameters, 'FailoverProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "FailoverProperties") + else: + _json = None request = build_fail_over_request( resource_group_name=resource_group_name, @@ -875,7 +929,8 @@ def fail_over( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, json=_json, - template_url=self.fail_over.metadata['url'], + content=_content, + template_url=self.fail_over.metadata["url"], headers=_headers, params=_params, ) @@ -883,10 +938,9 @@ def fail_over( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -897,52 +951,45 @@ def fail_over( # pylint: disable=inconsistent-return-statements 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, - namespace_name: str, - alias: str, - **kwargs: Any - ) -> Iterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, alias: str, **kwargs: Any + ) -> Iterable["_models.SBAuthorizationRule"]: """Gets the authorization rules for a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :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) + :return: An iterator like instance of either SBAuthorizationRule or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) @@ -950,17 +997,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -976,10 +1017,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -990,48 +1029,38 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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: str, - namespace_name: str, - alias: str, - authorization_rule_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -1039,7 +1068,7 @@ def get_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -1047,10 +1076,9 @@ def get_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1058,52 +1086,43 @@ def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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: str, - namespace_name: str, - alias: str, - authorization_rule_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -1111,7 +1130,7 @@ def list_keys( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1119,10 +1138,9 @@ def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1130,50 +1148,111 @@ def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}/listKeys"} # type: ignore - - @distributed_trace + @overload def check_name_availability( self, resource_group_name: str, namespace_name: str, parameters: _models.CheckNameAvailability, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Check the give namespace name availability. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters to check availability of the given namespace name. + :param parameters: Parameters to check availability of the given namespace name. Required. :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.CheckNameAvailability + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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.v2021_11_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters to check availability of the given namespace name. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :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.v2021_11_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, + resource_group_name: str, + namespace_name: str, + parameters: Union[_models.CheckNameAvailability, IO], + **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters to check availability of the given namespace name. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.CheckNameAvailability or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameAvailabilityResult, or the result of cls(response) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResult] - _json = self._serialize.body(parameters, 'CheckNameAvailability') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CheckNameAvailability") request = build_check_name_availability_request( resource_group_name=resource_group_name, @@ -1182,7 +1261,8 @@ def check_name_availability( api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) @@ -1190,10 +1270,9 @@ def check_name_availability( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1201,12 +1280,11 @@ def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + 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 - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/CheckNameAvailability"} # type: ignore diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_migration_configs_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_migration_configs_operations.py index fed06161b0b7..5c6b4c8d9d2f 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_migration_configs_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_migration_configs_operations.py @@ -6,11 +6,16 @@ # 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, Iterable, Optional, TypeVar, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -22,95 +27,88 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_and_start_migration_request_initial( +def build_create_and_start_migration_request( resource_group_name: str, namespace_name: str, config_name: Union[str, "_models.MigrationConfigurationName"], subscription_id: str, - *, - json: Optional[_models.MigrationConfigProperties] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( @@ -123,33 +121,32 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( @@ -162,33 +159,32 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_complete_migration_request( @@ -201,33 +197,32 @@ def build_complete_migration_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_revert_request( @@ -240,33 +235,33 @@ def build_revert_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class MigrationConfigsOperations: """ @@ -287,46 +282,41 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> Iterable[_models.MigrationConfigListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> Iterable["_models.MigrationConfigProperties"]: """Gets all migrationConfigurations. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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 + :return: An iterator like instance of either MigrationConfigProperties or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.MigrationConfigListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.MigrationConfigProperties] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MigrationConfigListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -334,16 +324,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -359,10 +344,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -373,35 +356,37 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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: str, namespace_name: str, config_name: Union[str, "_models.MigrationConfigurationName"], - parameters: _models.MigrationConfigProperties, + parameters: Union[_models.MigrationConfigProperties, IO], **kwargs: Any ) -> Optional[_models.MigrationConfigProperties]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.MigrationConfigProperties]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.MigrationConfigProperties]] - _json = self._serialize.body(parameters, 'MigrationConfigProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "MigrationConfigProperties") - request = build_create_and_start_migration_request_initial( + request = build_create_and_start_migration_request( resource_group_name=resource_group_name, namespace_name=namespace_name, config_name=config_name, @@ -409,7 +394,8 @@ def _create_and_start_migration_initial( api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_and_start_migration_initial.metadata['url'], + content=_content, + template_url=self._create_and_start_migration_initial.metadata["url"], headers=_headers, params=_params, ) @@ -417,48 +403,92 @@ def _create_and_start_migration_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) + 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 - + _create_and_start_migration_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore - @distributed_trace + @overload def begin_create_and_start_migration( self, resource_group_name: str, namespace_name: str, config_name: Union[str, "_models.MigrationConfigurationName"], parameters: _models.MigrationConfigProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2021_11_01.models.MigrationConfigurationName - :param parameters: Parameters required to create Migration Configuration. + :param parameters: Parameters required to create Migration Configuration. Required. :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.MigrationConfigProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. + :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_11_01.models.MigrationConfigProperties] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_and_start_migration( + self, + resource_group_name: str, + namespace_name: str, + config_name: Union[str, "_models.MigrationConfigurationName"], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param config_name: The configuration name. Should always be "$default". "$default" Required. + :type config_name: str or ~azure.mgmt.servicebus.v2021_11_01.models.MigrationConfigurationName + :param parameters: Parameters required to create Migration Configuration. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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 @@ -471,20 +501,56 @@ def begin_create_and_start_migration( of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.servicebus.v2021_11_01.models.MigrationConfigProperties] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_and_start_migration( + self, + resource_group_name: str, + namespace_name: str, + config_name: Union[str, "_models.MigrationConfigurationName"], + parameters: Union[_models.MigrationConfigProperties, IO], + **kwargs: Any + ) -> LROPoller[_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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param config_name: The configuration name. Should always be "$default". "$default" Required. + :type config_name: str or ~azure.mgmt.servicebus.v2021_11_01.models.MigrationConfigurationName + :param parameters: Parameters required to create Migration Configuration. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.MigrationConfigProperties or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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_11_01.models.MigrationConfigProperties] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.MigrationConfigProperties] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MigrationConfigProperties] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + 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 = self._create_and_start_migration_initial( # type: ignore resource_group_name=resource_group_name, @@ -493,39 +559,35 @@ def begin_create_and_start_migration( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) + deserialized = self._deserialize("MigrationConfigProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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 @@ -537,36 +599,33 @@ def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes a MigrationConfiguration. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2021_11_01.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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -574,10 +633,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -588,8 +646,7 @@ def delete( # pylint: disable=inconsistent-return-statements 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( @@ -601,36 +658,33 @@ def get( ) -> _models.MigrationConfigProperties: """Retrieves Migration Config. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2021_11_01.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) + :return: MigrationConfigProperties or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.MigrationConfigProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MigrationConfigProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MigrationConfigProperties] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -638,10 +692,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -649,15 +702,14 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) + 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 - + 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 @@ -671,36 +723,33 @@ def complete_migration( # pylint: disable=inconsistent-return-statements 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2021_11_01.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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.complete_migration.metadata["url"], headers=_headers, params=_params, ) @@ -708,10 +757,9 @@ def complete_migration( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -722,8 +770,7 @@ def complete_migration( # pylint: disable=inconsistent-return-statements 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 @distributed_trace def revert( # pylint: disable=inconsistent-return-statements @@ -735,36 +782,33 @@ def revert( # pylint: disable=inconsistent-return-statements ) -> None: """This operation reverts Migration. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2021_11_01.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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.revert.metadata["url"], headers=_headers, params=_params, ) @@ -772,10 +816,9 @@ def revert( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -786,5 +829,4 @@ def revert( # pylint: disable=inconsistent-return-statements 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_11_01/operations/_namespaces_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_namespaces_operations.py index d6af66a8d3c8..4a8d1605b569 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_namespaces_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_namespaces_operations.py @@ -6,11 +6,16 @@ # 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, Iterable, Optional, TypeVar, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -22,651 +27,557 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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: + +def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + accept = _headers.pop("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'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_resource_group_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces") # pylint: disable=line-too-long + _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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request_initial( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - *, - json: Optional[_models.SBNamespace] = None, - content: Any = None, - **kwargs: Any + +def build_create_or_update_request( + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long + _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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any +def build_delete_request( + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - *, - json: Optional[_models.SBNamespaceUpdateParameters] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_network_rule_set_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - *, - json: Optional[_models.NetworkRuleSet] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_network_rule_set_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_network_rule_sets_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_authorization_rules_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_authorization_rule_request( - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - subscription_id: str, - *, - json: Optional[_models.SBAuthorizationRule] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, authorization_rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_authorization_rule_request( - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, authorization_rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_authorization_rule_request( - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, authorization_rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, authorization_rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_regenerate_keys_request( - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - subscription_id: str, - *, - json: Optional[_models.RegenerateAccessKeyParameters] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, authorization_rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_check_name_availability_request( - subscription_id: str, - *, - json: Optional[_models.CheckNameAvailability] = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: + +def build_check_name_availability_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + class NamespacesOperations: """ @@ -687,38 +598,31 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.SBNamespaceListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.SBNamespace"]: """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_11_01.models.SBNamespaceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either SBNamespace or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.SBNamespace] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespaceListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -726,14 +630,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -749,10 +650,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -763,47 +662,38 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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: str, - **kwargs: Any - ) -> Iterable[_models.SBNamespaceListResult]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.SBNamespace"]: """Gets the available namespaces within a resource group. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :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_11_01.models.SBNamespaceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either SBNamespace or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.SBNamespace] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespaceListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -811,15 +701,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -835,10 +721,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -849,41 +733,40 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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: str, - namespace_name: str, - parameters: _models.SBNamespace, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, parameters: Union[_models.SBNamespace, IO], **kwargs: Any ) -> Optional[_models.SBNamespace]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.SBNamespace]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.SBNamespace]] - _json = self._serialize.body(parameters, 'SBNamespace') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBNamespace") - request = build_create_or_update_request_initial( + request = build_create_or_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._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) @@ -891,48 +774,88 @@ def _create_or_update_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SBNamespace', pipeline_response) + 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 - + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, namespace_name: str, parameters: _models.SBNamespace, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters supplied to create a namespace resource. + :param parameters: Parameters supplied to create a namespace resource. Required. :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.SBNamespace + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. + :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_11_01.models.SBNamespace] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to create a namespace resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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 @@ -944,20 +867,48 @@ def begin_create_or_update( :return: An instance of LROPoller that returns either SBNamespace or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.servicebus.v2021_11_01.models.SBNamespace] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, resource_group_name: str, namespace_name: str, parameters: Union[_models.SBNamespace, IO], **kwargs: Any + ) -> LROPoller[_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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to create a namespace resource. Is either a model type + or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.SBNamespace or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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_11_01.models.SBNamespace] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespace] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBNamespace] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + 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 = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, @@ -965,64 +916,54 @@ def begin_create_or_update( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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: str, - namespace_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_request_initial( + request = build_delete_request( 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'], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1030,35 +971,29 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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_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 @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, 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. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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. @@ -1070,92 +1005,77 @@ def begin_delete( # pylint: disable=inconsistent-return-statements 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + 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 = self._delete_initial( # type: ignore resource_group_name=resource_group_name, namespace_name=namespace_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> _models.SBNamespace: + def get(self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: SBNamespace or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBNamespace - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespace] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBNamespace] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -1163,10 +1083,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1174,51 +1093,114 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBNamespace', pipeline_response) + 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 - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - @distributed_trace + @overload def update( self, resource_group_name: str, namespace_name: str, parameters: _models.SBNamespaceUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters supplied to update a namespace resource. + :param parameters: Parameters supplied to update a namespace resource. Required. :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.SBNamespaceUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBNamespace or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBNamespace or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> 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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to update a namespace resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBNamespace, or the result of cls(response) + :return: SBNamespace or None or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBNamespace or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace + def update( + self, + resource_group_name: str, + namespace_name: str, + parameters: Union[_models.SBNamespaceUpdateParameters, IO], + **kwargs: Any + ) -> 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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to update a namespace resource. Is either a model type + or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.SBNamespaceUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBNamespace or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBNamespace or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.SBNamespace]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.SBNamespace]] - _json = self._serialize.body(parameters, 'SBNamespaceUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBNamespaceUpdateParameters") request = build_update_request( resource_group_name=resource_group_name, @@ -1227,7 +1209,8 @@ def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -1235,10 +1218,9 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -1248,53 +1230,113 @@ def update( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SBNamespace', pipeline_response) + 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 - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - @distributed_trace + @overload def create_or_update_network_rule_set( self, resource_group_name: str, namespace_name: str, parameters: _models.NetworkRuleSet, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.NetworkRuleSet: """Create or update NetworkRuleSet for a Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: The Namespace IpFilterRule. + :param parameters: The Namespace IpFilterRule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.NetworkRuleSet + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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.v2021_11_01.models.NetworkRuleSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_network_rule_set( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NetworkRuleSet: + """Create or update NetworkRuleSet for a Namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: The Namespace IpFilterRule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: NetworkRuleSet, or the result of cls(response) + :return: NetworkRuleSet or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.NetworkRuleSet - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace + def create_or_update_network_rule_set( + self, + resource_group_name: str, + namespace_name: str, + parameters: Union[_models.NetworkRuleSet, IO], + **kwargs: Any + ) -> _models.NetworkRuleSet: + """Create or update NetworkRuleSet for a Namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: The Namespace IpFilterRule. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.NetworkRuleSet or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2021_11_01.models.NetworkRuleSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkRuleSet] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.NetworkRuleSet] - _json = self._serialize.body(parameters, 'NetworkRuleSet') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "NetworkRuleSet") request = build_create_or_update_network_rule_set_request( resource_group_name=resource_group_name, @@ -1303,7 +1345,8 @@ def create_or_update_network_rule_set( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_network_rule_set.metadata['url'], + content=_content, + template_url=self.create_or_update_network_rule_set.metadata["url"], headers=_headers, params=_params, ) @@ -1311,10 +1354,9 @@ def create_or_update_network_rule_set( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1322,52 +1364,45 @@ def create_or_update_network_rule_set( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('NetworkRuleSet', pipeline_response) + 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 - + 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: str, - namespace_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: NetworkRuleSet or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.NetworkRuleSet - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkRuleSet] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.NetworkRuleSet] - 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'], + template_url=self.get_network_rule_set.metadata["url"], headers=_headers, params=_params, ) @@ -1375,10 +1410,9 @@ def get_network_rule_set( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1386,55 +1420,48 @@ def get_network_rule_set( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('NetworkRuleSet', pipeline_response) + 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 - + 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, - namespace_name: str, - **kwargs: Any - ) -> Iterable[_models.NetworkRuleSetListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> Iterable["_models.NetworkRuleSet"]: """Gets list of NetworkRuleSet for a Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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_11_01.models.NetworkRuleSetListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either NetworkRuleSet or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.NetworkRuleSet] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkRuleSetListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_network_rule_sets.metadata["url"], headers=_headers, params=_params, ) @@ -1442,16 +1469,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -1467,10 +1489,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1481,51 +1501,44 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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: str, - namespace_name: str, - **kwargs: Any - ) -> Iterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> Iterable["_models.SBAuthorizationRule"]: """Gets the authorization rules for a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: An iterator like instance of either SBAuthorizationRule or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) @@ -1533,16 +1546,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -1558,10 +1566,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1572,49 +1578,115 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 + @overload def create_or_update_authorization_rule( self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, parameters: _models.SBAuthorizationRule, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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.v2021_11_01.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2021_11_01.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: Union[_models.SBAuthorizationRule, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - _json = self._serialize.body(parameters, 'SBAuthorizationRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBAuthorizationRule") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -1624,7 +1696,8 @@ def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -1632,10 +1705,9 @@ def create_or_update_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1643,56 +1715,48 @@ def create_or_update_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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: str, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -1700,10 +1764,9 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1714,49 +1777,41 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements 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: str, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - 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'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -1764,10 +1819,9 @@ def get_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1775,56 +1829,48 @@ def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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: str, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - 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'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1832,10 +1878,9 @@ def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1843,53 +1888,120 @@ def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys"} # type: ignore - - @distributed_trace + @overload def regenerate_keys( self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, parameters: _models.RegenerateAccessKeyParameters, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.RegenerateAccessKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2021_11_01.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateAccessKeyParameters, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.RegenerateAccessKeyParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2021_11_01.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateAccessKeyParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -1899,7 +2011,8 @@ def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1907,10 +2020,9 @@ def regenerate_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1918,51 +2030,91 @@ def regenerate_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 + regenerate_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore + + @overload + def check_name_availability( + self, parameters: _models.CheckNameAvailability, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + :param parameters: Parameters to check availability of the given namespace name. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.CheckNameAvailability + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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.v2021_11_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param parameters: Parameters to check availability of the given namespace name. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :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.v2021_11_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def check_name_availability( - self, - parameters: _models.CheckNameAvailability, - **kwargs: Any + self, parameters: Union[_models.CheckNameAvailability, IO], **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Check the give namespace name availability. - :param parameters: Parameters to check availability of the given namespace name. - :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.CheckNameAvailability + :param parameters: Parameters to check availability of the given namespace name. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.CheckNameAvailability or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameAvailabilityResult, or the result of cls(response) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResult] - _json = self._serialize.body(parameters, 'CheckNameAvailability') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _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'], + content=_content, + template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) @@ -1970,10 +2122,9 @@ def check_name_availability( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1981,12 +2132,11 @@ def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + 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 - + 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_11_01/operations/_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_operations.py index b9ddcd40a230..6f849a742cf5 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_operations.py @@ -7,10 +7,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- 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 urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -20,38 +25,34 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +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: + +def build_list_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.ServiceBus/operations") # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class Operations: """ @@ -72,36 +73,30 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.OperationListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """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_11_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -109,13 +104,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -131,10 +124,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -145,8 +136,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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_11_01/operations/_patch.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_patch.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_private_endpoint_connections_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_private_endpoint_connections_operations.py index 5c24300d7918..ab84aeba5e7d 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_private_endpoint_connections_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_private_endpoint_connections_operations.py @@ -6,11 +6,16 @@ # 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, Iterable, Optional, TypeVar, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -22,134 +27,130 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - subscription_id: str, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, - *, - json: Optional[_models.PrivateEndpointConnection] = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( +def build_delete_request( resource_group_name: str, namespace_name: str, - subscription_id: str, private_endpoint_connection_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( @@ -162,33 +163,35 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class PrivateEndpointConnectionsOperations: """ @@ -209,46 +212,41 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> Iterable[_models.PrivateEndpointConnectionListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> Iterable["_models.PrivateEndpointConnection"]: """Gets the available PrivateEndpointConnections within a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.PrivateEndpointConnectionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnectionListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # 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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -256,16 +254,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -281,10 +274,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -295,60 +286,128 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 + @overload def create_or_update( self, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, parameters: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.PrivateEndpointConnection: """Creates or updates PrivateEndpointConnections of service namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param private_endpoint_connection_name: The PrivateEndpointConnection name. + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. :type private_endpoint_connection_name: str :param parameters: Parameters supplied to update Status of PrivateEndPoint Connection to - namespace resource. + namespace resource. Required. :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.PrivateEndpointConnection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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.v2021_11_01.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Creates or updates PrivateEndpointConnections of service namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. + :type private_endpoint_connection_name: str + :param parameters: Parameters supplied to update Status of PrivateEndPoint Connection to + namespace resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateEndpointConnection, or the result of cls(response) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + parameters: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Creates or updates PrivateEndpointConnections of service namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. + :type private_endpoint_connection_name: str + :param parameters: Parameters supplied to update Status of PrivateEndPoint Connection to + namespace resource. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.PrivateEndpointConnection or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2021_11_01.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - _json = self._serialize.body(parameters, 'PrivateEndpointConnection') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _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, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -356,10 +415,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -368,48 +426,40 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + 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 - + 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: str, - namespace_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_request_initial( + request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, - subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) @@ -417,37 +467,32 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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_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 @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + def begin_delete( + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param private_endpoint_connection_name: The PrivateEndpointConnection name. + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. :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. @@ -459,97 +504,83 @@ def begin_delete( # pylint: disable=inconsistent-return-statements 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + 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 = self._delete_initial( # type: ignore 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, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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: str, - namespace_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param private_endpoint_connection_name: The PrivateEndpointConnection name. + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. :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) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -557,10 +588,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -568,12 +598,11 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + 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 - + 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_11_01/operations/_private_link_resources_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_private_link_resources_operations.py index 4b6c38cbe1ba..99162fa77662 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_private_link_resources_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_private_link_resources_operations.py @@ -8,9 +8,13 @@ # -------------------------------------------------------------------------- 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.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,48 +23,48 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class PrivateLinkResourcesOperations: """ @@ -81,43 +85,36 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def get( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: PrivateLinkResourcesListResult or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.PrivateLinkResourcesListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourcesListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResourcesListResult] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -125,10 +122,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -136,12 +132,11 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateLinkResourcesListResult', pipeline_response) + 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 - + 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_11_01/operations/_queues_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_queues_operations.py index 2396e8424900..c8eb69f57df0 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_queues_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_queues_operations.py @@ -6,11 +6,16 @@ # 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, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -20,50 +25,48 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") 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 + resource_group_name: str, namespace_name: str, queue_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_authorization_rule_request( @@ -72,47 +75,43 @@ def build_create_or_update_authorization_rule_request( queue_name: str, authorization_rule_name: str, subscription_id: str, - *, - json: Optional[_models.SBAuthorizationRule] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_authorization_rule_request( @@ -126,34 +125,35 @@ def build_delete_authorization_rule_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_authorization_rule_request( @@ -167,34 +167,35 @@ def build_get_authorization_rule_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( @@ -208,34 +209,35 @@ def build_list_keys_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_regenerate_keys_request( @@ -244,47 +246,43 @@ def build_regenerate_keys_request( queue_name: str, authorization_rule_name: str, subscription_id: str, - *, - json: Optional[_models.RegenerateAccessKeyParameters] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_namespace_request( @@ -299,161 +297,141 @@ def build_list_by_namespace_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if skip is not None: - _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', maximum=1000, minimum=0) + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", maximum=1000, minimum=0) if top is not None: - _params['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - resource_group_name: str, - namespace_name: str, - queue_name: str, - subscription_id: str, - *, - json: Optional[_models.SBQueue] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, queue_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - namespace_name: str, - queue_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, queue_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - namespace_name: str, - queue_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, queue_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class QueuesOperations: """ @@ -474,50 +452,43 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - **kwargs: Any - ) -> Iterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, queue_name: str, **kwargs: Any + ) -> Iterable["_models.SBAuthorizationRule"]: """Gets all authorization rules for a queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :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) + :return: An iterator like instance of either SBAuthorizationRule or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) @@ -525,17 +496,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -551,10 +516,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -565,13 +528,11 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 + @overload def create_or_update_authorization_rule( self, resource_group_name: str, @@ -579,38 +540,112 @@ def create_or_update_authorization_rule( queue_name: str, authorization_rule_name: str, parameters: _models.SBAuthorizationRule, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBAuthorizationRule: """Creates an authorization rule for a queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for a queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2021_11_01.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: Union[_models.SBAuthorizationRule, IO], + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for a queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2021_11_01.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - _json = self._serialize.body(parameters, 'SBAuthorizationRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBAuthorizationRule") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -621,7 +656,8 @@ def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -629,10 +665,9 @@ def create_or_update_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -640,15 +675,14 @@ def create_or_update_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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 @@ -661,31 +695,28 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes a queue authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -693,7 +724,7 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_authorization_rule.metadata['url'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -701,10 +732,9 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -715,8 +745,7 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements 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( @@ -729,31 +758,28 @@ def get_authorization_rule( ) -> _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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -761,7 +787,7 @@ def get_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -769,10 +795,9 @@ def get_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -780,15 +805,14 @@ def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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( @@ -801,31 +825,28 @@ def list_keys( ) -> _models.AccessKeys: """Primary and secondary connection strings to the queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -833,7 +854,7 @@ def list_keys( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -841,10 +862,9 @@ def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -852,17 +872,16 @@ def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore - - @distributed_trace + @overload def regenerate_keys( self, resource_group_name: str, @@ -870,38 +889,112 @@ def regenerate_keys( queue_name: str, authorization_rule_name: str, parameters: _models.RegenerateAccessKeyParameters, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.RegenerateAccessKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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.v2021_11_01.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateAccessKeyParameters, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.RegenerateAccessKeyParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2021_11_01.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateAccessKeyParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -912,7 +1005,8 @@ def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) @@ -920,10 +1014,9 @@ def regenerate_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -931,15 +1024,14 @@ def regenerate_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 - + 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( @@ -949,12 +1041,12 @@ def list_by_namespace( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable[_models.SBQueueListResult]: + ) -> Iterable["_models.SBQueue"]: """Gets the queues within a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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 @@ -964,32 +1056,30 @@ def list_by_namespace( 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_11_01.models.SBQueueListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either SBQueue or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.SBQueue] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBQueueListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + api_version=api_version, + template_url=self.list_by_namespace.metadata["url"], headers=_headers, params=_params, ) @@ -997,18 +1087,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -1024,10 +1107,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1038,49 +1119,115 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 + @overload def create_or_update( self, resource_group_name: str, namespace_name: str, queue_name: str, parameters: _models.SBQueue, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param parameters: Parameters supplied to create or update a queue resource. + :param parameters: Parameters supplied to create or update a queue resource. Required. :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.SBQueue + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBQueue, or the result of cls(response) + :return: SBQueue or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param parameters: Parameters supplied to create or update a queue resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2021_11_01.models.SBQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + parameters: Union[_models.SBQueue, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param parameters: Parameters supplied to create or update a queue resource. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.SBQueue or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2021_11_01.models.SBQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBQueue] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBQueue] - _json = self._serialize.body(parameters, 'SBQueue') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBQueue") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -1090,7 +1237,8 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -1098,10 +1246,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1109,56 +1256,48 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBQueue', pipeline_response) + 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 - + 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: str, - namespace_name: str, - queue_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -1166,10 +1305,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1180,49 +1318,39 @@ def delete( # pylint: disable=inconsistent-return-statements 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: str, - namespace_name: str, - queue_name: str, - **kwargs: Any - ) -> _models.SBQueue: + def get(self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :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) + :return: SBQueue or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBQueue] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBQueue] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -1230,10 +1358,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1241,12 +1368,11 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBQueue', pipeline_response) + 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 - + 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_11_01/operations/_rules_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_rules_operations.py index be66a582ba18..56f50fcf1fa3 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_rules_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_rules_operations.py @@ -6,11 +6,16 @@ # 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, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -20,13 +25,16 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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_subscriptions_request( resource_group_name: str, namespace_name: str, @@ -41,38 +49,37 @@ def build_list_by_subscriptions_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if skip is not None: - _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', maximum=1000, minimum=0) + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", maximum=1000, minimum=0) if top is not None: - _params['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( @@ -82,48 +89,42 @@ def build_create_or_update_request( subscription_name: str, rule_name: str, subscription_id: str, - *, - json: Optional[_models.Rule] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( @@ -138,35 +139,34 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( @@ -181,35 +181,35 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class RulesOperations: """ @@ -230,7 +230,6 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_by_subscriptions( self, @@ -241,16 +240,16 @@ def list_by_subscriptions( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable[_models.RuleListResult]: + ) -> Iterable["_models.Rule"]: """List all the rules within given topic-subscription. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :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 @@ -260,33 +259,32 @@ def list_by_subscriptions( 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_11_01.models.RuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Rule or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.Rule] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.RuleListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + api_version=api_version, + template_url=self.list_by_subscriptions.metadata["url"], headers=_headers, params=_params, ) @@ -294,20 +292,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -323,10 +312,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -337,13 +324,11 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 + @overload def create_or_update( self, resource_group_name: str, @@ -352,40 +337,120 @@ def create_or_update( subscription_name: str, rule_name: str, parameters: _models.Rule, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param rule_name: The rule name. + :param rule_name: The rule name. Required. :type rule_name: str - :param parameters: Parameters supplied to create a rule. + :param parameters: Parameters supplied to create a rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.Rule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Rule, or the result of cls(response) + :return: Rule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.Rule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param rule_name: The rule name. Required. + :type rule_name: str + :param parameters: Parameters supplied to create a rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2021_11_01.models.Rule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + parameters: Union[_models.Rule, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param rule_name: The rule name. Required. + :type rule_name: str + :param parameters: Parameters supplied to create a rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.Rule or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2021_11_01.models.Rule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Rule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Rule] - _json = self._serialize.body(parameters, 'Rule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Rule") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -397,7 +462,8 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -405,10 +471,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -416,15 +481,14 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Rule', pipeline_response) + 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 - + 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 @@ -438,33 +502,30 @@ def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes an existing rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param rule_name: The rule name. + :param rule_name: The rule name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -473,7 +534,7 @@ def delete( # pylint: disable=inconsistent-return-statements rule_name=rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -481,10 +542,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -495,8 +555,7 @@ def delete( # pylint: disable=inconsistent-return-statements 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( @@ -510,33 +569,30 @@ def get( ) -> _models.Rule: """Retrieves the description for the specified rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param rule_name: The rule name. + :param rule_name: The rule name. Required. :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) + :return: Rule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.Rule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Rule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Rule] - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -545,7 +601,7 @@ def get( rule_name=rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -553,10 +609,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -564,12 +619,11 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Rule', pipeline_response) + 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 - + 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_11_01/operations/_subscriptions_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_subscriptions_operations.py index 9ded268e4caa..74a8cccbcd4f 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_subscriptions_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_subscriptions_operations.py @@ -6,11 +6,16 @@ # 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, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -20,13 +25,16 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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_topic_request( resource_group_name: str, namespace_name: str, @@ -40,37 +48,36 @@ def build_list_by_topic_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if skip is not None: - _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', maximum=1000, minimum=0) + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", maximum=1000, minimum=0) if top is not None: - _params['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( @@ -79,47 +86,41 @@ def build_create_or_update_request( topic_name: str, subscription_name: str, subscription_id: str, - *, - json: Optional[_models.SBSubscription] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( @@ -133,34 +134,33 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( @@ -174,34 +174,34 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class SubscriptionsOperations: """ @@ -222,7 +222,6 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_by_topic( self, @@ -232,14 +231,14 @@ def list_by_topic( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable[_models.SBSubscriptionListResult]: + ) -> Iterable["_models.SBSubscription"]: """List all the subscriptions under a specified topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :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 @@ -249,34 +248,31 @@ def list_by_topic( 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_11_01.models.SBSubscriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either SBSubscription or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.SBSubscription] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBSubscriptionListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + api_version=api_version, + template_url=self.list_by_topic.metadata["url"], headers=_headers, params=_params, ) @@ -284,19 +280,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -312,10 +300,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -326,13 +312,11 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 + @overload def create_or_update( self, resource_group_name: str, @@ -340,38 +324,112 @@ def create_or_update( topic_name: str, subscription_name: str, parameters: _models.SBSubscription, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBSubscription: """Creates a topic subscription. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param parameters: Parameters supplied to create a subscription resource. + :param parameters: Parameters supplied to create a subscription resource. Required. :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.SBSubscription + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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.v2021_11_01.models.SBSubscription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBSubscription: + """Creates a topic subscription. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param parameters: Parameters supplied to create a subscription resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2021_11_01.models.SBSubscription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + parameters: Union[_models.SBSubscription, IO], + **kwargs: Any + ) -> _models.SBSubscription: + """Creates a topic subscription. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param parameters: Parameters supplied to create a subscription resource. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.SBSubscription or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBSubscription, or the result of cls(response) + :return: SBSubscription or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBSubscription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBSubscription] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBSubscription] - _json = self._serialize.body(parameters, 'SBSubscription') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBSubscription") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -382,7 +440,8 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -390,10 +449,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -401,52 +459,43 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBSubscription', pipeline_response) + 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 - + 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: str, - namespace_name: str, - topic_name: str, - subscription_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -454,7 +503,7 @@ def delete( # pylint: disable=inconsistent-return-statements subscription_name=subscription_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -462,10 +511,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -476,45 +524,36 @@ def delete( # pylint: disable=inconsistent-return-statements 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: str, - namespace_name: str, - topic_name: str, - subscription_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :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) + :return: SBSubscription or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBSubscription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBSubscription] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBSubscription] - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -522,7 +561,7 @@ def get( subscription_name=subscription_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -530,10 +569,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -541,12 +579,11 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBSubscription', pipeline_response) + 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 - + 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_11_01/operations/_topics_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_topics_operations.py index ba568af6a301..c7a963815aa7 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_topics_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2021_11_01/operations/_topics_operations.py @@ -6,11 +6,16 @@ # 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, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -20,50 +25,48 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") 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 + resource_group_name: str, namespace_name: str, topic_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_authorization_rule_request( @@ -72,47 +75,43 @@ def build_create_or_update_authorization_rule_request( topic_name: str, authorization_rule_name: str, subscription_id: str, - *, - json: Optional[_models.SBAuthorizationRule] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_authorization_rule_request( @@ -126,34 +125,35 @@ def build_get_authorization_rule_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_authorization_rule_request( @@ -167,34 +167,35 @@ def build_delete_authorization_rule_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( @@ -208,34 +209,35 @@ def build_list_keys_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_regenerate_keys_request( @@ -244,47 +246,43 @@ def build_regenerate_keys_request( topic_name: str, authorization_rule_name: str, subscription_id: str, - *, - json: Optional[_models.RegenerateAccessKeyParameters] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_namespace_request( @@ -299,161 +297,141 @@ def build_list_by_namespace_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if skip is not None: - _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', maximum=1000, minimum=0) + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", maximum=1000, minimum=0) if top is not None: - _params['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_id: str, - *, - json: Optional[_models.SBTopic] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, topic_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, topic_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, topic_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class TopicsOperations: """ @@ -474,50 +452,43 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - **kwargs: Any - ) -> Iterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, topic_name: str, **kwargs: Any + ) -> Iterable["_models.SBAuthorizationRule"]: """Gets authorization rules for a topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :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) + :return: An iterator like instance of either SBAuthorizationRule or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) @@ -525,17 +496,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -551,10 +516,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -565,13 +528,11 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 + @overload def create_or_update_authorization_rule( self, resource_group_name: str, @@ -579,38 +540,112 @@ def create_or_update_authorization_rule( topic_name: str, authorization_rule_name: str, parameters: _models.SBAuthorizationRule, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2021_11_01.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: Union[_models.SBAuthorizationRule, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2021_11_01.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - _json = self._serialize.body(parameters, 'SBAuthorizationRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBAuthorizationRule") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -621,7 +656,8 @@ def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -629,10 +665,9 @@ def create_or_update_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -640,15 +675,14 @@ def create_or_update_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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( @@ -661,31 +695,28 @@ def get_authorization_rule( ) -> _models.SBAuthorizationRule: """Returns the specified authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -693,7 +724,7 @@ def get_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -701,10 +732,9 @@ def get_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -712,15 +742,14 @@ def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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 @@ -733,31 +762,28 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes a topic authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -765,7 +791,7 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_authorization_rule.metadata['url'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -773,10 +799,9 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -787,8 +812,7 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements 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( @@ -801,31 +825,28 @@ def list_keys( ) -> _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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -833,7 +854,7 @@ def list_keys( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -841,10 +862,9 @@ def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -852,17 +872,16 @@ def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore - - @distributed_trace + @overload def regenerate_keys( self, resource_group_name: str, @@ -870,38 +889,112 @@ def regenerate_keys( topic_name: str, authorization_rule_name: str, parameters: _models.RegenerateAccessKeyParameters, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.RegenerateAccessKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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.v2021_11_01.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateAccessKeyParameters, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.RegenerateAccessKeyParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2021_11_01.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateAccessKeyParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -912,7 +1005,8 @@ def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) @@ -920,10 +1014,9 @@ def regenerate_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -931,15 +1024,14 @@ def regenerate_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 - + 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( @@ -949,12 +1041,12 @@ def list_by_namespace( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable[_models.SBTopicListResult]: + ) -> Iterable["_models.SBTopic"]: """Gets all the topics in a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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 @@ -964,32 +1056,30 @@ def list_by_namespace( 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_11_01.models.SBTopicListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either SBTopic or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2021_11_01.models.SBTopic] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBTopicListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + api_version=api_version, + template_url=self.list_by_namespace.metadata["url"], headers=_headers, params=_params, ) @@ -997,18 +1087,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -1024,10 +1107,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1038,49 +1119,115 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 + @overload def create_or_update( self, resource_group_name: str, namespace_name: str, topic_name: str, parameters: _models.SBTopic, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBTopic: """Creates a topic in the specified namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param parameters: Parameters supplied to create a topic resource. + :param parameters: Parameters supplied to create a topic resource. Required. :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.SBTopic + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBTopic, or the result of cls(response) + :return: SBTopic or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBTopic - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBTopic: + """Creates a topic in the specified namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param parameters: Parameters supplied to create a topic resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2021_11_01.models.SBTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + parameters: Union[_models.SBTopic, IO], + **kwargs: Any + ) -> _models.SBTopic: + """Creates a topic in the specified namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param parameters: Parameters supplied to create a topic resource. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2021_11_01.models.SBTopic or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2021_11_01.models.SBTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBTopic] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBTopic] - _json = self._serialize.body(parameters, 'SBTopic') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBTopic") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -1090,7 +1237,8 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -1098,10 +1246,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1109,56 +1256,48 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBTopic', pipeline_response) + 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 - + 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: str, - namespace_name: str, - topic_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -1166,10 +1305,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1180,49 +1318,39 @@ def delete( # pylint: disable=inconsistent-return-statements 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: str, - namespace_name: str, - topic_name: str, - **kwargs: Any - ) -> _models.SBTopic: + def get(self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :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) + :return: SBTopic or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2021_11_01.models.SBTopic - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBTopic] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBTopic] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -1230,10 +1358,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1241,12 +1368,11 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBTopic', pipeline_response) + 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 - + 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/v2022_01_01_preview/__init__.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/__init__.py index 221541a00fb6..2a82b6cb6f69 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/__init__.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/__init__.py @@ -17,7 +17,8 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['ServiceBusManagementClient'] + +__all__ = ["ServiceBusManagementClient"] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/_configuration.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/_configuration.py index 783200eb0f9c..edf19a57568d 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/_configuration.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/_configuration.py @@ -25,24 +25,19 @@ class ServiceBusManagementClientConfiguration(Configuration): # pylint: disable Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :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. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2022-01-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(ServiceBusManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str + api_version = kwargs.pop("api_version", "2022-01-01-preview") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -52,23 +47,24 @@ def __init__( self.credential = credential self.subscription_id = subscription_id 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.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-servicebus/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> None - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(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/v2022_01_01_preview/_metadata.json b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/_metadata.json index b470bf08107e..ac1ac1d7c65d 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/_metadata.json +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/_metadata.json @@ -10,20 +10,20 @@ "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\"], \"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\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ServiceBusManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ServiceBusManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", + "signature": "subscription_id: str,", + "description": "Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", + "description": "Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/_patch.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/_patch.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/_service_bus_management_client.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/_service_bus_management_client.py index fa1bf25ce31a..7acaebcdde70 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/_service_bus_management_client.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/_service_bus_management_client.py @@ -9,20 +9,31 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import ServiceBusManagementClientConfiguration -from .operations import DisasterRecoveryConfigsOperations, MigrationConfigsOperations, NamespacesOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, QueuesOperations, RulesOperations, SubscriptionsOperations, TopicsOperations +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: # pylint: disable=too-many-instance-attributes + +class ServiceBusManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Azure Service Bus client for managing Namespace. :ivar namespaces: NamespacesOperations operations @@ -50,10 +61,10 @@ class ServiceBusManagementClient: # pylint: disable=too-many-instance-attribu :ivar subscriptions: SubscriptionsOperations operations :vartype subscriptions: azure.mgmt.servicebus.v2022_01_01_preview.operations.SubscriptionsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :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. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -71,50 +82,35 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ServiceBusManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + 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._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.namespaces = NamespacesOperations( - 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.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.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: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -123,7 +119,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/_vendor.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/_vendor.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/_vendor.py @@ -7,6 +7,7 @@ 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) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): 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 - ] + 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/v2022_01_01_preview/_version.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/_version.py index 920456322fa1..9f1dc6e309ba 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/_version.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "8.1.0" +VERSION = "0.0.0 (it should be stable)" diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/__init__.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/__init__.py index e7dd87df1f93..ba757410f14a 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/__init__.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/__init__.py @@ -14,7 +14,8 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['ServiceBusManagementClient'] + +__all__ = ["ServiceBusManagementClient"] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/_configuration.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/_configuration.py index 3dab941141f1..479ddbe3b04c 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/_configuration.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/_configuration.py @@ -25,24 +25,19 @@ class ServiceBusManagementClientConfiguration(Configuration): # pylint: disable Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :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. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2022-01-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(ServiceBusManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2022-01-01-preview") # type: str + api_version = kwargs.pop("api_version", "2022-01-01-preview") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -52,22 +47,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id 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.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-servicebus/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, - **kwargs: Any - ) -> None: - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(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/v2022_01_01_preview/aio/_patch.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/_patch.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/_service_bus_management_client.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/_service_bus_management_client.py index 13c1abe32866..6894cdf34ee4 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/_service_bus_management_client.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/_service_bus_management_client.py @@ -9,20 +9,31 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import ServiceBusManagementClientConfiguration -from .operations import DisasterRecoveryConfigsOperations, MigrationConfigsOperations, NamespacesOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, QueuesOperations, RulesOperations, SubscriptionsOperations, TopicsOperations +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: # pylint: disable=too-many-instance-attributes + +class ServiceBusManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Azure Service Bus client for managing Namespace. :ivar namespaces: NamespacesOperations operations @@ -51,10 +62,10 @@ class ServiceBusManagementClient: # pylint: disable=too-many-instance-attribu :ivar subscriptions: SubscriptionsOperations operations :vartype subscriptions: azure.mgmt.servicebus.v2022_01_01_preview.aio.operations.SubscriptionsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :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. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -72,50 +83,35 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ServiceBusManagementClientConfiguration(credential=credential, subscription_id=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._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.namespaces = NamespacesOperations( - 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.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.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 - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -124,7 +120,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/__init__.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/__init__.py index 5559ccd3746c..831edc36bd6b 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/__init__.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/__init__.py @@ -20,17 +20,18 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'NamespacesOperations', - 'PrivateEndpointConnectionsOperations', - 'PrivateLinkResourcesOperations', - 'Operations', - 'DisasterRecoveryConfigsOperations', - 'MigrationConfigsOperations', - 'QueuesOperations', - 'TopicsOperations', - 'RulesOperations', - 'SubscriptionsOperations', + "NamespacesOperations", + "PrivateEndpointConnectionsOperations", + "PrivateLinkResourcesOperations", + "Operations", + "DisasterRecoveryConfigsOperations", + "MigrationConfigsOperations", + "QueuesOperations", + "TopicsOperations", + "RulesOperations", + "SubscriptionsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_disaster_recovery_configs_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_disaster_recovery_configs_operations.py index f67e9b774890..64a6f7880d84 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_disaster_recovery_configs_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_disaster_recovery_configs_operations.py @@ -6,10 +6,17 @@ # 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, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +27,23 @@ 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') +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]] + class DisasterRecoveryConfigsOperations: """ .. warning:: @@ -43,46 +63,40 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.ArmDisasterRecoveryListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ArmDisasterRecovery"]: """Gets all Alias(Disaster Recovery configurations). - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: An iterator like instance of either ArmDisasterRecovery or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.ArmDisasterRecoveryListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.ArmDisasterRecovery] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ArmDisasterRecoveryListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -90,16 +104,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -115,10 +124,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -129,49 +136,117 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 + @overload async def create_or_update( self, resource_group_name: str, namespace_name: str, alias: str, parameters: _models.ArmDisasterRecovery, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Required. :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.ArmDisasterRecovery + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ArmDisasterRecovery or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.ArmDisasterRecovery or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ArmDisasterRecovery, or the result of cls(response) + :return: ArmDisasterRecovery or None or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.ArmDisasterRecovery or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: Union[_models.ArmDisasterRecovery, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). Is + either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.ArmDisasterRecovery or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ArmDisasterRecovery or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.ArmDisasterRecovery or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ArmDisasterRecovery]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ArmDisasterRecovery]] - _json = self._serialize.body(parameters, 'ArmDisasterRecovery') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ArmDisasterRecovery") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -181,7 +256,8 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -189,10 +265,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -202,56 +277,48 @@ async def create_or_update( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ArmDisasterRecovery', pipeline_response) + 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 - + 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, - alias: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -259,10 +326,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -273,49 +339,41 @@ async def delete( # pylint: disable=inconsistent-return-statements 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, - namespace_name: str, - alias: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :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) + :return: ArmDisasterRecovery or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.ArmDisasterRecovery - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ArmDisasterRecovery] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ArmDisasterRecovery] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -323,10 +381,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -334,57 +391,49 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ArmDisasterRecovery', pipeline_response) + 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 - + 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, - alias: str, - **kwargs: Any + self, 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. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.break_pairing.metadata["url"], headers=_headers, params=_params, ) @@ -392,10 +441,9 @@ async def break_pairing( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -406,50 +454,118 @@ async def break_pairing( # pylint: disable=inconsistent-return-statements 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 - @distributed_trace_async + @overload async def fail_over( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, alias: str, parameters: Optional[_models.FailoverProperties] = None, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). Default value is None. :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.FailoverProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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: + """ + + @overload + async def fail_over( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Default value is None. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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: + """ + + @distributed_trace_async + async def fail_over( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: Optional[Union[_models.FailoverProperties, IO]] = 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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). Is + either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.FailoverProperties or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - if parameters is not None: - _json = self._serialize.body(parameters, 'FailoverProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "FailoverProperties") + else: + _json = None request = build_fail_over_request( resource_group_name=resource_group_name, @@ -459,7 +575,8 @@ async def fail_over( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, json=_json, - template_url=self.fail_over.metadata['url'], + content=_content, + template_url=self.fail_over.metadata["url"], headers=_headers, params=_params, ) @@ -467,10 +584,9 @@ async def fail_over( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -481,52 +597,45 @@ async def fail_over( # pylint: disable=inconsistent-return-statements 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, - namespace_name: str, - alias: str, - **kwargs: Any - ) -> AsyncIterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, alias: str, **kwargs: Any + ) -> AsyncIterable["_models.SBAuthorizationRule"]: """Gets the authorization rules for a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :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) + :return: An iterator like instance of either SBAuthorizationRule or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.SBAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.SBAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) @@ -534,17 +643,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -560,10 +663,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -574,48 +675,38 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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, - namespace_name: str, - alias: str, - authorization_rule_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -623,7 +714,7 @@ async def get_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -631,10 +722,9 @@ async def get_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -642,52 +732,43 @@ async def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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, - namespace_name: str, - alias: str, - authorization_rule_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -695,7 +776,7 @@ async def list_keys( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -703,10 +784,9 @@ async def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -714,50 +794,111 @@ async def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 - + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}/listKeys"} # type: ignore - @distributed_trace_async + @overload async def check_name_availability( self, resource_group_name: str, namespace_name: str, parameters: _models.CheckNameAvailability, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Check the give namespace name availability. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters to check availability of the given namespace name. + :param parameters: Parameters to check availability of the given namespace name. Required. :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.CheckNameAvailability + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameAvailabilityResult, or the result of cls(response) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + async def check_name_availability( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters to check availability of the given namespace name. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :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.v2022_01_01_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, + resource_group_name: str, + namespace_name: str, + parameters: Union[_models.CheckNameAvailability, IO], + **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters to check availability of the given namespace name. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.CheckNameAvailability or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :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.v2022_01_01_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResult] - _json = self._serialize.body(parameters, 'CheckNameAvailability') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CheckNameAvailability") request = build_check_name_availability_request( resource_group_name=resource_group_name, @@ -766,7 +907,8 @@ async def check_name_availability( api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) @@ -774,10 +916,9 @@ async def check_name_availability( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -785,12 +926,11 @@ async def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + 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 - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/CheckNameAvailability"} # type: ignore diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_migration_configs_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_migration_configs_operations.py index 0cb763195c64..ec35c489501c 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_migration_configs_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_migration_configs_operations.py @@ -6,10 +6,17 @@ # 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, Optional, TypeVar, Union, cast +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +29,19 @@ 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') +from ...operations._migration_configs_operations import ( + build_complete_migration_request, + build_create_and_start_migration_request, + 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]] + class MigrationConfigsOperations: """ .. warning:: @@ -45,46 +61,41 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.MigrationConfigListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.MigrationConfigProperties"]: """Gets all migrationConfigurations. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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 + :return: An iterator like instance of either MigrationConfigProperties or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.MigrationConfigListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.MigrationConfigProperties] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MigrationConfigListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -92,16 +103,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -117,10 +123,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -131,35 +135,37 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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, resource_group_name: str, namespace_name: str, config_name: Union[str, "_models.MigrationConfigurationName"], - parameters: _models.MigrationConfigProperties, + parameters: Union[_models.MigrationConfigProperties, IO], **kwargs: Any ) -> Optional[_models.MigrationConfigProperties]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.MigrationConfigProperties]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.MigrationConfigProperties]] - _json = self._serialize.body(parameters, 'MigrationConfigProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "MigrationConfigProperties") - request = build_create_and_start_migration_request_initial( + request = build_create_and_start_migration_request( resource_group_name=resource_group_name, namespace_name=namespace_name, config_name=config_name, @@ -167,7 +173,8 @@ async def _create_and_start_migration_initial( api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_and_start_migration_initial.metadata['url'], + content=_content, + template_url=self._create_and_start_migration_initial.metadata["url"], headers=_headers, params=_params, ) @@ -175,27 +182,108 @@ async def _create_and_start_migration_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) + 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 + _create_and_start_migration_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore + @overload + async def begin_create_and_start_migration( + self, + resource_group_name: str, + namespace_name: str, + config_name: Union[str, "_models.MigrationConfigurationName"], + parameters: _models.MigrationConfigProperties, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> 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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param config_name: The configuration name. Should always be "$default". "$default" Required. + :type config_name: str or + ~azure.mgmt.servicebus.v2022_01_01_preview.models.MigrationConfigurationName + :param parameters: Parameters required to create Migration Configuration. Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.MigrationConfigProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. + :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.v2022_01_01_preview.models.MigrationConfigProperties] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_and_start_migration( + self, + resource_group_name: str, + namespace_name: str, + config_name: Union[str, "_models.MigrationConfigurationName"], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> 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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param config_name: The configuration name. Should always be "$default". "$default" Required. + :type config_name: str or + ~azure.mgmt.servicebus.v2022_01_01_preview.models.MigrationConfigurationName + :param parameters: Parameters required to create Migration Configuration. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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.v2022_01_01_preview.models.MigrationConfigProperties] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_and_start_migration( @@ -203,21 +291,26 @@ async def begin_create_and_start_migration( resource_group_name: str, namespace_name: str, config_name: Union[str, "_models.MigrationConfigurationName"], - parameters: _models.MigrationConfigProperties, + parameters: Union[_models.MigrationConfigProperties, IO], **kwargs: Any ) -> 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2022_01_01_preview.models.MigrationConfigurationName - :param parameters: Parameters required to create Migration Configuration. + :param parameters: Parameters required to create Migration Configuration. Is either a model + type or a IO type. Required. :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.MigrationConfigProperties + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -230,20 +323,17 @@ async def begin_create_and_start_migration( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicebus.v2022_01_01_preview.models.MigrationConfigProperties] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.MigrationConfigProperties] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MigrationConfigProperties] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + 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( # type: ignore resource_group_name=resource_group_name, @@ -252,39 +342,35 @@ async def begin_create_and_start_migration( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) + deserialized = self._deserialize("MigrationConfigProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, 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 + deserialization_callback=get_long_running_output, ) 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 + begin_create_and_start_migration.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -296,37 +382,34 @@ async def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes a MigrationConfiguration. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2022_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -334,10 +417,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -348,8 +430,7 @@ async def delete( # pylint: disable=inconsistent-return-statements 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( @@ -361,37 +442,34 @@ async def get( ) -> _models.MigrationConfigProperties: """Retrieves Migration Config. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2022_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) + :return: MigrationConfigProperties or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.MigrationConfigProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MigrationConfigProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MigrationConfigProperties] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -399,10 +477,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -410,15 +487,14 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) + 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 - + 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 @@ -432,37 +508,34 @@ async def complete_migration( # pylint: disable=inconsistent-return-statements 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2022_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.complete_migration.metadata["url"], headers=_headers, params=_params, ) @@ -470,10 +543,9 @@ async def complete_migration( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -484,8 +556,7 @@ async def complete_migration( # pylint: disable=inconsistent-return-statements 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 @distributed_trace_async async def revert( # pylint: disable=inconsistent-return-statements @@ -497,37 +568,34 @@ async def revert( # pylint: disable=inconsistent-return-statements ) -> None: """This operation reverts Migration. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2022_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.revert.metadata["url"], headers=_headers, params=_params, ) @@ -535,10 +603,9 @@ async def revert( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -549,5 +616,4 @@ async def revert( # pylint: disable=inconsistent-return-statements 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/v2022_01_01_preview/aio/operations/_namespaces_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_namespaces_operations.py index a2767c6538bc..631472edb6af 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_namespaces_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_namespaces_operations.py @@ -6,10 +6,17 @@ # 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, Optional, TypeVar, Union, cast +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +29,29 @@ 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') +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, + build_delete_authorization_rule_request, + build_delete_request, + 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]] + class NamespacesOperations: """ .. warning:: @@ -45,38 +71,32 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.SBNamespaceListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.SBNamespace"]: """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) + :return: An iterator like instance of either SBNamespace or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.SBNamespaceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.SBNamespace] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespaceListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -84,14 +104,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -107,10 +124,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -121,47 +136,39 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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, - **kwargs: Any - ) -> AsyncIterable[_models.SBNamespaceListResult]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.SBNamespace"]: """Gets the available namespaces within a resource group. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :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) + :return: An iterator like instance of either SBNamespace or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.SBNamespaceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.SBNamespace] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespaceListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -169,15 +176,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -193,10 +196,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -207,41 +208,40 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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, - resource_group_name: str, - namespace_name: str, - parameters: _models.SBNamespace, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, parameters: Union[_models.SBNamespace, IO], **kwargs: Any ) -> Optional[_models.SBNamespace]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.SBNamespace]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.SBNamespace]] - _json = self._serialize.body(parameters, 'SBNamespace') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBNamespace") - request = build_create_or_update_request_initial( + request = build_create_or_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._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) @@ -249,48 +249,121 @@ async def _create_or_update_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SBNamespace', pipeline_response) + 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 - + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - @distributed_trace_async + @overload async def begin_create_or_update( self, resource_group_name: str, namespace_name: str, parameters: _models.SBNamespace, + *, + content_type: str = "application/json", **kwargs: Any ) -> 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters supplied to create a namespace resource. + :param parameters: Parameters supplied to create a namespace resource. Required. :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBNamespace + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. + :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.v2022_01_01_preview.models.SBNamespace] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> 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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to create a namespace resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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.v2022_01_01_preview.models.SBNamespace] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, resource_group_name: str, namespace_name: str, parameters: Union[_models.SBNamespace, IO], **kwargs: Any + ) -> 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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to create a namespace resource. Is either a model type + or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBNamespace or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -303,20 +376,17 @@ async def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicebus.v2022_01_01_preview.models.SBNamespace] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespace] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBNamespace] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + 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( # type: ignore resource_group_name=resource_group_name, @@ -324,64 +394,54 @@ async def begin_create_or_update( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, 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 + deserialization_callback=get_long_running_output, ) 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 + 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, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_request_initial( + request = build_delete_request( 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'], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) @@ -389,35 +449,29 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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_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 @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete(self, resource_group_name: str, namespace_name: str, **kwargs: Any) -> 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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. @@ -429,92 +483,77 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + 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( # type: ignore resource_group_name=resource_group_name, namespace_name=namespace_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, 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 + deserialization_callback=get_long_running_output, ) 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 + 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, - namespace_name: str, - **kwargs: Any - ) -> _models.SBNamespace: + async def get(self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: SBNamespace or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBNamespace - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespace] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBNamespace] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -522,10 +561,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -533,51 +571,115 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBNamespace', pipeline_response) + 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 + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + @overload + async def update( + self, + resource_group_name: str, + namespace_name: str, + parameters: _models.SBNamespaceUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> 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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to update a namespace resource. Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBNamespaceUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBNamespace or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBNamespace or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> 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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to update a namespace resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBNamespace or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBNamespace or None + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def update( self, resource_group_name: str, namespace_name: str, - parameters: _models.SBNamespaceUpdateParameters, + parameters: Union[_models.SBNamespaceUpdateParameters, IO], **kwargs: Any ) -> 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters supplied to update a namespace resource. + :param parameters: Parameters supplied to update a namespace resource. Is either a model type + or a IO type. Required. :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBNamespaceUpdateParameters + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBNamespace, or the result of cls(response) + :return: SBNamespace or None or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBNamespace or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.SBNamespace]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.SBNamespace]] - _json = self._serialize.body(parameters, 'SBNamespaceUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBNamespaceUpdateParameters") request = build_update_request( resource_group_name=resource_group_name, @@ -586,7 +688,8 @@ async def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -594,10 +697,9 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -607,53 +709,113 @@ async def update( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SBNamespace', pipeline_response) + 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 + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - - @distributed_trace_async + @overload async def create_or_update_network_rule_set( self, resource_group_name: str, namespace_name: str, parameters: _models.NetworkRuleSet, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.NetworkRuleSet: """Create or update NetworkRuleSet for a Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: The Namespace IpFilterRule. + :param parameters: The Namespace IpFilterRule. Required. :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.NetworkRuleSet + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: NetworkRuleSet, or the result of cls(response) + :return: NetworkRuleSet or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.NetworkRuleSet - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + async def create_or_update_network_rule_set( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NetworkRuleSet: + """Create or update NetworkRuleSet for a Namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: The Namespace IpFilterRule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2022_01_01_preview.models.NetworkRuleSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_network_rule_set( + self, + resource_group_name: str, + namespace_name: str, + parameters: Union[_models.NetworkRuleSet, IO], + **kwargs: Any + ) -> _models.NetworkRuleSet: + """Create or update NetworkRuleSet for a Namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: The Namespace IpFilterRule. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.NetworkRuleSet or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2022_01_01_preview.models.NetworkRuleSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkRuleSet] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.NetworkRuleSet] - _json = self._serialize.body(parameters, 'NetworkRuleSet') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "NetworkRuleSet") request = build_create_or_update_network_rule_set_request( resource_group_name=resource_group_name, @@ -662,7 +824,8 @@ async def create_or_update_network_rule_set( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_network_rule_set.metadata['url'], + content=_content, + template_url=self.create_or_update_network_rule_set.metadata["url"], headers=_headers, params=_params, ) @@ -670,10 +833,9 @@ async def create_or_update_network_rule_set( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -681,52 +843,45 @@ async def create_or_update_network_rule_set( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('NetworkRuleSet', pipeline_response) + 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 - + 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, - namespace_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: NetworkRuleSet or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.NetworkRuleSet - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkRuleSet] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.NetworkRuleSet] - 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'], + template_url=self.get_network_rule_set.metadata["url"], headers=_headers, params=_params, ) @@ -734,10 +889,9 @@ async def get_network_rule_set( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -745,55 +899,49 @@ async def get_network_rule_set( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('NetworkRuleSet', pipeline_response) + 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 - + 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, - namespace_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.NetworkRuleSetListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.NetworkRuleSet"]: """Gets list of NetworkRuleSet for a Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: An iterator like instance of either NetworkRuleSet or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.NetworkRuleSetListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.NetworkRuleSet] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkRuleSetListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_network_rule_sets.metadata["url"], headers=_headers, params=_params, ) @@ -801,16 +949,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -826,10 +969,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -840,51 +981,44 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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, - namespace_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SBAuthorizationRule"]: """Gets the authorization rules for a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: An iterator like instance of either SBAuthorizationRule or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.SBAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.SBAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) @@ -892,16 +1026,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -917,10 +1046,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -931,49 +1058,115 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 + @overload async def create_or_update_authorization_rule( self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, parameters: _models.SBAuthorizationRule, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBAuthorizationRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2022_01_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: Union[_models.SBAuthorizationRule, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBAuthorizationRule or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2022_01_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - _json = self._serialize.body(parameters, 'SBAuthorizationRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBAuthorizationRule") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -983,7 +1176,8 @@ async def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -991,10 +1185,9 @@ async def create_or_update_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1002,56 +1195,48 @@ async def create_or_update_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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, - authorization_rule_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -1059,10 +1244,9 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1073,49 +1257,41 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat 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, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - 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'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -1123,10 +1299,9 @@ async def get_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1134,56 +1309,48 @@ async def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - 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'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1191,10 +1358,9 @@ async def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1202,54 +1368,122 @@ async def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys"} # type: ignore - - @distributed_trace_async + @overload async def regenerate_keys( self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, parameters: _models.RegenerateAccessKeyParameters, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.RegenerateAccessKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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.v2022_01_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace_async + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateAccessKeyParameters, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: + ~azure.mgmt.servicebus.v2022_01_01_preview.models.RegenerateAccessKeyParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2022_01_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateAccessKeyParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -1259,7 +1493,8 @@ async def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1267,10 +1502,9 @@ async def regenerate_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1278,51 +1512,91 @@ async def regenerate_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 + regenerate_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore + @overload + async def check_name_availability( + self, parameters: _models.CheckNameAvailability, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param parameters: Parameters to check availability of the given namespace name. Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.CheckNameAvailability + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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.v2022_01_01_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param parameters: Parameters to check availability of the given namespace name. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :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.v2022_01_01_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def check_name_availability( - self, - parameters: _models.CheckNameAvailability, - **kwargs: Any + self, parameters: Union[_models.CheckNameAvailability, IO], **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Check the give namespace name availability. - :param parameters: Parameters to check availability of the given namespace name. - :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.CheckNameAvailability + :param parameters: Parameters to check availability of the given namespace name. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.CheckNameAvailability or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameAvailabilityResult, or the result of cls(response) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResult] - _json = self._serialize.body(parameters, 'CheckNameAvailability') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _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'], + content=_content, + template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) @@ -1330,10 +1604,9 @@ async def check_name_availability( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1341,12 +1614,11 @@ async def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + 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 - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability"} # type: ignore diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_operations.py index 6691d1b4ee72..ee1c7157dde7 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_operations.py @@ -7,9 +7,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +27,11 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class Operations: """ .. warning:: @@ -42,36 +51,31 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.OperationListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """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) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -79,13 +83,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -101,10 +103,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -115,8 +115,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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/v2022_01_01_preview/aio/operations/_patch.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_patch.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_private_endpoint_connections_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_private_endpoint_connections_operations.py index 17fc571750fa..a5d455c09581 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_private_endpoint_connections_operations.py @@ -6,10 +6,17 @@ # 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, Optional, TypeVar, Union, cast +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +29,17 @@ 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') +from ...operations._private_endpoint_connections_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class PrivateEndpointConnectionsOperations: """ .. warning:: @@ -45,46 +59,41 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.PrivateEndpointConnectionListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PrivateEndpointConnection"]: """Gets the available PrivateEndpointConnections within a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.PrivateEndpointConnectionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnectionListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -92,16 +101,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -117,10 +121,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -131,60 +133,129 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 + @overload async def create_or_update( self, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, parameters: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.PrivateEndpointConnection: """Creates or updates PrivateEndpointConnections of service namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param private_endpoint_connection_name: The PrivateEndpointConnection name. + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. :type private_endpoint_connection_name: str :param parameters: Parameters supplied to update Status of PrivateEndPoint Connection to - namespace resource. + namespace resource. Required. :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.PrivateEndpointConnection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateEndpointConnection, or the result of cls(response) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Creates or updates PrivateEndpointConnections of service namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. + :type private_endpoint_connection_name: str + :param parameters: Parameters supplied to update Status of PrivateEndPoint Connection to + namespace resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2022_01_01_preview.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + parameters: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Creates or updates PrivateEndpointConnections of service namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. + :type private_endpoint_connection_name: str + :param parameters: Parameters supplied to update Status of PrivateEndPoint Connection to + namespace resource. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.PrivateEndpointConnection + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2022_01_01_preview.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - _json = self._serialize.body(parameters, 'PrivateEndpointConnection') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _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, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -192,10 +263,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -204,48 +274,40 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + 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 - + 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, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_request_initial( + request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, - subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) @@ -253,37 +315,32 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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_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 @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes an existing Private Endpoint Connection. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param private_endpoint_connection_name: The PrivateEndpointConnection name. + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. :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. @@ -295,97 +352,83 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + 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( # type: ignore 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, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, 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 + deserialization_callback=get_long_running_output, ) 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 + 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, - namespace_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param private_endpoint_connection_name: The PrivateEndpointConnection name. + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. :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) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -393,10 +436,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -404,12 +446,11 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + 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 - + 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/v2022_01_01_preview/aio/operations/_private_link_resources_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_private_link_resources_operations.py index 9ae4e692ece3..9408fee38a9c 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_private_link_resources_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_private_link_resources_operations.py @@ -8,7 +8,13 @@ # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Optional, TypeVar -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -19,9 +25,11 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._private_link_resources_operations import build_get_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class PrivateLinkResourcesOperations: """ .. warning:: @@ -41,43 +49,36 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async async def get( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: PrivateLinkResourcesListResult or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.PrivateLinkResourcesListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourcesListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResourcesListResult] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -85,10 +86,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -96,12 +96,11 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateLinkResourcesListResult', pipeline_response) + 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 - + 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/v2022_01_01_preview/aio/operations/_queues_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_queues_operations.py index 7f7e1f04ab7a..f540eb01f261 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_queues_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_queues_operations.py @@ -6,10 +6,17 @@ # 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, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +27,23 @@ 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') +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]] + class QueuesOperations: """ .. warning:: @@ -43,50 +63,43 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, queue_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SBAuthorizationRule"]: """Gets all authorization rules for a queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :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) + :return: An iterator like instance of either SBAuthorizationRule or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.SBAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.SBAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) @@ -94,17 +107,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -120,10 +127,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -134,13 +139,11 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 + @overload async def create_or_update_authorization_rule( self, resource_group_name: str, @@ -148,38 +151,112 @@ async def create_or_update_authorization_rule( queue_name: str, authorization_rule_name: str, parameters: _models.SBAuthorizationRule, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBAuthorizationRule: """Creates an authorization rule for a queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBAuthorizationRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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.v2022_01_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for a queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace_async + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: Union[_models.SBAuthorizationRule, IO], + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for a queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBAuthorizationRule or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2022_01_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - _json = self._serialize.body(parameters, 'SBAuthorizationRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBAuthorizationRule") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -190,7 +267,8 @@ async def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -198,10 +276,9 @@ async def create_or_update_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -209,15 +286,14 @@ async def create_or_update_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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 @@ -230,31 +306,28 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat ) -> None: """Deletes a queue authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -262,7 +335,7 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_authorization_rule.metadata['url'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -270,10 +343,9 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -284,8 +356,7 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat 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( @@ -298,31 +369,28 @@ async def get_authorization_rule( ) -> _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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -330,7 +398,7 @@ async def get_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -338,10 +406,9 @@ async def get_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -349,15 +416,14 @@ async def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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( @@ -370,31 +436,28 @@ async def list_keys( ) -> _models.AccessKeys: """Primary and secondary connection strings to the queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -402,7 +465,7 @@ async def list_keys( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -410,10 +473,9 @@ async def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -421,17 +483,16 @@ async def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 - + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore - @distributed_trace_async + @overload async def regenerate_keys( self, resource_group_name: str, @@ -439,39 +500,114 @@ async def regenerate_keys( queue_name: str, authorization_rule_name: str, parameters: _models.RegenerateAccessKeyParameters, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.RegenerateAccessKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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.v2022_01_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2022_01_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateAccessKeyParameters, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: + ~azure.mgmt.servicebus.v2022_01_01_preview.models.RegenerateAccessKeyParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateAccessKeyParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -482,7 +618,8 @@ async def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) @@ -490,10 +627,9 @@ async def regenerate_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -501,15 +637,14 @@ async def regenerate_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 - + 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( @@ -519,12 +654,12 @@ def list_by_namespace( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable[_models.SBQueueListResult]: + ) -> AsyncIterable["_models.SBQueue"]: """Gets the queues within a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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 @@ -534,32 +669,31 @@ def list_by_namespace( 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) + :return: An iterator like instance of either SBQueue or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.SBQueueListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.SBQueue] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBQueueListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + api_version=api_version, + template_url=self.list_by_namespace.metadata["url"], headers=_headers, params=_params, ) @@ -567,18 +701,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -594,10 +721,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -608,49 +733,115 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 + @overload async def create_or_update( self, resource_group_name: str, namespace_name: str, queue_name: str, parameters: _models.SBQueue, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param parameters: Parameters supplied to create or update a queue resource. + :param parameters: Parameters supplied to create or update a queue resource. Required. :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBQueue + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBQueue, or the result of cls(response) + :return: SBQueue or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param parameters: Parameters supplied to create or update a queue resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2022_01_01_preview.models.SBQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + parameters: Union[_models.SBQueue, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param parameters: Parameters supplied to create or update a queue resource. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBQueue or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2022_01_01_preview.models.SBQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBQueue] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBQueue] - _json = self._serialize.body(parameters, 'SBQueue') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBQueue") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -660,7 +851,8 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -668,10 +860,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -679,56 +870,48 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBQueue', pipeline_response) + 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 - + 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, - queue_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -736,10 +919,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -750,49 +932,41 @@ async def delete( # pylint: disable=inconsistent-return-statements 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, - namespace_name: str, - queue_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :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) + :return: SBQueue or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBQueue] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBQueue] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -800,10 +974,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -811,12 +984,11 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBQueue', pipeline_response) + 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 - + 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/v2022_01_01_preview/aio/operations/_rules_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_rules_operations.py index 3fe195decf17..00a8aa8caaaa 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_rules_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_rules_operations.py @@ -6,10 +6,17 @@ # 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, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +27,17 @@ 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') +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]] + class RulesOperations: """ .. warning:: @@ -43,7 +57,6 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_by_subscriptions( self, @@ -54,16 +67,16 @@ def list_by_subscriptions( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable[_models.RuleListResult]: + ) -> AsyncIterable["_models.Rule"]: """List all the rules within given topic-subscription. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :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 @@ -73,34 +86,33 @@ def list_by_subscriptions( 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) + :return: An iterator like instance of either Rule or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.RuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.Rule] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.RuleListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + api_version=api_version, + template_url=self.list_by_subscriptions.metadata["url"], headers=_headers, params=_params, ) @@ -108,20 +120,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -137,10 +140,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -151,13 +152,11 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 + @overload async def create_or_update( self, resource_group_name: str, @@ -166,40 +165,120 @@ async def create_or_update( subscription_name: str, rule_name: str, parameters: _models.Rule, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param rule_name: The rule name. + :param rule_name: The rule name. Required. :type rule_name: str - :param parameters: Parameters supplied to create a rule. + :param parameters: Parameters supplied to create a rule. Required. :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.Rule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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.v2022_01_01_preview.models.Rule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param rule_name: The rule name. Required. + :type rule_name: str + :param parameters: Parameters supplied to create a rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2022_01_01_preview.models.Rule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + parameters: Union[_models.Rule, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param rule_name: The rule name. Required. + :type rule_name: str + :param parameters: Parameters supplied to create a rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.Rule or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Rule, or the result of cls(response) + :return: Rule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.Rule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Rule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Rule] - _json = self._serialize.body(parameters, 'Rule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Rule") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -211,7 +290,8 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -219,10 +299,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -230,15 +309,14 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Rule', pipeline_response) + 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 - + 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 @@ -252,33 +330,30 @@ async def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes an existing rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param rule_name: The rule name. + :param rule_name: The rule name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -287,7 +362,7 @@ async def delete( # pylint: disable=inconsistent-return-statements rule_name=rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -295,10 +370,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -309,8 +383,7 @@ async def delete( # pylint: disable=inconsistent-return-statements 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( @@ -324,33 +397,30 @@ async def get( ) -> _models.Rule: """Retrieves the description for the specified rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param rule_name: The rule name. + :param rule_name: The rule name. Required. :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) + :return: Rule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.Rule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Rule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Rule] - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -359,7 +429,7 @@ async def get( rule_name=rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -367,10 +437,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -378,12 +447,11 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Rule', pipeline_response) + 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 - + 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/v2022_01_01_preview/aio/operations/_subscriptions_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_subscriptions_operations.py index b4a603ce4f1d..e546c8d0eab7 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_subscriptions_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_subscriptions_operations.py @@ -6,10 +6,17 @@ # 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, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +27,17 @@ 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') +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]] + class SubscriptionsOperations: """ .. warning:: @@ -43,7 +57,6 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_by_topic( self, @@ -53,14 +66,14 @@ def list_by_topic( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable[_models.SBSubscriptionListResult]: + ) -> AsyncIterable["_models.SBSubscription"]: """List all the subscriptions under a specified topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :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 @@ -70,34 +83,32 @@ def list_by_topic( 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) + :return: An iterator like instance of either SBSubscription or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.SBSubscriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.SBSubscription] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBSubscriptionListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + api_version=api_version, + template_url=self.list_by_topic.metadata["url"], headers=_headers, params=_params, ) @@ -105,19 +116,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -133,10 +136,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -147,13 +148,11 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 + @overload async def create_or_update( self, resource_group_name: str, @@ -161,38 +160,112 @@ async def create_or_update( topic_name: str, subscription_name: str, parameters: _models.SBSubscription, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBSubscription: """Creates a topic subscription. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param parameters: Parameters supplied to create a subscription resource. + :param parameters: Parameters supplied to create a subscription resource. Required. :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBSubscription + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBSubscription, or the result of cls(response) + :return: SBSubscription or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBSubscription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBSubscription: + """Creates a topic subscription. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param parameters: Parameters supplied to create a subscription resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2022_01_01_preview.models.SBSubscription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + parameters: Union[_models.SBSubscription, IO], + **kwargs: Any + ) -> _models.SBSubscription: + """Creates a topic subscription. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param parameters: Parameters supplied to create a subscription resource. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBSubscription or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2022_01_01_preview.models.SBSubscription + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBSubscription] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBSubscription] - _json = self._serialize.body(parameters, 'SBSubscription') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBSubscription") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -203,7 +276,8 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -211,10 +285,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -222,52 +295,43 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBSubscription', pipeline_response) + 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 - + 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, - topic_name: str, - subscription_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -275,7 +339,7 @@ async def delete( # pylint: disable=inconsistent-return-statements subscription_name=subscription_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -283,10 +347,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -297,45 +360,36 @@ async def delete( # pylint: disable=inconsistent-return-statements 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, - namespace_name: str, - topic_name: str, - subscription_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :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) + :return: SBSubscription or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBSubscription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBSubscription] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBSubscription] - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -343,7 +397,7 @@ async def get( subscription_name=subscription_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -351,10 +405,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -362,12 +415,11 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBSubscription', pipeline_response) + 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 - + 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/v2022_01_01_preview/aio/operations/_topics_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_topics_operations.py index 02c0592da674..3bdd9e63ea03 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_topics_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/aio/operations/_topics_operations.py @@ -6,10 +6,17 @@ # 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, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +27,23 @@ 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') +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]] + class TopicsOperations: """ .. warning:: @@ -43,50 +63,43 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, topic_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SBAuthorizationRule"]: """Gets authorization rules for a topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :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) + :return: An iterator like instance of either SBAuthorizationRule or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.SBAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.SBAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) @@ -94,17 +107,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -120,10 +127,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -134,13 +139,11 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 + @overload async def create_or_update_authorization_rule( self, resource_group_name: str, @@ -148,38 +151,112 @@ async def create_or_update_authorization_rule( topic_name: str, authorization_rule_name: str, parameters: _models.SBAuthorizationRule, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBAuthorizationRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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.v2022_01_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace_async + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: Union[_models.SBAuthorizationRule, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBAuthorizationRule or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2022_01_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - _json = self._serialize.body(parameters, 'SBAuthorizationRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBAuthorizationRule") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -190,7 +267,8 @@ async def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -198,10 +276,9 @@ async def create_or_update_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -209,15 +286,14 @@ async def create_or_update_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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( @@ -230,31 +306,28 @@ async def get_authorization_rule( ) -> _models.SBAuthorizationRule: """Returns the specified authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -262,7 +335,7 @@ async def get_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -270,10 +343,9 @@ async def get_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -281,15 +353,14 @@ async def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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 @@ -302,31 +373,28 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat ) -> None: """Deletes a topic authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -334,7 +402,7 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_authorization_rule.metadata['url'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -342,10 +410,9 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -356,8 +423,7 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat 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( @@ -370,31 +436,28 @@ async def list_keys( ) -> _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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -402,7 +465,7 @@ async def list_keys( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -410,10 +473,9 @@ async def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -421,17 +483,16 @@ async def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 - + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore - @distributed_trace_async + @overload async def regenerate_keys( self, resource_group_name: str, @@ -439,39 +500,114 @@ async def regenerate_keys( topic_name: str, authorization_rule_name: str, parameters: _models.RegenerateAccessKeyParameters, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.RegenerateAccessKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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.v2022_01_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2022_01_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateAccessKeyParameters, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: + ~azure.mgmt.servicebus.v2022_01_01_preview.models.RegenerateAccessKeyParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateAccessKeyParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -482,7 +618,8 @@ async def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) @@ -490,10 +627,9 @@ async def regenerate_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -501,15 +637,14 @@ async def regenerate_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 - + 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( @@ -519,12 +654,12 @@ def list_by_namespace( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable[_models.SBTopicListResult]: + ) -> AsyncIterable["_models.SBTopic"]: """Gets all the topics in a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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 @@ -534,32 +669,31 @@ def list_by_namespace( 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) + :return: An iterator like instance of either SBTopic or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.SBTopicListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.SBTopic] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBTopicListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + api_version=api_version, + template_url=self.list_by_namespace.metadata["url"], headers=_headers, params=_params, ) @@ -567,18 +701,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -594,10 +721,8 @@ 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -608,49 +733,115 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 + @overload async def create_or_update( self, resource_group_name: str, namespace_name: str, topic_name: str, parameters: _models.SBTopic, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBTopic: """Creates a topic in the specified namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param parameters: Parameters supplied to create a topic resource. + :param parameters: Parameters supplied to create a topic resource. Required. :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBTopic + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBTopic, or the result of cls(response) + :return: SBTopic or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBTopic - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBTopic: + """Creates a topic in the specified namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param parameters: Parameters supplied to create a topic resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2022_01_01_preview.models.SBTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + parameters: Union[_models.SBTopic, IO], + **kwargs: Any + ) -> _models.SBTopic: + """Creates a topic in the specified namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param parameters: Parameters supplied to create a topic resource. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBTopic or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2022_01_01_preview.models.SBTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBTopic] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBTopic] - _json = self._serialize.body(parameters, 'SBTopic') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBTopic") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -660,7 +851,8 @@ async def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -668,10 +860,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -679,56 +870,48 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBTopic', pipeline_response) + 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 - + 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, - topic_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -736,10 +919,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -750,49 +932,41 @@ async def delete( # pylint: disable=inconsistent-return-statements 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, - namespace_name: str, - topic_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :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) + :return: SBTopic or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBTopic - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBTopic] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBTopic] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -800,10 +974,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -811,12 +984,11 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBTopic', pipeline_response) + 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 - + 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/v2022_01_01_preview/models/__init__.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/models/__init__.py index 21d9474c1ea6..4ff8d9282a40 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/models/__init__.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/models/__init__.py @@ -63,109 +63,107 @@ from ._models_py3 import UserAssignedIdentity from ._models_py3 import UserAssignedIdentityProperties - -from ._service_bus_management_client_enums import ( - AccessRights, - CreatedByType, - DefaultAction, - EndPointProvisioningState, - EntityStatus, - FilterType, - KeySource, - KeyType, - ManagedServiceIdentityType, - MigrationConfigurationName, - NetworkRuleIPAction, - PrivateLinkConnectionStatus, - ProvisioningStateDR, - PublicNetworkAccess, - PublicNetworkAccessFlag, - RoleDisasterRecovery, - SkuName, - SkuTier, - TlsVersion, - UnavailableReason, -) +from ._service_bus_management_client_enums import AccessRights +from ._service_bus_management_client_enums import CreatedByType +from ._service_bus_management_client_enums import DefaultAction +from ._service_bus_management_client_enums import EndPointProvisioningState +from ._service_bus_management_client_enums import EntityStatus +from ._service_bus_management_client_enums import FilterType +from ._service_bus_management_client_enums import KeySource +from ._service_bus_management_client_enums import KeyType +from ._service_bus_management_client_enums import ManagedServiceIdentityType +from ._service_bus_management_client_enums import MigrationConfigurationName +from ._service_bus_management_client_enums import NetworkRuleIPAction +from ._service_bus_management_client_enums import PrivateLinkConnectionStatus +from ._service_bus_management_client_enums import ProvisioningStateDR +from ._service_bus_management_client_enums import PublicNetworkAccess +from ._service_bus_management_client_enums import PublicNetworkAccessFlag +from ._service_bus_management_client_enums import RoleDisasterRecovery +from ._service_bus_management_client_enums import SkuName +from ._service_bus_management_client_enums import SkuTier +from ._service_bus_management_client_enums import TlsVersion +from ._service_bus_management_client_enums import UnavailableReason from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'AccessKeys', - 'Action', - 'ArmDisasterRecovery', - 'ArmDisasterRecoveryListResult', - 'CheckNameAvailability', - 'CheckNameAvailabilityResult', - 'ConnectionState', - 'CorrelationFilter', - 'Encryption', - 'ErrorAdditionalInfo', - 'ErrorResponse', - 'ErrorResponseError', - 'FailoverProperties', - 'Identity', - 'KeyVaultProperties', - 'MessageCountDetails', - 'MigrationConfigListResult', - 'MigrationConfigProperties', - 'NWRuleSetIpRules', - 'NWRuleSetVirtualNetworkRules', - 'NetworkRuleSet', - 'NetworkRuleSetListResult', - 'Operation', - 'OperationDisplay', - 'OperationListResult', - 'PrivateEndpoint', - 'PrivateEndpointConnection', - 'PrivateEndpointConnectionListResult', - 'PrivateLinkResource', - 'PrivateLinkResourcesListResult', - 'ProxyResource', - 'RegenerateAccessKeyParameters', - 'Resource', - 'ResourceNamespacePatch', - 'Rule', - 'RuleListResult', - 'SBAuthorizationRule', - 'SBAuthorizationRuleListResult', - 'SBClientAffineProperties', - 'SBNamespace', - 'SBNamespaceListResult', - 'SBNamespaceUpdateParameters', - 'SBQueue', - 'SBQueueListResult', - 'SBSku', - 'SBSubscription', - 'SBSubscriptionListResult', - 'SBTopic', - 'SBTopicListResult', - 'SqlFilter', - 'SqlRuleAction', - 'Subnet', - 'SystemData', - 'TrackedResource', - 'UserAssignedIdentity', - 'UserAssignedIdentityProperties', - 'AccessRights', - 'CreatedByType', - 'DefaultAction', - 'EndPointProvisioningState', - 'EntityStatus', - 'FilterType', - 'KeySource', - 'KeyType', - 'ManagedServiceIdentityType', - 'MigrationConfigurationName', - 'NetworkRuleIPAction', - 'PrivateLinkConnectionStatus', - 'ProvisioningStateDR', - 'PublicNetworkAccess', - 'PublicNetworkAccessFlag', - 'RoleDisasterRecovery', - 'SkuName', - 'SkuTier', - 'TlsVersion', - 'UnavailableReason', + "AccessKeys", + "Action", + "ArmDisasterRecovery", + "ArmDisasterRecoveryListResult", + "CheckNameAvailability", + "CheckNameAvailabilityResult", + "ConnectionState", + "CorrelationFilter", + "Encryption", + "ErrorAdditionalInfo", + "ErrorResponse", + "ErrorResponseError", + "FailoverProperties", + "Identity", + "KeyVaultProperties", + "MessageCountDetails", + "MigrationConfigListResult", + "MigrationConfigProperties", + "NWRuleSetIpRules", + "NWRuleSetVirtualNetworkRules", + "NetworkRuleSet", + "NetworkRuleSetListResult", + "Operation", + "OperationDisplay", + "OperationListResult", + "PrivateEndpoint", + "PrivateEndpointConnection", + "PrivateEndpointConnectionListResult", + "PrivateLinkResource", + "PrivateLinkResourcesListResult", + "ProxyResource", + "RegenerateAccessKeyParameters", + "Resource", + "ResourceNamespacePatch", + "Rule", + "RuleListResult", + "SBAuthorizationRule", + "SBAuthorizationRuleListResult", + "SBClientAffineProperties", + "SBNamespace", + "SBNamespaceListResult", + "SBNamespaceUpdateParameters", + "SBQueue", + "SBQueueListResult", + "SBSku", + "SBSubscription", + "SBSubscriptionListResult", + "SBTopic", + "SBTopicListResult", + "SqlFilter", + "SqlRuleAction", + "Subnet", + "SystemData", + "TrackedResource", + "UserAssignedIdentity", + "UserAssignedIdentityProperties", + "AccessRights", + "CreatedByType", + "DefaultAction", + "EndPointProvisioningState", + "EntityStatus", + "FilterType", + "KeySource", + "KeyType", + "ManagedServiceIdentityType", + "MigrationConfigurationName", + "NetworkRuleIPAction", + "PrivateLinkConnectionStatus", + "ProvisioningStateDR", + "PublicNetworkAccess", + "PublicNetworkAccessFlag", + "RoleDisasterRecovery", + "SkuName", + "SkuTier", + "TlsVersion", + "UnavailableReason", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/models/_models_py3.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/models/_models_py3.py index eee47e184d16..eb02540af20f 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/models/_models_py3.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -7,17 +8,22 @@ # -------------------------------------------------------------------------- import datetime +import sys from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - import __init__ as _models + from .. import models as _models +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class AccessKeys(msrest.serialization.Model): +class AccessKeys(_serialization.Model): """Namespace/ServiceBus Connection String. Variables are only populated by the server, and will be ignored when sending a request. @@ -45,32 +51,28 @@ class AccessKeys(msrest.serialization.Model): """ _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}, + "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) + "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().__init__(**kwargs) self.primary_connection_string = None self.secondary_connection_string = None self.alias_primary_connection_string = None @@ -80,7 +82,7 @@ def __init__( self.key_name = None -class Action(msrest.serialization.Model): +class Action(_serialization.Model): """Represents the filter actions which are allowed for the transformation of a message that have been matched by a filter expression. :ivar sql_expression: SQL expression. e.g. MyProperty='ABC'. @@ -94,9 +96,9 @@ class Action(msrest.serialization.Model): """ _attribute_map = { - 'sql_expression': {'key': 'sqlExpression', 'type': 'str'}, - 'compatibility_level': {'key': 'compatibilityLevel', 'type': 'int'}, - 'requires_preprocessing': {'key': 'requiresPreprocessing', 'type': 'bool'}, + "sql_expression": {"key": "sqlExpression", "type": "str"}, + "compatibility_level": {"key": "compatibilityLevel", "type": "int"}, + "requires_preprocessing": {"key": "requiresPreprocessing", "type": "bool"}, } def __init__( @@ -104,7 +106,7 @@ def __init__( *, sql_expression: Optional[str] = None, compatibility_level: Optional[int] = None, - requires_preprocessing: Optional[bool] = True, + requires_preprocessing: bool = True, **kwargs ): """ @@ -117,13 +119,13 @@ def __init__( preprocessing. :paramtype requires_preprocessing: bool """ - super(Action, self).__init__(**kwargs) + super().__init__(**kwargs) self.sql_expression = sql_expression self.compatibility_level = compatibility_level self.requires_preprocessing = requires_preprocessing -class ProxyResource(msrest.serialization.Model): +class ProxyResource(_serialization.Model): """Common fields that are returned in the response for all Azure Resource Manager resources. Variables are only populated by the server, and will be ignored when sending a request. @@ -141,26 +143,22 @@ class ProxyResource(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ProxyResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -186,11 +184,11 @@ class ArmDisasterRecovery(ProxyResource): :vartype system_data: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SystemData :ivar provisioning_state: Provisioning state of the Alias(Disaster Recovery configuration) - possible values 'Accepted' or 'Succeeded' or 'Failed'. Known values are: "Accepted", - "Succeeded", "Failed". + "Succeeded", and "Failed". :vartype provisioning_state: str or ~azure.mgmt.servicebus.v2022_01_01_preview.models.ProvisioningStateDR :ivar pending_replication_operations_count: Number of entities pending to be replicated. - :vartype pending_replication_operations_count: long + :vartype pending_replication_operations_count: int :ivar partner_namespace: ARM Id of the Primary/Secondary eventhub namespace name, which is part of GEO DR pairing. :vartype partner_namespace: str @@ -198,41 +196,35 @@ class ArmDisasterRecovery(ProxyResource): pairing. :vartype alternate_name: str :ivar role: role of namespace in GEO DR - possible values 'Primary' or 'PrimaryNotReplicating' - or 'Secondary'. Known values are: "Primary", "PrimaryNotReplicating", "Secondary". + or 'Secondary'. Known values are: "Primary", "PrimaryNotReplicating", and "Secondary". :vartype role: str or ~azure.mgmt.servicebus.v2022_01_01_preview.models.RoleDisasterRecovery """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'pending_replication_operations_count': {'readonly': True}, - 'role': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"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'}, - 'location': {'key': 'location', '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'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "pending_replication_operations_count": {"key": "properties.pendingReplicationOperationsCount", "type": "int"}, + "partner_namespace": {"key": "properties.partnerNamespace", "type": "str"}, + "alternate_name": {"key": "properties.alternateName", "type": "str"}, + "role": {"key": "properties.role", "type": "str"}, } - def __init__( - self, - *, - partner_namespace: Optional[str] = None, - alternate_name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, partner_namespace: Optional[str] = None, 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. @@ -241,7 +233,7 @@ def __init__( pairing. :paramtype alternate_name: str """ - super(ArmDisasterRecovery, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.provisioning_state = None self.pending_replication_operations_count = None @@ -250,7 +242,7 @@ def __init__( self.role = None -class ArmDisasterRecoveryListResult(msrest.serialization.Model): +class ArmDisasterRecoveryListResult(_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. @@ -263,65 +255,55 @@ class ArmDisasterRecoveryListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ArmDisasterRecovery]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ArmDisasterRecovery]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.ArmDisasterRecovery"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.ArmDisasterRecovery"]] = None, **kwargs): """ :keyword value: List of Alias(Disaster Recovery configurations). :paramtype value: list[~azure.mgmt.servicebus.v2022_01_01_preview.models.ArmDisasterRecovery] """ - super(ArmDisasterRecoveryListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class CheckNameAvailability(msrest.serialization.Model): +class CheckNameAvailability(_serialization.Model): """Description of a Check Name availability request properties. All required parameters must be populated in order to send to Azure. - :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. + :ivar name: 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. Required. :vartype name: str """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - name: str, - **kwargs - ): + def __init__(self, *, 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. + :keyword name: 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. Required. :paramtype name: str """ - super(CheckNameAvailability, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class CheckNameAvailabilityResult(msrest.serialization.Model): +class CheckNameAvailabilityResult(_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. @@ -332,19 +314,19 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): available; otherwise, false. :vartype name_available: bool :ivar reason: The reason for unavailability of a namespace. Known values are: "None", - "InvalidName", "SubscriptionIsDisabled", "NameInUse", "NameInLockdown", + "InvalidName", "SubscriptionIsDisabled", "NameInUse", "NameInLockdown", and "TooManyNamespaceInCurrentSubscription". :vartype reason: str or ~azure.mgmt.servicebus.v2022_01_01_preview.models.UnavailableReason """ _validation = { - 'message': {'readonly': True}, + "message": {"readonly": True}, } _attribute_map = { - 'message': {'key': 'message', 'type': 'str'}, - 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, - 'reason': {'key': 'reason', 'type': 'str'}, + "message": {"key": "message", "type": "str"}, + "name_available": {"key": "nameAvailable", "type": "bool"}, + "reason": {"key": "reason", "type": "str"}, } def __init__( @@ -359,21 +341,21 @@ def __init__( available; otherwise, false. :paramtype name_available: bool :keyword reason: The reason for unavailability of a namespace. Known values are: "None", - "InvalidName", "SubscriptionIsDisabled", "NameInUse", "NameInLockdown", + "InvalidName", "SubscriptionIsDisabled", "NameInUse", "NameInLockdown", and "TooManyNamespaceInCurrentSubscription". :paramtype reason: str or ~azure.mgmt.servicebus.v2022_01_01_preview.models.UnavailableReason """ - super(CheckNameAvailabilityResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.message = None self.name_available = name_available self.reason = reason -class ConnectionState(msrest.serialization.Model): +class ConnectionState(_serialization.Model): """ConnectionState information. :ivar status: Status of the connection. Known values are: "Pending", "Approved", "Rejected", - "Disconnected". + and "Disconnected". :vartype status: str or ~azure.mgmt.servicebus.v2022_01_01_preview.models.PrivateLinkConnectionStatus :ivar description: Description of the connection state. @@ -381,8 +363,8 @@ class ConnectionState(msrest.serialization.Model): """ _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "status": {"key": "status", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -394,18 +376,18 @@ def __init__( ): """ :keyword status: Status of the connection. Known values are: "Pending", "Approved", "Rejected", - "Disconnected". + and "Disconnected". :paramtype status: str or ~azure.mgmt.servicebus.v2022_01_01_preview.models.PrivateLinkConnectionStatus :keyword description: Description of the connection state. :paramtype description: str """ - super(ConnectionState, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status self.description = description -class CorrelationFilter(msrest.serialization.Model): +class CorrelationFilter(_serialization.Model): """Represents the correlation filter expression. :ivar properties: dictionary object for custom filters. @@ -432,16 +414,16 @@ class CorrelationFilter(msrest.serialization.Model): """ _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'}, + "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__( @@ -456,7 +438,7 @@ def __init__( session_id: Optional[str] = None, reply_to_session_id: Optional[str] = None, content_type: Optional[str] = None, - requires_preprocessing: Optional[bool] = True, + requires_preprocessing: bool = True, **kwargs ): """ @@ -482,7 +464,7 @@ def __init__( preprocessing. :paramtype requires_preprocessing: bool """ - super(CorrelationFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.correlation_id = correlation_id self.message_id = message_id @@ -495,30 +477,30 @@ def __init__( self.requires_preprocessing = requires_preprocessing -class Encryption(msrest.serialization.Model): +class Encryption(_serialization.Model): """Properties to configure Encryption. :ivar key_vault_properties: Properties of KeyVault. :vartype key_vault_properties: list[~azure.mgmt.servicebus.v2022_01_01_preview.models.KeyVaultProperties] - :ivar key_source: Enumerates the possible value of keySource for Encryption. Known values are: - "Microsoft.KeyVault". Default value: "Microsoft.KeyVault". + :ivar key_source: Enumerates the possible value of keySource for Encryption. + "Microsoft.KeyVault" :vartype key_source: str or ~azure.mgmt.servicebus.v2022_01_01_preview.models.KeySource :ivar require_infrastructure_encryption: Enable Infrastructure Encryption (Double Encryption). :vartype 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'}, + "key_vault_properties": {"key": "keyVaultProperties", "type": "[KeyVaultProperties]"}, + "key_source": {"key": "keySource", "type": "str"}, + "require_infrastructure_encryption": {"key": "requireInfrastructureEncryption", "type": "bool"}, } def __init__( self, *, key_vault_properties: Optional[List["_models.KeyVaultProperties"]] = None, - key_source: Optional[Union[str, "_models.KeySource"]] = "Microsoft.KeyVault", + key_source: Union[str, "_models.KeySource"] = "Microsoft.KeyVault", require_infrastructure_encryption: Optional[bool] = None, **kwargs ): @@ -526,20 +508,20 @@ def __init__( :keyword key_vault_properties: Properties of KeyVault. :paramtype key_vault_properties: list[~azure.mgmt.servicebus.v2022_01_01_preview.models.KeyVaultProperties] - :keyword key_source: Enumerates the possible value of keySource for Encryption. Known values - are: "Microsoft.KeyVault". Default value: "Microsoft.KeyVault". + :keyword key_source: Enumerates the possible value of keySource for Encryption. + "Microsoft.KeyVault" :paramtype key_source: str or ~azure.mgmt.servicebus.v2022_01_01_preview.models.KeySource :keyword require_infrastructure_encryption: Enable Infrastructure Encryption (Double Encryption). :paramtype require_infrastructure_encryption: bool """ - super(Encryption, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_vault_properties = key_vault_properties self.key_source = key_source self.require_infrastructure_encryption = require_infrastructure_encryption -class ErrorAdditionalInfo(msrest.serialization.Model): +class ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. Variables are only populated by the server, and will be ignored when sending a request. @@ -547,31 +529,27 @@ class ErrorAdditionalInfo(msrest.serialization.Model): :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. - :vartype info: any + :vartype info: JSON """ _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, + "type": {"readonly": True}, + "info": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorAdditionalInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.info = None -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """The resource management error response. :ivar error: The error object. @@ -579,24 +557,19 @@ class ErrorResponse(msrest.serialization.Model): """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponseError'}, + "error": {"key": "error", "type": "ErrorResponseError"}, } - def __init__( - self, - *, - error: Optional["_models.ErrorResponseError"] = None, - **kwargs - ): + def __init__(self, *, error: Optional["_models.ErrorResponseError"] = None, **kwargs): """ :keyword error: The error object. :paramtype error: ~azure.mgmt.servicebus.v2022_01_01_preview.models.ErrorResponseError """ - super(ErrorResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error -class ErrorResponseError(msrest.serialization.Model): +class ErrorResponseError(_serialization.Model): """The error object. Variables are only populated by the server, and will be ignored when sending a request. @@ -615,28 +588,24 @@ class ErrorResponseError(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, + "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]'}, + "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) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.message = None self.target = None @@ -644,7 +613,7 @@ def __init__( self.additional_info = None -class FailoverProperties(msrest.serialization.Model): +class FailoverProperties(_serialization.Model): """Safe failover is to indicate the service should wait for pending replication to finish before switching to the secondary. :ivar is_safe_failover: Safe failover is to indicate the service should wait for pending @@ -653,25 +622,20 @@ class FailoverProperties(msrest.serialization.Model): """ _attribute_map = { - 'is_safe_failover': {'key': 'properties.IsSafeFailover', 'type': 'bool'}, + "is_safe_failover": {"key": "properties.IsSafeFailover", "type": "bool"}, } - def __init__( - self, - *, - is_safe_failover: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, 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) + super().__init__(**kwargs) self.is_safe_failover = is_safe_failover -class Identity(msrest.serialization.Model): +class Identity(_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. @@ -681,7 +645,7 @@ class Identity(msrest.serialization.Model): :ivar tenant_id: TenantId from the KeyVault. :vartype tenant_id: str :ivar type: Type of managed service identity. Known values are: "SystemAssigned", - "UserAssigned", "SystemAssigned, UserAssigned", "None". + "UserAssigned", "SystemAssigned, UserAssigned", and "None". :vartype type: str or ~azure.mgmt.servicebus.v2022_01_01_preview.models.ManagedServiceIdentityType :ivar user_assigned_identities: Properties for User Assigned Identities. @@ -690,15 +654,15 @@ class Identity(msrest.serialization.Model): """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, + "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}'}, + "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__( @@ -710,21 +674,21 @@ def __init__( ): """ :keyword type: Type of managed service identity. Known values are: "SystemAssigned", - "UserAssigned", "SystemAssigned, UserAssigned", "None". + "UserAssigned", "SystemAssigned, UserAssigned", and "None". :paramtype type: str or ~azure.mgmt.servicebus.v2022_01_01_preview.models.ManagedServiceIdentityType :keyword user_assigned_identities: Properties for User Assigned Identities. :paramtype user_assigned_identities: dict[str, ~azure.mgmt.servicebus.v2022_01_01_preview.models.UserAssignedIdentity] """ - super(Identity, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = None self.tenant_id = None self.type = type self.user_assigned_identities = user_assigned_identities -class KeyVaultProperties(msrest.serialization.Model): +class KeyVaultProperties(_serialization.Model): """Properties to configure keyVault Properties. :ivar key_name: Name of the Key from KeyVault. @@ -739,10 +703,10 @@ class KeyVaultProperties(msrest.serialization.Model): """ _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'}, + "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__( @@ -765,54 +729,50 @@ def __init__( :paramtype identity: ~azure.mgmt.servicebus.v2022_01_01_preview.models.UserAssignedIdentityProperties """ - super(KeyVaultProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_name = key_name self.key_vault_uri = key_vault_uri self.key_version = key_version self.identity = identity -class MessageCountDetails(msrest.serialization.Model): +class MessageCountDetails(_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 + :vartype active_message_count: int :ivar dead_letter_message_count: Number of messages that are dead lettered. - :vartype dead_letter_message_count: long + :vartype dead_letter_message_count: int :ivar scheduled_message_count: Number of scheduled messages. - :vartype scheduled_message_count: long + :vartype scheduled_message_count: int :ivar transfer_message_count: Number of messages transferred to another queue, topic, or subscription. - :vartype transfer_message_count: long + :vartype transfer_message_count: int :ivar transfer_dead_letter_message_count: Number of messages transferred into dead letters. - :vartype transfer_dead_letter_message_count: long + :vartype transfer_dead_letter_message_count: int """ _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}, + "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'}, + "active_message_count": {"key": "activeMessageCount", "type": "int"}, + "dead_letter_message_count": {"key": "deadLetterMessageCount", "type": "int"}, + "scheduled_message_count": {"key": "scheduledMessageCount", "type": "int"}, + "transfer_message_count": {"key": "transferMessageCount", "type": "int"}, + "transfer_dead_letter_message_count": {"key": "transferDeadLetterMessageCount", "type": "int"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(MessageCountDetails, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.active_message_count = None self.dead_letter_message_count = None self.scheduled_message_count = None @@ -820,7 +780,7 @@ def __init__( self.transfer_dead_letter_message_count = None -class MigrationConfigListResult(msrest.serialization.Model): +class MigrationConfigListResult(_serialization.Model): """The result of the List migrationConfigurations operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -834,26 +794,21 @@ class MigrationConfigListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[MigrationConfigProperties]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[MigrationConfigProperties]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.MigrationConfigProperties"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.MigrationConfigProperties"]] = None, **kwargs): """ :keyword value: List of Migration Configs. :paramtype value: list[~azure.mgmt.servicebus.v2022_01_01_preview.models.MigrationConfigProperties] """ - super(MigrationConfigListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None @@ -878,7 +833,7 @@ class MigrationConfigProperties(ProxyResource): :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 + :vartype pending_replication_operations_count: int :ivar target_namespace: Existing premium Namespace ARM Id name which has no entities, will be used for migration. :vartype target_namespace: str @@ -890,36 +845,30 @@ class MigrationConfigProperties(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'pending_replication_operations_count': {'readonly': True}, - 'migration_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"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'}, - 'location': {'key': 'location', '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'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "pending_replication_operations_count": {"key": "properties.pendingReplicationOperationsCount", "type": "int"}, + "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, - *, - target_namespace: Optional[str] = None, - post_migration_name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, target_namespace: Optional[str] = None, 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. @@ -927,7 +876,7 @@ def __init__( :keyword post_migration_name: Name to access Standard Namespace after migration. :paramtype post_migration_name: str """ - super(MigrationConfigProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.provisioning_state = None self.pending_replication_operations_count = None @@ -956,7 +905,8 @@ class NetworkRuleSet(ProxyResource): :ivar trusted_service_access_enabled: Value that indicates whether Trusted Service Access is Enabled or not. :vartype trusted_service_access_enabled: bool - :ivar default_action: Default Action for Network Rule Set. Known values are: "Allow", "Deny". + :ivar default_action: Default Action for Network Rule Set. Known values are: "Allow" and + "Deny". :vartype default_action: str or ~azure.mgmt.servicebus.v2022_01_01_preview.models.DefaultAction :ivar virtual_network_rules: List VirtualNetwork Rules. :vartype virtual_network_rules: @@ -964,30 +914,30 @@ class NetworkRuleSet(ProxyResource): :ivar ip_rules: List of IpRules. :vartype ip_rules: list[~azure.mgmt.servicebus.v2022_01_01_preview.models.NWRuleSetIpRules] :ivar public_network_access: This determines if traffic is allowed over public network. By - default it is enabled. Known values are: "Enabled", "Disabled". Default value: "Enabled". + default it is enabled. Known values are: "Enabled" and "Disabled". :vartype public_network_access: str or ~azure.mgmt.servicebus.v2022_01_01_preview.models.PublicNetworkAccessFlag """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'readonly': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"readonly": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', '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'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "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__( @@ -997,14 +947,14 @@ def __init__( default_action: Optional[Union[str, "_models.DefaultAction"]] = None, virtual_network_rules: Optional[List["_models.NWRuleSetVirtualNetworkRules"]] = None, ip_rules: Optional[List["_models.NWRuleSetIpRules"]] = None, - public_network_access: Optional[Union[str, "_models.PublicNetworkAccessFlag"]] = "Enabled", + public_network_access: Union[str, "_models.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. Known values are: "Allow", + :keyword default_action: Default Action for Network Rule Set. Known values are: "Allow" and "Deny". :paramtype default_action: str or ~azure.mgmt.servicebus.v2022_01_01_preview.models.DefaultAction @@ -1014,11 +964,11 @@ def __init__( :keyword ip_rules: List of IpRules. :paramtype ip_rules: list[~azure.mgmt.servicebus.v2022_01_01_preview.models.NWRuleSetIpRules] :keyword public_network_access: This determines if traffic is allowed over public network. By - default it is enabled. Known values are: "Enabled", "Disabled". Default value: "Enabled". + default it is enabled. Known values are: "Enabled" and "Disabled". :paramtype public_network_access: str or ~azure.mgmt.servicebus.v2022_01_01_preview.models.PublicNetworkAccessFlag """ - super(NetworkRuleSet, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.trusted_service_access_enabled = trusted_service_access_enabled self.default_action = default_action @@ -1027,7 +977,7 @@ def __init__( self.public_network_access = public_network_access -class NetworkRuleSetListResult(msrest.serialization.Model): +class NetworkRuleSetListResult(_serialization.Model): """The response of the List NetworkRuleSet operation. :ivar value: Result of the List NetworkRuleSet operation. @@ -1038,16 +988,12 @@ class NetworkRuleSetListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[NetworkRuleSet]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[NetworkRuleSet]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.NetworkRuleSet"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.NetworkRuleSet"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Result of the List NetworkRuleSet operation. @@ -1056,44 +1002,40 @@ def __init__( list of NetworkRuleSet. :paramtype next_link: str """ - super(NetworkRuleSetListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class NWRuleSetIpRules(msrest.serialization.Model): +class NWRuleSetIpRules(_serialization.Model): """Description of NetWorkRuleSet - IpRules resource. :ivar ip_mask: IP Mask. :vartype ip_mask: str - :ivar action: The IP Filter Action. Known values are: "Allow". Default value: "Allow". + :ivar action: The IP Filter Action. "Allow" :vartype action: str or ~azure.mgmt.servicebus.v2022_01_01_preview.models.NetworkRuleIPAction """ _attribute_map = { - 'ip_mask': {'key': 'ipMask', 'type': 'str'}, - 'action': {'key': 'action', 'type': 'str'}, + "ip_mask": {"key": "ipMask", "type": "str"}, + "action": {"key": "action", "type": "str"}, } def __init__( - self, - *, - ip_mask: Optional[str] = None, - action: Optional[Union[str, "_models.NetworkRuleIPAction"]] = "Allow", - **kwargs + self, *, ip_mask: Optional[str] = None, action: Union[str, "_models.NetworkRuleIPAction"] = "Allow", **kwargs ): """ :keyword ip_mask: IP Mask. :paramtype ip_mask: str - :keyword action: The IP Filter Action. Known values are: "Allow". Default value: "Allow". + :keyword action: The IP Filter Action. "Allow" :paramtype action: str or ~azure.mgmt.servicebus.v2022_01_01_preview.models.NetworkRuleIPAction """ - super(NWRuleSetIpRules, self).__init__(**kwargs) + super().__init__(**kwargs) self.ip_mask = ip_mask self.action = action -class NWRuleSetVirtualNetworkRules(msrest.serialization.Model): +class NWRuleSetVirtualNetworkRules(_serialization.Model): """Description of VirtualNetworkRules - NetworkRules resource. :ivar subnet: Subnet properties. @@ -1104,8 +1046,8 @@ class NWRuleSetVirtualNetworkRules(msrest.serialization.Model): """ _attribute_map = { - 'subnet': {'key': 'subnet', 'type': 'Subnet'}, - 'ignore_missing_vnet_service_endpoint': {'key': 'ignoreMissingVnetServiceEndpoint', 'type': 'bool'}, + "subnet": {"key": "subnet", "type": "Subnet"}, + "ignore_missing_vnet_service_endpoint": {"key": "ignoreMissingVnetServiceEndpoint", "type": "bool"}, } def __init__( @@ -1122,12 +1064,12 @@ def __init__( VNet Service Endpoint. :paramtype ignore_missing_vnet_service_endpoint: bool """ - super(NWRuleSetVirtualNetworkRules, self).__init__(**kwargs) + super().__init__(**kwargs) self.subnet = subnet self.ignore_missing_vnet_service_endpoint = ignore_missing_vnet_service_endpoint -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """A Service Bus REST API operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -1141,19 +1083,19 @@ class Operation(msrest.serialization.Model): :ivar origin: Origin of the operation. :vartype origin: str :ivar properties: Properties of the operation. - :vartype properties: any + :vartype properties: JSON """ _validation = { - 'name': {'readonly': True}, + "name": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - 'origin': {'key': 'origin', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'object'}, + "name": {"key": "name", "type": "str"}, + "is_data_action": {"key": "isDataAction", "type": "bool"}, + "display": {"key": "display", "type": "OperationDisplay"}, + "origin": {"key": "origin", "type": "str"}, + "properties": {"key": "properties", "type": "object"}, } def __init__( @@ -1162,7 +1104,7 @@ def __init__( is_data_action: Optional[bool] = None, display: Optional["_models.OperationDisplay"] = None, origin: Optional[str] = None, - properties: Optional[Any] = None, + properties: Optional[JSON] = None, **kwargs ): """ @@ -1173,9 +1115,9 @@ def __init__( :keyword origin: Origin of the operation. :paramtype origin: str :keyword properties: Properties of the operation. - :paramtype properties: any + :paramtype properties: JSON """ - super(Operation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = None self.is_data_action = is_data_action self.display = display @@ -1183,7 +1125,7 @@ def __init__( self.properties = properties -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """Operation display payload. Variables are only populated by the server, and will be ignored when sending a request. @@ -1199,33 +1141,29 @@ class OperationDisplay(msrest.serialization.Model): """ _validation = { - 'provider': {'readonly': True}, - 'resource': {'readonly': True}, - 'operation': {'readonly': True}, - 'description': {'readonly': True}, + "provider": {"readonly": True}, + "resource": {"readonly": True}, + "operation": {"readonly": True}, + "description": {"readonly": True}, } _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(OperationDisplay, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.provider = None self.resource = None self.operation = None self.description = None -class OperationListResult(msrest.serialization.Model): +class OperationListResult(_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. @@ -1238,27 +1176,23 @@ class OperationListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(OperationListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class PrivateEndpoint(msrest.serialization.Model): +class PrivateEndpoint(_serialization.Model): """PrivateEndpoint information. :ivar id: The ARM identifier for Private Endpoint. @@ -1266,20 +1200,15 @@ class PrivateEndpoint(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, id: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin """ :keyword id: The ARM identifier for Private Endpoint. :paramtype id: str """ - super(PrivateEndpoint, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id @@ -1306,28 +1235,31 @@ class PrivateEndpointConnection(ProxyResource): :vartype private_link_service_connection_state: ~azure.mgmt.servicebus.v2022_01_01_preview.models.ConnectionState :ivar provisioning_state: Provisioning state of the Private Endpoint Connection. Known values - are: "Creating", "Updating", "Deleting", "Succeeded", "Canceled", "Failed". + are: "Creating", "Updating", "Deleting", "Succeeded", "Canceled", and "Failed". :vartype provisioning_state: str or ~azure.mgmt.servicebus.v2022_01_01_preview.models.EndPointProvisioningState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'readonly': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"readonly": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', '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'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "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__( @@ -1345,18 +1277,18 @@ def __init__( :paramtype private_link_service_connection_state: ~azure.mgmt.servicebus.v2022_01_01_preview.models.ConnectionState :keyword provisioning_state: Provisioning state of the Private Endpoint Connection. Known - values are: "Creating", "Updating", "Deleting", "Succeeded", "Canceled", "Failed". + values are: "Creating", "Updating", "Deleting", "Succeeded", "Canceled", and "Failed". :paramtype provisioning_state: str or ~azure.mgmt.servicebus.v2022_01_01_preview.models.EndPointProvisioningState """ - super(PrivateEndpointConnection, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.private_endpoint = private_endpoint self.private_link_service_connection_state = private_link_service_connection_state self.provisioning_state = provisioning_state -class PrivateEndpointConnectionListResult(msrest.serialization.Model): +class PrivateEndpointConnectionListResult(_serialization.Model): """Result of the list of all private endpoint connections operation. :ivar value: A collection of private endpoint connection resources. @@ -1367,8 +1299,8 @@ class PrivateEndpointConnectionListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateEndpointConnection]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PrivateEndpointConnection]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( @@ -1385,12 +1317,12 @@ def __init__( :keyword next_link: A link for the next page of private endpoint connection resources. :paramtype next_link: str """ - super(PrivateEndpointConnectionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class PrivateLinkResource(msrest.serialization.Model): +class PrivateLinkResource(_serialization.Model): """Information of the private link resource. :ivar id: Fully qualified identifier of the resource. @@ -1408,18 +1340,18 @@ class PrivateLinkResource(msrest.serialization.Model): """ _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]'}, + "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, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin name: Optional[str] = None, type: Optional[str] = None, group_id: Optional[str] = None, @@ -1441,7 +1373,7 @@ def __init__( :keyword required_zone_names: Required Zone Names. :paramtype required_zone_names: list[str] """ - super(PrivateLinkResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.name = name self.type = type @@ -1450,7 +1382,7 @@ def __init__( self.required_zone_names = required_zone_names -class PrivateLinkResourcesListResult(msrest.serialization.Model): +class PrivateLinkResourcesListResult(_serialization.Model): """Result of the List private link resources operation. :ivar value: A collection of private link resources. @@ -1460,16 +1392,12 @@ class PrivateLinkResourcesListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateLinkResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PrivateLinkResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.PrivateLinkResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.PrivateLinkResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: A collection of private link resources. @@ -1477,17 +1405,17 @@ def __init__( :keyword next_link: A link for the next page of private link resources. :paramtype next_link: str """ - super(PrivateLinkResourcesListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class RegenerateAccessKeyParameters(msrest.serialization.Model): +class RegenerateAccessKeyParameters(_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. - :ivar key_type: Required. The access key to regenerate. Known values are: "PrimaryKey", + :ivar key_type: The access key to regenerate. Required. Known values are: "PrimaryKey" and "SecondaryKey". :vartype key_type: str or ~azure.mgmt.servicebus.v2022_01_01_preview.models.KeyType :ivar key: Optional, if the key value provided, is reset for KeyType value or autogenerate Key @@ -1496,35 +1424,29 @@ class RegenerateAccessKeyParameters(msrest.serialization.Model): """ _validation = { - 'key_type': {'required': True}, + "key_type": {"required": True}, } _attribute_map = { - 'key_type': {'key': 'keyType', 'type': 'str'}, - 'key': {'key': 'key', 'type': 'str'}, + "key_type": {"key": "keyType", "type": "str"}, + "key": {"key": "key", "type": "str"}, } - def __init__( - self, - *, - key_type: Union[str, "_models.KeyType"], - key: Optional[str] = None, - **kwargs - ): + def __init__(self, *, key_type: Union[str, "_models.KeyType"], key: Optional[str] = None, **kwargs): """ - :keyword key_type: Required. The access key to regenerate. Known values are: "PrimaryKey", + :keyword key_type: The access key to regenerate. Required. Known values are: "PrimaryKey" and "SecondaryKey". :paramtype key_type: str or ~azure.mgmt.servicebus.v2022_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) + super().__init__(**kwargs) self.key_type = key_type self.key = key -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """The Resource definition for other than namespace. Variables are only populated by the server, and will be ignored when sending a request. @@ -1538,24 +1460,20 @@ class Resource(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "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'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Resource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -1574,38 +1492,32 @@ class ResourceNamespacePatch(Resource): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "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}'}, + "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, - *, - location: Optional[str] = None, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs): """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(ResourceNamespacePatch, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.tags = tags @@ -1631,7 +1543,7 @@ class Rule(ProxyResource): message that have been matched by a filter expression. :vartype action: ~azure.mgmt.servicebus.v2022_01_01_preview.models.Action :ivar filter_type: Filter type that is evaluated against a BrokeredMessage. Known values are: - "SqlFilter", "CorrelationFilter". + "SqlFilter" and "CorrelationFilter". :vartype filter_type: str or ~azure.mgmt.servicebus.v2022_01_01_preview.models.FilterType :ivar sql_filter: Properties of sqlFilter. :vartype sql_filter: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SqlFilter @@ -1641,23 +1553,23 @@ class Rule(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'readonly': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"readonly": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', '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'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "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__( @@ -1674,7 +1586,7 @@ def __init__( message that have been matched by a filter expression. :paramtype action: ~azure.mgmt.servicebus.v2022_01_01_preview.models.Action :keyword filter_type: Filter type that is evaluated against a BrokeredMessage. Known values - are: "SqlFilter", "CorrelationFilter". + are: "SqlFilter" and "CorrelationFilter". :paramtype filter_type: str or ~azure.mgmt.servicebus.v2022_01_01_preview.models.FilterType :keyword sql_filter: Properties of sqlFilter. :paramtype sql_filter: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SqlFilter @@ -1682,7 +1594,7 @@ def __init__( :paramtype correlation_filter: ~azure.mgmt.servicebus.v2022_01_01_preview.models.CorrelationFilter """ - super(Rule, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.action = action self.filter_type = filter_type @@ -1690,7 +1602,7 @@ def __init__( self.correlation_filter = correlation_filter -class RuleListResult(msrest.serialization.Model): +class RuleListResult(_serialization.Model): """The response of the List rule operation. :ivar value: Result of the List Rules operation. @@ -1701,17 +1613,11 @@ class RuleListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Rule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Rule]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.Rule"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Rule"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: Result of the List Rules operation. :paramtype value: list[~azure.mgmt.servicebus.v2022_01_01_preview.models.Rule] @@ -1719,7 +1625,7 @@ def __init__( list of rules. :paramtype next_link: str """ - super(RuleListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link @@ -1746,38 +1652,33 @@ class SBAuthorizationRule(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'readonly': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"readonly": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'rights': {'key': 'properties.rights', 'type': '[str]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "rights": {"key": "properties.rights", "type": "[str]"}, } - def __init__( - self, - *, - rights: Optional[List[Union[str, "_models.AccessRights"]]] = None, - **kwargs - ): + def __init__(self, *, rights: Optional[List[Union[str, "_models.AccessRights"]]] = None, **kwargs): """ :keyword rights: The rights associated with the rule. :paramtype rights: list[str or ~azure.mgmt.servicebus.v2022_01_01_preview.models.AccessRights] """ - super(SBAuthorizationRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.rights = rights -class SBAuthorizationRuleListResult(msrest.serialization.Model): +class SBAuthorizationRuleListResult(_serialization.Model): """The response to the List Namespace operation. :ivar value: Result of the List Authorization Rules operation. @@ -1788,16 +1689,12 @@ class SBAuthorizationRuleListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SBAuthorizationRule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SBAuthorizationRule]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.SBAuthorizationRule"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.SBAuthorizationRule"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Result of the List Authorization Rules operation. @@ -1806,12 +1703,12 @@ def __init__( list of Authorization Rules. :paramtype next_link: str """ - super(SBAuthorizationRuleListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SBClientAffineProperties(msrest.serialization.Model): +class SBClientAffineProperties(_serialization.Model): """Properties specific to client affine subscriptions. :ivar client_id: Indicates the Client ID of the application that created the client-affine @@ -1826,9 +1723,9 @@ class SBClientAffineProperties(msrest.serialization.Model): """ _attribute_map = { - 'client_id': {'key': 'clientId', 'type': 'str'}, - 'is_durable': {'key': 'isDurable', 'type': 'bool'}, - 'is_shared': {'key': 'isShared', 'type': 'bool'}, + "client_id": {"key": "clientId", "type": "str"}, + "is_durable": {"key": "isDurable", "type": "bool"}, + "is_shared": {"key": "isShared", "type": "bool"}, } def __init__( @@ -1850,7 +1747,7 @@ def __init__( subscription is shared or not. :paramtype is_shared: bool """ - super(SBClientAffineProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.client_id = client_id self.is_durable = is_durable self.is_shared = is_shared @@ -1869,46 +1766,40 @@ class TrackedResource(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :ivar location: Required. The Geo-location where the resource lives. + :ivar location: The Geo-location where the resource lives. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "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}'}, + "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, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword location: Required. The Geo-location where the resource lives. + :keyword location: The Geo-location where the resource lives. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(TrackedResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.tags = tags -class SBNamespace(TrackedResource): +class SBNamespace(TrackedResource): # pylint: disable=too-many-instance-attributes """Description of a namespace resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -1921,9 +1812,9 @@ class SBNamespace(TrackedResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :ivar location: Required. The Geo-location where the resource lives. + :ivar location: The Geo-location where the resource lives. Required. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar sku: Properties of SKU. :vartype sku: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBSku @@ -1932,7 +1823,7 @@ class SBNamespace(TrackedResource): :ivar system_data: The system meta data relating to this resource. :vartype system_data: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SystemData :ivar minimum_tls_version: The minimum TLS version for the cluster to support, e.g. '1.2'. - Known values are: "1.0", "1.1", "1.2". + Known values are: "1.0", "1.1", and "1.2". :vartype minimum_tls_version: str or ~azure.mgmt.servicebus.v2022_01_01_preview.models.TlsVersion :ivar provisioning_state: Provisioning state of the namespace. @@ -1961,48 +1852,50 @@ class SBNamespace(TrackedResource): :ivar alternate_name: Alternate name for namespace. :vartype alternate_name: str :ivar public_network_access: This determines if traffic is allowed over public network. By - default it is enabled. Known values are: "Enabled", "Disabled", "SecuredByPerimeter". Default - value: "Enabled". + default it is enabled. Known values are: "Enabled", "Disabled", and "SecuredByPerimeter". :vartype public_network_access: str or ~azure.mgmt.servicebus.v2022_01_01_preview.models.PublicNetworkAccess """ _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}, + "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'}, - 'minimum_tls_version': {'key': 'properties.minimumTlsVersion', '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'}, - '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'}, - 'alternate_name': {'key': 'properties.alternateName', 'type': 'str'}, - 'public_network_access': {'key': 'properties.publicNetworkAccess', 'type': 'str'}, + "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"}, + "minimum_tls_version": {"key": "properties.minimumTlsVersion", "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"}, + "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"}, + "alternate_name": {"key": "properties.alternateName", "type": "str"}, + "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, } def __init__( @@ -2018,20 +1911,20 @@ def __init__( private_endpoint_connections: Optional[List["_models.PrivateEndpointConnection"]] = None, disable_local_auth: Optional[bool] = None, alternate_name: Optional[str] = None, - public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = "Enabled", + public_network_access: Union[str, "_models.PublicNetworkAccess"] = "Enabled", **kwargs ): """ - :keyword location: Required. The Geo-location where the resource lives. + :keyword location: The Geo-location where the resource lives. Required. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword sku: Properties of SKU. :paramtype sku: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBSku :keyword identity: Properties of BYOK Identity description. :paramtype identity: ~azure.mgmt.servicebus.v2022_01_01_preview.models.Identity :keyword minimum_tls_version: The minimum TLS version for the cluster to support, e.g. '1.2'. - Known values are: "1.0", "1.1", "1.2". + Known values are: "1.0", "1.1", and "1.2". :paramtype minimum_tls_version: str or ~azure.mgmt.servicebus.v2022_01_01_preview.models.TlsVersion :keyword zone_redundant: Enabling this property creates a Premium Service Bus Namespace in @@ -2048,12 +1941,11 @@ def __init__( :keyword alternate_name: Alternate name for namespace. :paramtype alternate_name: str :keyword public_network_access: This determines if traffic is allowed over public network. By - default it is enabled. Known values are: "Enabled", "Disabled", "SecuredByPerimeter". Default - value: "Enabled". + default it is enabled. Known values are: "Enabled", "Disabled", and "SecuredByPerimeter". :paramtype public_network_access: str or ~azure.mgmt.servicebus.v2022_01_01_preview.models.PublicNetworkAccess """ - super(SBNamespace, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.sku = sku self.identity = identity self.system_data = None @@ -2072,7 +1964,7 @@ def __init__( self.public_network_access = public_network_access -class SBNamespaceListResult(msrest.serialization.Model): +class SBNamespaceListResult(_serialization.Model): """The response of the List Namespace operation. :ivar value: Result of the List Namespace operation. @@ -2083,16 +1975,12 @@ class SBNamespaceListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SBNamespace]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SBNamespace]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.SBNamespace"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.SBNamespace"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Result of the List Namespace operation. @@ -2101,12 +1989,12 @@ def __init__( list of Namespaces. :paramtype next_link: str """ - super(SBNamespaceListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SBNamespaceUpdateParameters(ResourceNamespacePatch): +class SBNamespaceUpdateParameters(ResourceNamespacePatch): # pylint: disable=too-many-instance-attributes """Description of a namespace resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2119,7 +2007,7 @@ class SBNamespaceUpdateParameters(ResourceNamespacePatch): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar sku: Properties of SKU. :vartype sku: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBSku @@ -2150,35 +2038,38 @@ class SBNamespaceUpdateParameters(ResourceNamespacePatch): """ _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}, + "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'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, - 'private_endpoint_connections': {'key': 'properties.privateEndpointConnections', 'type': '[PrivateEndpointConnection]'}, - 'disable_local_auth': {'key': 'properties.disableLocalAuth', 'type': 'bool'}, - 'alternate_name': {'key': 'properties.alternateName', 'type': 'str'}, + "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"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "private_endpoint_connections": { + "key": "properties.privateEndpointConnections", + "type": "[PrivateEndpointConnection]", + }, + "disable_local_auth": {"key": "properties.disableLocalAuth", "type": "bool"}, + "alternate_name": {"key": "properties.alternateName", "type": "str"}, } def __init__( @@ -2197,7 +2088,7 @@ def __init__( """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword sku: Properties of SKU. :paramtype sku: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBSku @@ -2214,7 +2105,7 @@ def __init__( :keyword alternate_name: Alternate name for namespace. :paramtype alternate_name: str """ - super(SBNamespaceUpdateParameters, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.sku = sku self.identity = identity self.provisioning_state = None @@ -2229,7 +2120,7 @@ def __init__( self.alternate_name = alternate_name -class SBQueue(ProxyResource): +class SBQueue(ProxyResource): # pylint: disable=too-many-instance-attributes """Description of queue Resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2256,9 +2147,9 @@ class SBQueue(ProxyResource): to this queue. :vartype accessed_at: ~datetime.datetime :ivar size_in_bytes: The size of the queue, in bytes. - :vartype size_in_bytes: long + :vartype size_in_bytes: int :ivar message_count: The number of messages in the queue. - :vartype message_count: long + :vartype message_count: int :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. @@ -2268,7 +2159,7 @@ class SBQueue(ProxyResource): :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. - :vartype max_message_size_in_kilobytes: long + :vartype max_message_size_in_kilobytes: int :ivar requires_duplicate_detection: A value indicating if this queue requires duplicate detection. :vartype requires_duplicate_detection: bool @@ -2290,7 +2181,7 @@ class SBQueue(ProxyResource): :vartype max_delivery_count: int :ivar status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". + "Deleting", "Renaming", and "Unknown". :vartype status: str or ~azure.mgmt.servicebus.v2022_01_01_preview.models.EntityStatus :ivar enable_batched_operations: Value that indicates whether server-side batched operations are enabled. @@ -2311,50 +2202,53 @@ class SBQueue(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'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}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"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'}, - 'location': {'key': 'location', '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__( + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "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": "int"}, + "message_count": {"key": "properties.messageCount", "type": "int"}, + "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": "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__( # pylint: disable=too-many-locals self, *, lock_duration: Optional[datetime.timedelta] = None, @@ -2385,7 +2279,7 @@ def __init__( :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 + :paramtype max_message_size_in_kilobytes: int :keyword requires_duplicate_detection: A value indicating if this queue requires duplicate detection. :paramtype requires_duplicate_detection: bool @@ -2407,7 +2301,7 @@ def __init__( :paramtype max_delivery_count: int :keyword status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". + "Deleting", "Renaming", and "Unknown". :paramtype status: str or ~azure.mgmt.servicebus.v2022_01_01_preview.models.EntityStatus :keyword enable_batched_operations: Value that indicates whether server-side batched operations are enabled. @@ -2427,7 +2321,7 @@ def __init__( message. :paramtype forward_dead_lettered_messages_to: str """ - super(SBQueue, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.count_details = None self.created_at = None @@ -2453,7 +2347,7 @@ def __init__( self.forward_dead_lettered_messages_to = forward_dead_lettered_messages_to -class SBQueueListResult(msrest.serialization.Model): +class SBQueueListResult(_serialization.Model): """The response to the List Queues operation. :ivar value: Result of the List Queues operation. @@ -2464,17 +2358,11 @@ class SBQueueListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SBQueue]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SBQueue]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.SBQueue"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.SBQueue"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: Result of the List Queues operation. :paramtype value: list[~azure.mgmt.servicebus.v2022_01_01_preview.models.SBQueue] @@ -2482,19 +2370,19 @@ def __init__( list of queues. :paramtype next_link: str """ - super(SBQueueListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SBSku(msrest.serialization.Model): +class SBSku(_serialization.Model): """SKU of the namespace. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Name of this SKU. Known values are: "Basic", "Standard", "Premium". + :ivar name: Name of this SKU. Required. Known values are: "Basic", "Standard", and "Premium". :vartype name: str or ~azure.mgmt.servicebus.v2022_01_01_preview.models.SkuName - :ivar tier: The billing tier of this particular SKU. Known values are: "Basic", "Standard", + :ivar tier: The billing tier of this particular SKU. Known values are: "Basic", "Standard", and "Premium". :vartype tier: str or ~azure.mgmt.servicebus.v2022_01_01_preview.models.SkuTier :ivar capacity: The specified messaging units for the tier. For Premium tier, capacity are 1,2 @@ -2503,13 +2391,13 @@ class SBSku(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'int'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "capacity": {"key": "capacity", "type": "int"}, } def __init__( @@ -2521,22 +2409,23 @@ def __init__( **kwargs ): """ - :keyword name: Required. Name of this SKU. Known values are: "Basic", "Standard", "Premium". + :keyword name: Name of this SKU. Required. Known values are: "Basic", "Standard", and + "Premium". :paramtype name: str or ~azure.mgmt.servicebus.v2022_01_01_preview.models.SkuName :keyword tier: The billing tier of this particular SKU. Known values are: "Basic", "Standard", - "Premium". + and "Premium". :paramtype tier: str or ~azure.mgmt.servicebus.v2022_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) + super().__init__(**kwargs) self.name = name self.tier = tier self.capacity = capacity -class SBSubscription(ProxyResource): +class SBSubscription(ProxyResource): # pylint: disable=too-many-instance-attributes """Description of subscription resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2554,7 +2443,7 @@ class SBSubscription(ProxyResource): :ivar system_data: The system meta data relating to this resource. :vartype system_data: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SystemData :ivar message_count: Number of messages. - :vartype message_count: long + :vartype message_count: int :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. @@ -2585,7 +2474,7 @@ class SBSubscription(ProxyResource): :vartype max_delivery_count: int :ivar status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". + "Deleting", "Renaming", and "Unknown". :vartype status: str or ~azure.mgmt.servicebus.v2022_01_01_preview.models.EntityStatus :ivar enable_batched_operations: Value that indicates whether server-side batched operations are enabled. @@ -2606,46 +2495,52 @@ class SBSubscription(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'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}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"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'}, - 'location': {'key': 'location', '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__( + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "message_count": {"key": "properties.messageCount", "type": "int"}, + "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__( # pylint: disable=too-many-locals self, *, lock_duration: Optional[datetime.timedelta] = None, @@ -2687,7 +2582,7 @@ def __init__( :paramtype max_delivery_count: int :keyword status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". + "Deleting", "Renaming", and "Unknown". :paramtype status: str or ~azure.mgmt.servicebus.v2022_01_01_preview.models.EntityStatus :keyword enable_batched_operations: Value that indicates whether server-side batched operations are enabled. @@ -2707,7 +2602,7 @@ def __init__( :paramtype client_affine_properties: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBClientAffineProperties """ - super(SBSubscription, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.message_count = None self.created_at = None @@ -2730,7 +2625,7 @@ def __init__( self.client_affine_properties = client_affine_properties -class SBSubscriptionListResult(msrest.serialization.Model): +class SBSubscriptionListResult(_serialization.Model): """The response to the List Subscriptions operation. :ivar value: Result of the List Subscriptions operation. @@ -2741,16 +2636,12 @@ class SBSubscriptionListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SBSubscription]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SBSubscription]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.SBSubscription"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.SBSubscription"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Result of the List Subscriptions operation. @@ -2759,12 +2650,12 @@ def __init__( list of subscriptions. :paramtype next_link: str """ - super(SBSubscriptionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SBTopic(ProxyResource): +class SBTopic(ProxyResource): # pylint: disable=too-many-instance-attributes """Description of topic resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2782,7 +2673,7 @@ class SBTopic(ProxyResource): :ivar system_data: The system meta data relating to this resource. :vartype system_data: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SystemData :ivar size_in_bytes: Size of the topic, in bytes. - :vartype size_in_bytes: long + :vartype size_in_bytes: int :ivar created_at: Exact time the message was created. :vartype created_at: ~datetime.datetime :ivar updated_at: The exact time the message was updated. @@ -2802,7 +2693,7 @@ class SBTopic(ProxyResource): :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. - :vartype max_message_size_in_kilobytes: long + :vartype max_message_size_in_kilobytes: int :ivar requires_duplicate_detection: Value indicating if this topic requires duplicate detection. :vartype requires_duplicate_detection: bool @@ -2814,7 +2705,7 @@ class SBTopic(ProxyResource): :vartype enable_batched_operations: bool :ivar status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". + "Deleting", "Renaming", and "Unknown". :vartype status: str or ~azure.mgmt.servicebus.v2022_01_01_preview.models.EntityStatus :ivar support_ordering: Value that indicates whether the topic supports ordering. :vartype support_ordering: bool @@ -2830,42 +2721,45 @@ class SBTopic(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'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}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"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'}, - 'location': {'key': 'location', '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'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "size_in_bytes": {"key": "properties.sizeInBytes", "type": "int"}, + "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": "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__( @@ -2894,7 +2788,7 @@ def __init__( :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 + :paramtype max_message_size_in_kilobytes: int :keyword requires_duplicate_detection: Value indicating if this topic requires duplicate detection. :paramtype requires_duplicate_detection: bool @@ -2906,7 +2800,7 @@ def __init__( :paramtype enable_batched_operations: bool :keyword status: Enumerates the possible values for the status of a messaging entity. Known values are: "Active", "Disabled", "Restoring", "SendDisabled", "ReceiveDisabled", "Creating", - "Deleting", "Renaming", "Unknown". + "Deleting", "Renaming", and "Unknown". :paramtype status: str or ~azure.mgmt.servicebus.v2022_01_01_preview.models.EntityStatus :keyword support_ordering: Value that indicates whether the topic supports ordering. :paramtype support_ordering: bool @@ -2920,7 +2814,7 @@ def __init__( topic holds a message in memory temporarily before writing it to persistent storage. :paramtype enable_express: bool """ - super(SBTopic, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.size_in_bytes = None self.created_at = None @@ -2941,7 +2835,7 @@ def __init__( self.enable_express = enable_express -class SBTopicListResult(msrest.serialization.Model): +class SBTopicListResult(_serialization.Model): """The response to the List Topics operation. :ivar value: Result of the List Topics operation. @@ -2952,17 +2846,11 @@ class SBTopicListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SBTopic]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SBTopic]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.SBTopic"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.SBTopic"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: Result of the List Topics operation. :paramtype value: list[~azure.mgmt.servicebus.v2022_01_01_preview.models.SBTopic] @@ -2970,12 +2858,12 @@ def __init__( list of topics. :paramtype next_link: str """ - super(SBTopicListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SqlFilter(msrest.serialization.Model): +class SqlFilter(_serialization.Model): """Represents a filter which is a composition of an expression and an action that is executed in the pub/sub pipeline. :ivar sql_expression: The SQL expression. e.g. MyProperty='ABC'. @@ -2989,9 +2877,9 @@ class SqlFilter(msrest.serialization.Model): """ _attribute_map = { - 'sql_expression': {'key': 'sqlExpression', 'type': 'str'}, - 'compatibility_level': {'key': 'compatibilityLevel', 'type': 'int'}, - 'requires_preprocessing': {'key': 'requiresPreprocessing', 'type': 'bool'}, + "sql_expression": {"key": "sqlExpression", "type": "str"}, + "compatibility_level": {"key": "compatibilityLevel", "type": "int"}, + "requires_preprocessing": {"key": "requiresPreprocessing", "type": "bool"}, } def __init__( @@ -2999,7 +2887,7 @@ def __init__( *, sql_expression: Optional[str] = None, compatibility_level: Optional[int] = None, - requires_preprocessing: Optional[bool] = True, + requires_preprocessing: bool = True, **kwargs ): """ @@ -3012,7 +2900,7 @@ def __init__( preprocessing. :paramtype requires_preprocessing: bool """ - super(SqlFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.sql_expression = sql_expression self.compatibility_level = compatibility_level self.requires_preprocessing = requires_preprocessing @@ -3032,9 +2920,9 @@ class SqlRuleAction(Action): """ _attribute_map = { - 'sql_expression': {'key': 'sqlExpression', 'type': 'str'}, - 'compatibility_level': {'key': 'compatibilityLevel', 'type': 'int'}, - 'requires_preprocessing': {'key': 'requiresPreprocessing', 'type': 'bool'}, + "sql_expression": {"key": "sqlExpression", "type": "str"}, + "compatibility_level": {"key": "compatibilityLevel", "type": "int"}, + "requires_preprocessing": {"key": "requiresPreprocessing", "type": "bool"}, } def __init__( @@ -3042,7 +2930,7 @@ def __init__( *, sql_expression: Optional[str] = None, compatibility_level: Optional[int] = None, - requires_preprocessing: Optional[bool] = True, + requires_preprocessing: bool = True, **kwargs ): """ @@ -3055,47 +2943,47 @@ def __init__( preprocessing. :paramtype requires_preprocessing: bool """ - super(SqlRuleAction, self).__init__(sql_expression=sql_expression, compatibility_level=compatibility_level, requires_preprocessing=requires_preprocessing, **kwargs) + super().__init__( + sql_expression=sql_expression, + compatibility_level=compatibility_level, + requires_preprocessing=requires_preprocessing, + **kwargs + ) -class Subnet(msrest.serialization.Model): +class Subnet(_serialization.Model): """Properties supplied for Subnet. All required parameters must be populated in order to send to Azure. - :ivar id: Required. Resource ID of Virtual Network Subnet. + :ivar id: Resource ID of Virtual Network Subnet. Required. :vartype id: str """ _validation = { - 'id': {'required': True}, + "id": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: str, - **kwargs - ): + def __init__(self, *, id: str, **kwargs): # pylint: disable=redefined-builtin """ - :keyword id: Required. Resource ID of Virtual Network Subnet. + :keyword id: Resource ID of Virtual Network Subnet. Required. :paramtype id: str """ - super(Subnet, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id -class SystemData(msrest.serialization.Model): +class SystemData(_serialization.Model): """Metadata pertaining to creation and last modification of the resource. :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. Known values are: - "User", "Application", "ManagedIdentity", "Key". + "User", "Application", "ManagedIdentity", and "Key". :vartype created_by_type: str or ~azure.mgmt.servicebus.v2022_01_01_preview.models.CreatedByType :ivar created_at: The timestamp of resource creation (UTC). @@ -3103,7 +2991,7 @@ class SystemData(msrest.serialization.Model): :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. Known values - are: "User", "Application", "ManagedIdentity", "Key". + are: "User", "Application", "ManagedIdentity", and "Key". :vartype last_modified_by_type: str or ~azure.mgmt.servicebus.v2022_01_01_preview.models.CreatedByType :ivar last_modified_at: The type of identity that last modified the resource. @@ -3111,12 +2999,12 @@ class SystemData(msrest.serialization.Model): """ _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'}, + "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__( @@ -3134,7 +3022,7 @@ def __init__( :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. Known values are: - "User", "Application", "ManagedIdentity", "Key". + "User", "Application", "ManagedIdentity", and "Key". :paramtype created_by_type: str or ~azure.mgmt.servicebus.v2022_01_01_preview.models.CreatedByType :keyword created_at: The timestamp of resource creation (UTC). @@ -3142,13 +3030,13 @@ def __init__( :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. Known - values are: "User", "Application", "ManagedIdentity", "Key". + values are: "User", "Application", "ManagedIdentity", and "Key". :paramtype last_modified_by_type: str or ~azure.mgmt.servicebus.v2022_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) + super().__init__(**kwargs) self.created_by = created_by self.created_by_type = created_by_type self.created_at = created_at @@ -3157,7 +3045,7 @@ def __init__( self.last_modified_at = last_modified_at -class UserAssignedIdentity(msrest.serialization.Model): +class UserAssignedIdentity(_serialization.Model): """Recognized Dictionary value. Variables are only populated by the server, and will be ignored when sending a request. @@ -3169,27 +3057,23 @@ class UserAssignedIdentity(msrest.serialization.Model): """ _validation = { - 'principal_id': {'readonly': True}, - 'client_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "client_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'client_id': {'key': 'clientId', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "client_id": {"key": "clientId", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(UserAssignedIdentity, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.principal_id = None self.client_id = None -class UserAssignedIdentityProperties(msrest.serialization.Model): +class UserAssignedIdentityProperties(_serialization.Model): """UserAssignedIdentityProperties. :ivar user_assigned_identity: ARM ID of user Identity selected for encryption. @@ -3197,18 +3081,13 @@ class UserAssignedIdentityProperties(msrest.serialization.Model): """ _attribute_map = { - 'user_assigned_identity': {'key': 'userAssignedIdentity', 'type': 'str'}, + "user_assigned_identity": {"key": "userAssignedIdentity", "type": "str"}, } - def __init__( - self, - *, - user_assigned_identity: Optional[str] = None, - **kwargs - ): + def __init__(self, *, 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) + super().__init__(**kwargs) self.user_assigned_identity = user_assigned_identity diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/models/_patch.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/models/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/models/_patch.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/models/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/models/_service_bus_management_client_enums.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/models/_service_bus_management_client_enums.py index b2b24765cf9f..3bbabd34856a 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/models/_service_bus_management_client_enums.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/models/_service_bus_management_client_enums.py @@ -11,30 +11,31 @@ class AccessRights(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """AccessRights.""" MANAGE = "Manage" SEND = "Send" LISTEN = "Listen" + class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of identity that created the resource. - """ + """The type of identity that created the resource.""" USER = "User" APPLICATION = "Application" MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" + class DefaultAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Default Action for Network Rule Set - """ + """Default Action for Network Rule Set.""" ALLOW = "Allow" DENY = "Deny" + class EndPointProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Provisioning state of the Private Endpoint Connection. - """ + """Provisioning state of the Private Endpoint Connection.""" CREATING = "Creating" UPDATING = "Updating" @@ -43,9 +44,9 @@ class EndPointProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): CANCELED = "Canceled" FAILED = "Failed" + class EntityStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Entity status. - """ + """Entity status.""" ACTIVE = "Active" DISABLED = "Disabled" @@ -57,114 +58,118 @@ class EntityStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): RENAMING = "Renaming" UNKNOWN = "Unknown" + class FilterType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Rule filter types - """ + """Rule filter types.""" SQL_FILTER = "SqlFilter" CORRELATION_FILTER = "CorrelationFilter" + class KeySource(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Enumerates the possible value of keySource for Encryption - """ + """Enumerates the possible value of keySource for Encryption.""" MICROSOFT_KEY_VAULT = "Microsoft.KeyVault" + class KeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The access key to regenerate. - """ + """The access key to regenerate.""" PRIMARY_KEY = "PrimaryKey" SECONDARY_KEY = "SecondaryKey" + class ManagedServiceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Type of managed service identity. - """ + """Type of managed service identity.""" SYSTEM_ASSIGNED = "SystemAssigned" USER_ASSIGNED = "UserAssigned" SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" NONE = "None" + class MigrationConfigurationName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """MigrationConfigurationName.""" _DEFAULT = "$default" + class NetworkRuleIPAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The IP Filter Action - """ + """The IP Filter Action.""" ALLOW = "Allow" + class PrivateLinkConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Status of the connection. - """ + """Status of the connection.""" PENDING = "Pending" APPROVED = "Approved" REJECTED = "Rejected" DISCONNECTED = "Disconnected" + class ProvisioningStateDR(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Provisioning state of the Alias(Disaster Recovery configuration) - possible values 'Accepted' - or 'Succeeded' or 'Failed' + or 'Succeeded' or 'Failed'. """ ACCEPTED = "Accepted" SUCCEEDED = "Succeeded" FAILED = "Failed" + class PublicNetworkAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """This determines if traffic is allowed over public network. By default it is enabled. - """ + """This determines if traffic is allowed over public network. By default it is enabled.""" ENABLED = "Enabled" DISABLED = "Disabled" SECURED_BY_PERIMETER = "SecuredByPerimeter" + class PublicNetworkAccessFlag(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """This determines if traffic is allowed over public network. By default it is enabled. - """ + """This determines if traffic is allowed over public network. By default it is enabled.""" ENABLED = "Enabled" DISABLED = "Disabled" + class RoleDisasterRecovery(str, Enum, metaclass=CaseInsensitiveEnumMeta): """role of namespace in GEO DR - possible values 'Primary' or 'PrimaryNotReplicating' or - 'Secondary' + 'Secondary'. """ PRIMARY = "Primary" PRIMARY_NOT_REPLICATING = "PrimaryNotReplicating" SECONDARY = "Secondary" + class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Name of this SKU. - """ + """Name of this SKU.""" BASIC = "Basic" STANDARD = "Standard" PREMIUM = "Premium" + class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The billing tier of this particular SKU. - """ + """The billing tier of this particular SKU.""" BASIC = "Basic" STANDARD = "Standard" PREMIUM = "Premium" + class TlsVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The minimum TLS version for the cluster to support, e.g. '1.2' - """ + """The minimum TLS version for the cluster to support, e.g. '1.2'.""" ONE0 = "1.0" ONE1 = "1.1" ONE2 = "1.2" + class UnavailableReason(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the reason for the unavailability of the service. - """ + """Specifies the reason for the unavailability of the service.""" NONE = "None" INVALID_NAME = "InvalidName" diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/__init__.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/__init__.py index 5559ccd3746c..831edc36bd6b 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/__init__.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/__init__.py @@ -20,17 +20,18 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'NamespacesOperations', - 'PrivateEndpointConnectionsOperations', - 'PrivateLinkResourcesOperations', - 'Operations', - 'DisasterRecoveryConfigsOperations', - 'MigrationConfigsOperations', - 'QueuesOperations', - 'TopicsOperations', - 'RulesOperations', - 'SubscriptionsOperations', + "NamespacesOperations", + "PrivateEndpointConnectionsOperations", + "PrivateLinkResourcesOperations", + "Operations", + "DisasterRecoveryConfigsOperations", + "MigrationConfigsOperations", + "QueuesOperations", + "TopicsOperations", + "RulesOperations", + "SubscriptionsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_disaster_recovery_configs_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_disaster_recovery_configs_operations.py index 5a2ea424d9b8..513e0be06673 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_disaster_recovery_configs_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_disaster_recovery_configs_operations.py @@ -6,11 +6,16 @@ # 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, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -20,298 +25,257 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - resource_group_name: str, - namespace_name: str, - alias: str, - subscription_id: str, - *, - json: Optional[_models.ArmDisasterRecovery] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, alias: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - namespace_name: str, - alias: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, alias: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - namespace_name: str, - alias: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, alias: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_break_pairing_request( - resource_group_name: str, - namespace_name: str, - alias: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, alias: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_fail_over_request( - resource_group_name: str, - namespace_name: str, - alias: str, - subscription_id: str, - *, - json: Optional[_models.FailoverProperties] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, alias: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_authorization_rules_request( - resource_group_name: str, - namespace_name: str, - alias: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, alias: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_authorization_rule_request( @@ -325,34 +289,35 @@ def build_get_authorization_rule_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( @@ -366,79 +331,72 @@ def build_list_keys_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_check_name_availability_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - *, - json: Optional[_models.CheckNameAvailability] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + class DisasterRecoveryConfigsOperations: """ @@ -459,46 +417,40 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> Iterable[_models.ArmDisasterRecoveryListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> Iterable["_models.ArmDisasterRecovery"]: """Gets all Alias(Disaster Recovery configurations). - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: An iterator like instance of either ArmDisasterRecovery or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.ArmDisasterRecoveryListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.ArmDisasterRecovery] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ArmDisasterRecoveryListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -506,16 +458,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -531,10 +478,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -545,49 +490,117 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 + @overload def create_or_update( self, resource_group_name: str, namespace_name: str, alias: str, parameters: _models.ArmDisasterRecovery, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Required. :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.ArmDisasterRecovery + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ArmDisasterRecovery or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.ArmDisasterRecovery or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ArmDisasterRecovery or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.ArmDisasterRecovery or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: Union[_models.ArmDisasterRecovery, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). Is + either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.ArmDisasterRecovery or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ArmDisasterRecovery, or the result of cls(response) + :return: ArmDisasterRecovery or None or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.ArmDisasterRecovery or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ArmDisasterRecovery]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ArmDisasterRecovery]] - _json = self._serialize.body(parameters, 'ArmDisasterRecovery') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ArmDisasterRecovery") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -597,7 +610,8 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -605,10 +619,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -618,56 +631,48 @@ def create_or_update( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ArmDisasterRecovery', pipeline_response) + 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 - + 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: str, - namespace_name: str, - alias: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -675,10 +680,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -689,49 +693,41 @@ def delete( # pylint: disable=inconsistent-return-statements 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: str, - namespace_name: str, - alias: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :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) + :return: ArmDisasterRecovery or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.ArmDisasterRecovery - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ArmDisasterRecovery] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ArmDisasterRecovery] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -739,10 +735,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -750,57 +745,49 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ArmDisasterRecovery', pipeline_response) + 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 - + 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: str, - namespace_name: str, - alias: str, - **kwargs: Any + self, 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. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.break_pairing.metadata["url"], headers=_headers, params=_params, ) @@ -808,10 +795,9 @@ def break_pairing( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -822,50 +808,118 @@ def break_pairing( # pylint: disable=inconsistent-return-statements 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 - @distributed_trace + @overload def fail_over( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, alias: str, parameters: Optional[_models.FailoverProperties] = None, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). Default value is None. :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.FailoverProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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: + """ + + @overload + def fail_over( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). + Default value is None. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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: + """ + + @distributed_trace + def fail_over( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + namespace_name: str, + alias: str, + parameters: Optional[Union[_models.FailoverProperties, IO]] = 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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param alias: The Disaster Recovery configuration name. Required. + :type alias: str + :param parameters: Parameters required to create an Alias(Disaster Recovery configuration). Is + either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.FailoverProperties or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - if parameters is not None: - _json = self._serialize.body(parameters, 'FailoverProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "FailoverProperties") + else: + _json = None request = build_fail_over_request( resource_group_name=resource_group_name, @@ -875,7 +929,8 @@ def fail_over( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, json=_json, - template_url=self.fail_over.metadata['url'], + content=_content, + template_url=self.fail_over.metadata["url"], headers=_headers, params=_params, ) @@ -883,10 +938,9 @@ def fail_over( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -897,52 +951,45 @@ def fail_over( # pylint: disable=inconsistent-return-statements 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, - namespace_name: str, - alias: str, - **kwargs: Any - ) -> Iterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, alias: str, **kwargs: Any + ) -> Iterable["_models.SBAuthorizationRule"]: """Gets the authorization rules for a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :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) + :return: An iterator like instance of either SBAuthorizationRule or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.SBAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.SBAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) @@ -950,17 +997,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -976,10 +1017,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -990,48 +1029,38 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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: str, - namespace_name: str, - alias: str, - authorization_rule_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -1039,7 +1068,7 @@ def get_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -1047,10 +1076,9 @@ def get_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1058,52 +1086,43 @@ def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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: str, - namespace_name: str, - alias: str, - authorization_rule_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param alias: The Disaster Recovery configuration name. + :param alias: The Disaster Recovery configuration name. Required. :type alias: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -1111,7 +1130,7 @@ def list_keys( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1119,10 +1138,9 @@ def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1130,50 +1148,111 @@ def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}/listKeys"} # type: ignore - - @distributed_trace + @overload def check_name_availability( self, resource_group_name: str, namespace_name: str, parameters: _models.CheckNameAvailability, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Check the give namespace name availability. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters to check availability of the given namespace name. + :param parameters: Parameters to check availability of the given namespace name. Required. :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.CheckNameAvailability + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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.v2022_01_01_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters to check availability of the given namespace name. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :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.v2022_01_01_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, + resource_group_name: str, + namespace_name: str, + parameters: Union[_models.CheckNameAvailability, IO], + **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters to check availability of the given namespace name. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.CheckNameAvailability or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameAvailabilityResult, or the result of cls(response) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResult] - _json = self._serialize.body(parameters, 'CheckNameAvailability') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CheckNameAvailability") request = build_check_name_availability_request( resource_group_name=resource_group_name, @@ -1182,7 +1261,8 @@ def check_name_availability( api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) @@ -1190,10 +1270,9 @@ def check_name_availability( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1201,12 +1280,11 @@ def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + 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 - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/CheckNameAvailability"} # type: ignore diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_migration_configs_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_migration_configs_operations.py index 88853ef0f315..5b1dc683fba5 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_migration_configs_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_migration_configs_operations.py @@ -6,11 +6,16 @@ # 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, Iterable, Optional, TypeVar, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -22,95 +27,88 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_and_start_migration_request_initial( +def build_create_and_start_migration_request( resource_group_name: str, namespace_name: str, config_name: Union[str, "_models.MigrationConfigurationName"], subscription_id: str, - *, - json: Optional[_models.MigrationConfigProperties] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( @@ -123,33 +121,32 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( @@ -162,33 +159,32 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_complete_migration_request( @@ -201,33 +197,32 @@ def build_complete_migration_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_revert_request( @@ -240,33 +235,33 @@ def build_revert_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class MigrationConfigsOperations: """ @@ -287,46 +282,41 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> Iterable[_models.MigrationConfigListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> Iterable["_models.MigrationConfigProperties"]: """Gets all migrationConfigurations. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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 + :return: An iterator like instance of either MigrationConfigProperties or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.MigrationConfigListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.MigrationConfigProperties] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MigrationConfigListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -334,16 +324,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -359,10 +344,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -373,35 +356,37 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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: str, namespace_name: str, config_name: Union[str, "_models.MigrationConfigurationName"], - parameters: _models.MigrationConfigProperties, + parameters: Union[_models.MigrationConfigProperties, IO], **kwargs: Any ) -> Optional[_models.MigrationConfigProperties]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.MigrationConfigProperties]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.MigrationConfigProperties]] - _json = self._serialize.body(parameters, 'MigrationConfigProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "MigrationConfigProperties") - request = build_create_and_start_migration_request_initial( + request = build_create_and_start_migration_request( resource_group_name=resource_group_name, namespace_name=namespace_name, config_name=config_name, @@ -409,7 +394,8 @@ def _create_and_start_migration_initial( api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_and_start_migration_initial.metadata['url'], + content=_content, + template_url=self._create_and_start_migration_initial.metadata["url"], headers=_headers, params=_params, ) @@ -417,27 +403,108 @@ def _create_and_start_migration_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) + 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 + _create_and_start_migration_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}"} # type: ignore + @overload + def begin_create_and_start_migration( + self, + resource_group_name: str, + namespace_name: str, + config_name: Union[str, "_models.MigrationConfigurationName"], + parameters: _models.MigrationConfigProperties, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param config_name: The configuration name. Should always be "$default". "$default" Required. + :type config_name: str or + ~azure.mgmt.servicebus.v2022_01_01_preview.models.MigrationConfigurationName + :param parameters: Parameters required to create Migration Configuration. Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.MigrationConfigProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. + :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.v2022_01_01_preview.models.MigrationConfigProperties] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_and_start_migration( + self, + resource_group_name: str, + namespace_name: str, + config_name: Union[str, "_models.MigrationConfigurationName"], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param config_name: The configuration name. Should always be "$default". "$default" Required. + :type config_name: str or + ~azure.mgmt.servicebus.v2022_01_01_preview.models.MigrationConfigurationName + :param parameters: Parameters required to create Migration Configuration. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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.v2022_01_01_preview.models.MigrationConfigProperties] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_and_start_migration( @@ -445,21 +512,26 @@ def begin_create_and_start_migration( resource_group_name: str, namespace_name: str, config_name: Union[str, "_models.MigrationConfigurationName"], - parameters: _models.MigrationConfigProperties, + parameters: Union[_models.MigrationConfigProperties, IO], **kwargs: Any ) -> LROPoller[_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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2022_01_01_preview.models.MigrationConfigurationName - :param parameters: Parameters required to create Migration Configuration. + :param parameters: Parameters required to create Migration Configuration. Is either a model + type or a IO type. Required. :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.MigrationConfigProperties + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -472,20 +544,17 @@ def begin_create_and_start_migration( of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.servicebus.v2022_01_01_preview.models.MigrationConfigProperties] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.MigrationConfigProperties] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MigrationConfigProperties] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + 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 = self._create_and_start_migration_initial( # type: ignore resource_group_name=resource_group_name, @@ -494,39 +563,35 @@ def begin_create_and_start_migration( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) + deserialized = self._deserialize("MigrationConfigProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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 @@ -538,37 +603,34 @@ def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes a MigrationConfiguration. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2022_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -576,10 +638,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -590,8 +651,7 @@ def delete( # pylint: disable=inconsistent-return-statements 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( @@ -603,37 +663,34 @@ def get( ) -> _models.MigrationConfigProperties: """Retrieves Migration Config. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2022_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) + :return: MigrationConfigProperties or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.MigrationConfigProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MigrationConfigProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MigrationConfigProperties] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -641,10 +698,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -652,15 +708,14 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('MigrationConfigProperties', pipeline_response) + 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 - + 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 @@ -674,37 +729,34 @@ def complete_migration( # pylint: disable=inconsistent-return-statements 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2022_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.complete_migration.metadata["url"], headers=_headers, params=_params, ) @@ -712,10 +764,9 @@ def complete_migration( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -726,8 +777,7 @@ def complete_migration( # pylint: disable=inconsistent-return-statements 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 @distributed_trace def revert( # pylint: disable=inconsistent-return-statements @@ -739,37 +789,34 @@ def revert( # pylint: disable=inconsistent-return-statements ) -> None: """This operation reverts Migration. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param config_name: The configuration name. Should always be "$default". + :param config_name: The configuration name. Should always be "$default". "$default" Required. :type config_name: str or ~azure.mgmt.servicebus.v2022_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.revert.metadata["url"], headers=_headers, params=_params, ) @@ -777,10 +824,9 @@ def revert( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -791,5 +837,4 @@ def revert( # pylint: disable=inconsistent-return-statements 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/v2022_01_01_preview/operations/_namespaces_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_namespaces_operations.py index 5ca6dab57a1b..c6f6bd01a618 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_namespaces_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_namespaces_operations.py @@ -6,11 +6,16 @@ # 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, Iterable, Optional, TypeVar, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -22,651 +27,557 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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: + +def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + accept = _headers.pop("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'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_resource_group_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces") # pylint: disable=line-too-long + _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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request_initial( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - *, - json: Optional[_models.SBNamespace] = None, - content: Any = None, - **kwargs: Any + +def build_create_or_update_request( + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long + _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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any +def build_delete_request( + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - *, - json: Optional[_models.SBNamespaceUpdateParameters] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}") # pylint: disable=line-too-long + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_network_rule_set_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - *, - json: Optional[_models.NetworkRuleSet] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_network_rule_set_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_network_rule_sets_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_authorization_rules_request( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_authorization_rule_request( - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - subscription_id: str, - *, - json: Optional[_models.SBAuthorizationRule] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, authorization_rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_authorization_rule_request( - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, authorization_rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_authorization_rule_request( - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, authorization_rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, authorization_rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_regenerate_keys_request( - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - subscription_id: str, - *, - json: Optional[_models.RegenerateAccessKeyParameters] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, authorization_rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_check_name_availability_request( - subscription_id: str, - *, - json: Optional[_models.CheckNameAvailability] = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: + +def build_check_name_availability_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + class NamespacesOperations: """ @@ -687,38 +598,32 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.SBNamespaceListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.SBNamespace"]: """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) + :return: An iterator like instance of either SBNamespace or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.SBNamespaceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.SBNamespace] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespaceListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -726,14 +631,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -749,10 +651,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -763,47 +663,39 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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: str, - **kwargs: Any - ) -> Iterable[_models.SBNamespaceListResult]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.SBNamespace"]: """Gets the available namespaces within a resource group. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :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) + :return: An iterator like instance of either SBNamespace or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.SBNamespaceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.SBNamespace] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespaceListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -811,15 +703,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -835,10 +723,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -849,41 +735,40 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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: str, - namespace_name: str, - parameters: _models.SBNamespace, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, parameters: Union[_models.SBNamespace, IO], **kwargs: Any ) -> Optional[_models.SBNamespace]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.SBNamespace]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.SBNamespace]] - _json = self._serialize.body(parameters, 'SBNamespace') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBNamespace") - request = build_create_or_update_request_initial( + request = build_create_or_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._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) @@ -891,48 +776,89 @@ def _create_or_update_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SBNamespace', pipeline_response) + 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 - + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, namespace_name: str, parameters: _models.SBNamespace, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters supplied to create a namespace resource. + :param parameters: Parameters supplied to create a namespace resource. Required. :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBNamespace + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. + :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.v2022_01_01_preview.models.SBNamespace] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to create a namespace resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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 @@ -945,20 +871,49 @@ def begin_create_or_update( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.servicebus.v2022_01_01_preview.models.SBNamespace] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, resource_group_name: str, namespace_name: str, parameters: Union[_models.SBNamespace, IO], **kwargs: Any + ) -> LROPoller[_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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to create a namespace resource. Is either a model type + or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBNamespace or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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.v2022_01_01_preview.models.SBNamespace] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespace] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBNamespace] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + 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 = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, @@ -966,64 +921,54 @@ def begin_create_or_update( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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: str, - namespace_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_request_initial( + request = build_delete_request( 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'], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1031,35 +976,29 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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_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 @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, 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. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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. @@ -1071,92 +1010,77 @@ def begin_delete( # pylint: disable=inconsistent-return-statements 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + 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 = self._delete_initial( # type: ignore resource_group_name=resource_group_name, namespace_name=namespace_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> _models.SBNamespace: + def get(self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: SBNamespace or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBNamespace - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBNamespace] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBNamespace] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -1164,10 +1088,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1175,51 +1098,115 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBNamespace', pipeline_response) + 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 + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore + + @overload + def update( + self, + resource_group_name: str, + namespace_name: str, + parameters: _models.SBNamespaceUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> 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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to update a namespace resource. Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBNamespaceUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBNamespace or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBNamespace or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> 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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: Parameters supplied to update a namespace resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SBNamespace or None or the result of cls(response) + :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBNamespace or None + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def update( self, resource_group_name: str, namespace_name: str, - parameters: _models.SBNamespaceUpdateParameters, + parameters: Union[_models.SBNamespaceUpdateParameters, IO], **kwargs: Any ) -> 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: Parameters supplied to update a namespace resource. + :param parameters: Parameters supplied to update a namespace resource. Is either a model type + or a IO type. Required. :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBNamespaceUpdateParameters + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBNamespace, or the result of cls(response) + :return: SBNamespace or None or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBNamespace or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.SBNamespace]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.SBNamespace]] - _json = self._serialize.body(parameters, 'SBNamespaceUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBNamespaceUpdateParameters") request = build_update_request( resource_group_name=resource_group_name, @@ -1228,7 +1215,8 @@ def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -1236,10 +1224,9 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -1249,53 +1236,113 @@ def update( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('SBNamespace', pipeline_response) + deserialized = self._deserialize("SBNamespace", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SBNamespace', pipeline_response) + 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 + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}"} # type: ignore - - @distributed_trace + @overload def create_or_update_network_rule_set( self, resource_group_name: str, namespace_name: str, parameters: _models.NetworkRuleSet, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.NetworkRuleSet: """Create or update NetworkRuleSet for a Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param parameters: The Namespace IpFilterRule. + :param parameters: The Namespace IpFilterRule. Required. :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.NetworkRuleSet + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: NetworkRuleSet, or the result of cls(response) + :return: NetworkRuleSet or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.NetworkRuleSet - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def create_or_update_network_rule_set( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NetworkRuleSet: + """Create or update NetworkRuleSet for a Namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: The Namespace IpFilterRule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2022_01_01_preview.models.NetworkRuleSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_network_rule_set( + self, + resource_group_name: str, + namespace_name: str, + parameters: Union[_models.NetworkRuleSet, IO], + **kwargs: Any + ) -> _models.NetworkRuleSet: + """Create or update NetworkRuleSet for a Namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param parameters: The Namespace IpFilterRule. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.NetworkRuleSet or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2022_01_01_preview.models.NetworkRuleSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkRuleSet] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.NetworkRuleSet] - _json = self._serialize.body(parameters, 'NetworkRuleSet') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "NetworkRuleSet") request = build_create_or_update_network_rule_set_request( resource_group_name=resource_group_name, @@ -1304,7 +1351,8 @@ def create_or_update_network_rule_set( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_network_rule_set.metadata['url'], + content=_content, + template_url=self.create_or_update_network_rule_set.metadata["url"], headers=_headers, params=_params, ) @@ -1312,10 +1360,9 @@ def create_or_update_network_rule_set( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1323,52 +1370,45 @@ def create_or_update_network_rule_set( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('NetworkRuleSet', pipeline_response) + 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 - + 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: str, - namespace_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: NetworkRuleSet or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.NetworkRuleSet - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkRuleSet] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.NetworkRuleSet] - 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'], + template_url=self.get_network_rule_set.metadata["url"], headers=_headers, params=_params, ) @@ -1376,10 +1416,9 @@ def get_network_rule_set( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1387,55 +1426,49 @@ def get_network_rule_set( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('NetworkRuleSet', pipeline_response) + 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 - + 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, - namespace_name: str, - **kwargs: Any - ) -> Iterable[_models.NetworkRuleSetListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> Iterable["_models.NetworkRuleSet"]: """Gets list of NetworkRuleSet for a Namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: An iterator like instance of either NetworkRuleSet or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.NetworkRuleSetListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.NetworkRuleSet] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.NetworkRuleSetListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_network_rule_sets.metadata["url"], headers=_headers, params=_params, ) @@ -1443,16 +1476,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -1468,10 +1496,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1482,51 +1508,44 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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: str, - namespace_name: str, - **kwargs: Any - ) -> Iterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> Iterable["_models.SBAuthorizationRule"]: """Gets the authorization rules for a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: An iterator like instance of either SBAuthorizationRule or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.SBAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.SBAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) @@ -1534,16 +1553,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -1559,10 +1573,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1573,49 +1585,115 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 + @overload def create_or_update_authorization_rule( self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, parameters: _models.SBAuthorizationRule, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBAuthorizationRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2022_01_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: Union[_models.SBAuthorizationRule, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBAuthorizationRule or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2022_01_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - _json = self._serialize.body(parameters, 'SBAuthorizationRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBAuthorizationRule") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -1625,7 +1703,8 @@ def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -1633,10 +1712,9 @@ def create_or_update_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1644,56 +1722,48 @@ def create_or_update_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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: str, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -1701,10 +1771,9 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1715,49 +1784,41 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements 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: str, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - 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'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -1765,10 +1826,9 @@ def get_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1776,56 +1836,48 @@ def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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: str, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - 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'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1833,10 +1885,9 @@ def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1844,54 +1895,122 @@ def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 - + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys"} # type: ignore - @distributed_trace + @overload def regenerate_keys( self, resource_group_name: str, namespace_name: str, authorization_rule_name: str, parameters: _models.RegenerateAccessKeyParameters, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.RegenerateAccessKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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.v2022_01_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2022_01_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateAccessKeyParameters, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: + ~azure.mgmt.servicebus.v2022_01_01_preview.models.RegenerateAccessKeyParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateAccessKeyParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -1901,7 +2020,8 @@ def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1909,10 +2029,9 @@ def regenerate_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1920,51 +2039,91 @@ def regenerate_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 + regenerate_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore + + @overload + def check_name_availability( + self, parameters: _models.CheckNameAvailability, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + :param parameters: Parameters to check availability of the given namespace name. Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.CheckNameAvailability + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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.v2022_01_01_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Check the give namespace name availability. + + :param parameters: Parameters to check availability of the given namespace name. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :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.v2022_01_01_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def check_name_availability( - self, - parameters: _models.CheckNameAvailability, - **kwargs: Any + self, parameters: Union[_models.CheckNameAvailability, IO], **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Check the give namespace name availability. - :param parameters: Parameters to check availability of the given namespace name. - :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.CheckNameAvailability + :param parameters: Parameters to check availability of the given namespace name. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.CheckNameAvailability or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameAvailabilityResult, or the result of cls(response) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResult] - _json = self._serialize.body(parameters, 'CheckNameAvailability') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _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'], + content=_content, + template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) @@ -1972,10 +2131,9 @@ def check_name_availability( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1983,12 +2141,11 @@ def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + 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 - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability"} # type: ignore diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_operations.py index c63bde8af450..32696facffd5 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_operations.py @@ -7,10 +7,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- 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 urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -20,38 +25,34 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +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: + +def build_list_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.ServiceBus/operations") # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class Operations: """ @@ -72,36 +73,31 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.OperationListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """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) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -109,13 +105,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -131,10 +125,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -145,8 +137,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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/v2022_01_01_preview/operations/_patch.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_patch.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_private_endpoint_connections_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_private_endpoint_connections_operations.py index f7b46b8fcdbf..036a19e4fd85 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_private_endpoint_connections_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_private_endpoint_connections_operations.py @@ -6,11 +6,16 @@ # 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, Iterable, Optional, TypeVar, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -22,134 +27,130 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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( - resource_group_name: str, - namespace_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - subscription_id: str, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, - *, - json: Optional[_models.PrivateEndpointConnection] = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( +def build_delete_request( resource_group_name: str, namespace_name: str, - subscription_id: str, private_endpoint_connection_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( @@ -162,33 +163,35 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class PrivateEndpointConnectionsOperations: """ @@ -209,46 +212,41 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any - ) -> Iterable[_models.PrivateEndpointConnectionListResult]: + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> Iterable["_models.PrivateEndpointConnection"]: """Gets the available PrivateEndpointConnections within a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.PrivateEndpointConnectionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnectionListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -256,16 +254,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -281,10 +274,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -295,60 +286,129 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 + @overload def create_or_update( self, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, parameters: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.PrivateEndpointConnection: """Creates or updates PrivateEndpointConnections of service namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param private_endpoint_connection_name: The PrivateEndpointConnection name. + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. :type private_endpoint_connection_name: str :param parameters: Parameters supplied to update Status of PrivateEndPoint Connection to - namespace resource. + namespace resource. Required. :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.PrivateEndpointConnection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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.v2022_01_01_preview.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Creates or updates PrivateEndpointConnections of service namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. + :type private_endpoint_connection_name: str + :param parameters: Parameters supplied to update Status of PrivateEndPoint Connection to + namespace resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateEndpointConnection, or the result of cls(response) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + parameters: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Creates or updates PrivateEndpointConnections of service namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. + :type private_endpoint_connection_name: str + :param parameters: Parameters supplied to update Status of PrivateEndPoint Connection to + namespace resource. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.PrivateEndpointConnection + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2022_01_01_preview.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - _json = self._serialize.body(parameters, 'PrivateEndpointConnection') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _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, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -356,10 +416,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -368,48 +427,40 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + 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 - + 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: str, - namespace_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_request_initial( + request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, - subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) @@ -417,37 +468,32 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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_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 @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - namespace_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + def begin_delete( + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param private_endpoint_connection_name: The PrivateEndpointConnection name. + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. :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. @@ -459,97 +505,83 @@ def begin_delete( # pylint: disable=inconsistent-return-statements 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + 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 = self._delete_initial( # type: ignore 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, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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: str, - namespace_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param private_endpoint_connection_name: The PrivateEndpointConnection name. + :param private_endpoint_connection_name: The PrivateEndpointConnection name. Required. :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) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -557,10 +589,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -568,12 +599,11 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + 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 - + 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/v2022_01_01_preview/operations/_private_link_resources_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_private_link_resources_operations.py index 890123c2a613..2832d468bbd7 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_private_link_resources_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_private_link_resources_operations.py @@ -8,9 +8,13 @@ # -------------------------------------------------------------------------- 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.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,48 +23,48 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class PrivateLinkResourcesOperations: """ @@ -81,43 +85,36 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def get( - self, - resource_group_name: str, - namespace_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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) + :return: PrivateLinkResourcesListResult or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.PrivateLinkResourcesListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourcesListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResourcesListResult] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -125,10 +122,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -136,12 +132,11 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateLinkResourcesListResult', pipeline_response) + 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 - + 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/v2022_01_01_preview/operations/_queues_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_queues_operations.py index 05c04c8b4fc5..f528fdda3380 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_queues_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_queues_operations.py @@ -6,11 +6,16 @@ # 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, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -20,50 +25,48 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") 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 + resource_group_name: str, namespace_name: str, queue_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_authorization_rule_request( @@ -72,47 +75,43 @@ def build_create_or_update_authorization_rule_request( queue_name: str, authorization_rule_name: str, subscription_id: str, - *, - json: Optional[_models.SBAuthorizationRule] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_authorization_rule_request( @@ -126,34 +125,35 @@ def build_delete_authorization_rule_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_authorization_rule_request( @@ -167,34 +167,35 @@ def build_get_authorization_rule_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( @@ -208,34 +209,35 @@ def build_list_keys_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_regenerate_keys_request( @@ -244,47 +246,43 @@ def build_regenerate_keys_request( queue_name: str, authorization_rule_name: str, subscription_id: str, - *, - json: Optional[_models.RegenerateAccessKeyParameters] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_namespace_request( @@ -299,161 +297,141 @@ def build_list_by_namespace_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if skip is not None: - _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', maximum=1000, minimum=0) + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", maximum=1000, minimum=0) if top is not None: - _params['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - resource_group_name: str, - namespace_name: str, - queue_name: str, - subscription_id: str, - *, - json: Optional[_models.SBQueue] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, queue_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - namespace_name: str, - queue_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, queue_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - namespace_name: str, - queue_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, queue_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class QueuesOperations: """ @@ -474,50 +452,43 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - queue_name: str, - **kwargs: Any - ) -> Iterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, queue_name: str, **kwargs: Any + ) -> Iterable["_models.SBAuthorizationRule"]: """Gets all authorization rules for a queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :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) + :return: An iterator like instance of either SBAuthorizationRule or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.SBAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.SBAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) @@ -525,17 +496,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -551,10 +516,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -565,13 +528,11 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 + @overload def create_or_update_authorization_rule( self, resource_group_name: str, @@ -579,38 +540,112 @@ def create_or_update_authorization_rule( queue_name: str, authorization_rule_name: str, parameters: _models.SBAuthorizationRule, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBAuthorizationRule: """Creates an authorization rule for a queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBAuthorizationRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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.v2022_01_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for a queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: Union[_models.SBAuthorizationRule, IO], + **kwargs: Any + ) -> _models.SBAuthorizationRule: + """Creates an authorization rule for a queue. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBAuthorizationRule or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2022_01_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - _json = self._serialize.body(parameters, 'SBAuthorizationRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBAuthorizationRule") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -621,7 +656,8 @@ def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -629,10 +665,9 @@ def create_or_update_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -640,15 +675,14 @@ def create_or_update_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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 @@ -661,31 +695,28 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes a queue authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -693,7 +724,7 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_authorization_rule.metadata['url'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -701,10 +732,9 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -715,8 +745,7 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements 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( @@ -729,31 +758,28 @@ def get_authorization_rule( ) -> _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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -761,7 +787,7 @@ def get_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -769,10 +795,9 @@ def get_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -780,15 +805,14 @@ def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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( @@ -801,31 +825,28 @@ def list_keys( ) -> _models.AccessKeys: """Primary and secondary connection strings to the queue. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -833,7 +854,7 @@ def list_keys( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -841,10 +862,9 @@ def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -852,17 +872,16 @@ def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 - + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore - @distributed_trace + @overload def regenerate_keys( self, resource_group_name: str, @@ -870,39 +889,114 @@ def regenerate_keys( queue_name: str, authorization_rule_name: str, parameters: _models.RegenerateAccessKeyParameters, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.RegenerateAccessKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2022_01_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateAccessKeyParameters, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: + ~azure.mgmt.servicebus.v2022_01_01_preview.models.RegenerateAccessKeyParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2022_01_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateAccessKeyParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -913,7 +1007,8 @@ def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) @@ -921,10 +1016,9 @@ def regenerate_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -932,15 +1026,14 @@ def regenerate_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 - + 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( @@ -950,12 +1043,12 @@ def list_by_namespace( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable[_models.SBQueueListResult]: + ) -> Iterable["_models.SBQueue"]: """Gets the queues within a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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 @@ -965,32 +1058,30 @@ def list_by_namespace( 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.v2022_01_01_preview.models.SBQueueListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either SBQueue or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.SBQueue] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBQueueListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + api_version=api_version, + template_url=self.list_by_namespace.metadata["url"], headers=_headers, params=_params, ) @@ -998,18 +1089,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -1025,10 +1109,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1039,49 +1121,115 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 + @overload def create_or_update( self, resource_group_name: str, namespace_name: str, queue_name: str, parameters: _models.SBQueue, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :type queue_name: str - :param parameters: Parameters supplied to create or update a queue resource. + :param parameters: Parameters supplied to create or update a queue resource. Required. :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBQueue + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBQueue, or the result of cls(response) + :return: SBQueue or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param parameters: Parameters supplied to create or update a queue resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2022_01_01_preview.models.SBQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + queue_name: str, + parameters: Union[_models.SBQueue, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param queue_name: The queue name. Required. + :type queue_name: str + :param parameters: Parameters supplied to create or update a queue resource. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBQueue or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2022_01_01_preview.models.SBQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBQueue] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBQueue] - _json = self._serialize.body(parameters, 'SBQueue') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBQueue") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -1091,7 +1239,8 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -1099,10 +1248,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1110,56 +1258,48 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBQueue', pipeline_response) + 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 - + 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: str, - namespace_name: str, - queue_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -1167,10 +1307,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1181,49 +1320,39 @@ def delete( # pylint: disable=inconsistent-return-statements 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: str, - namespace_name: str, - queue_name: str, - **kwargs: Any - ) -> _models.SBQueue: + def get(self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param queue_name: The queue name. + :param queue_name: The queue name. Required. :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) + :return: SBQueue or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBQueue] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBQueue] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -1231,10 +1360,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1242,12 +1370,11 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBQueue', pipeline_response) + 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 - + 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/v2022_01_01_preview/operations/_rules_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_rules_operations.py index 2a90c85ff18e..e6e9458999a6 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_rules_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_rules_operations.py @@ -6,11 +6,16 @@ # 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, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -20,13 +25,16 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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_subscriptions_request( resource_group_name: str, namespace_name: str, @@ -41,38 +49,37 @@ def build_list_by_subscriptions_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if skip is not None: - _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', maximum=1000, minimum=0) + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", maximum=1000, minimum=0) if top is not None: - _params['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( @@ -82,48 +89,42 @@ def build_create_or_update_request( subscription_name: str, rule_name: str, subscription_id: str, - *, - json: Optional[_models.Rule] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( @@ -138,35 +139,34 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( @@ -181,35 +181,35 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class RulesOperations: """ @@ -230,7 +230,6 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_by_subscriptions( self, @@ -241,16 +240,16 @@ def list_by_subscriptions( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable[_models.RuleListResult]: + ) -> Iterable["_models.Rule"]: """List all the rules within given topic-subscription. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :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 @@ -260,34 +259,32 @@ def list_by_subscriptions( 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.v2022_01_01_preview.models.RuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Rule or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.Rule] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.RuleListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + api_version=api_version, + template_url=self.list_by_subscriptions.metadata["url"], headers=_headers, params=_params, ) @@ -295,20 +292,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -324,10 +312,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -338,13 +324,11 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 + @overload def create_or_update( self, resource_group_name: str, @@ -353,40 +337,120 @@ def create_or_update( subscription_name: str, rule_name: str, parameters: _models.Rule, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param rule_name: The rule name. + :param rule_name: The rule name. Required. :type rule_name: str - :param parameters: Parameters supplied to create a rule. + :param parameters: Parameters supplied to create a rule. Required. :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.Rule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Rule, or the result of cls(response) + :return: Rule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.Rule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param rule_name: The rule name. Required. + :type rule_name: str + :param parameters: Parameters supplied to create a rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2022_01_01_preview.models.Rule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + rule_name: str, + parameters: Union[_models.Rule, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param rule_name: The rule name. Required. + :type rule_name: str + :param parameters: Parameters supplied to create a rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.Rule or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2022_01_01_preview.models.Rule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Rule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Rule] - _json = self._serialize.body(parameters, 'Rule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Rule") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -398,7 +462,8 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -406,10 +471,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -417,15 +481,14 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Rule', pipeline_response) + 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 - + 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 @@ -439,33 +502,30 @@ def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes an existing rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param rule_name: The rule name. + :param rule_name: The rule name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -474,7 +534,7 @@ def delete( # pylint: disable=inconsistent-return-statements rule_name=rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -482,10 +542,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -496,8 +555,7 @@ def delete( # pylint: disable=inconsistent-return-statements 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( @@ -511,33 +569,30 @@ def get( ) -> _models.Rule: """Retrieves the description for the specified rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param rule_name: The rule name. + :param rule_name: The rule name. Required. :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) + :return: Rule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.Rule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Rule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Rule] - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -546,7 +601,7 @@ def get( rule_name=rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -554,10 +609,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -565,12 +619,11 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Rule', pipeline_response) + 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 - + 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/v2022_01_01_preview/operations/_subscriptions_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_subscriptions_operations.py index 36d423236c75..0e9f0e9c6ef9 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_subscriptions_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_subscriptions_operations.py @@ -6,11 +6,16 @@ # 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, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -20,13 +25,16 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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_topic_request( resource_group_name: str, namespace_name: str, @@ -40,37 +48,36 @@ def build_list_by_topic_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if skip is not None: - _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', maximum=1000, minimum=0) + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", maximum=1000, minimum=0) if top is not None: - _params['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( @@ -79,47 +86,41 @@ def build_create_or_update_request( topic_name: str, subscription_name: str, subscription_id: str, - *, - json: Optional[_models.SBSubscription] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( @@ -133,34 +134,33 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( @@ -174,34 +174,34 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class SubscriptionsOperations: """ @@ -222,7 +222,6 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_by_topic( self, @@ -232,14 +231,14 @@ def list_by_topic( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable[_models.SBSubscriptionListResult]: + ) -> Iterable["_models.SBSubscription"]: """List all the subscriptions under a specified topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :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 @@ -249,34 +248,32 @@ def list_by_topic( 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) + :return: An iterator like instance of either SBSubscription or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.SBSubscriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.SBSubscription] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBSubscriptionListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + api_version=api_version, + template_url=self.list_by_topic.metadata["url"], headers=_headers, params=_params, ) @@ -284,19 +281,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -312,10 +301,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -326,13 +313,11 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 + @overload def create_or_update( self, resource_group_name: str, @@ -340,38 +325,112 @@ def create_or_update( topic_name: str, subscription_name: str, parameters: _models.SBSubscription, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBSubscription: """Creates a topic subscription. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :type subscription_name: str - :param parameters: Parameters supplied to create a subscription resource. + :param parameters: Parameters supplied to create a subscription resource. Required. :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBSubscription + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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.v2022_01_01_preview.models.SBSubscription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBSubscription: + """Creates a topic subscription. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param parameters: Parameters supplied to create a subscription resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2022_01_01_preview.models.SBSubscription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + subscription_name: str, + parameters: Union[_models.SBSubscription, IO], + **kwargs: Any + ) -> _models.SBSubscription: + """Creates a topic subscription. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param subscription_name: The subscription name. Required. + :type subscription_name: str + :param parameters: Parameters supplied to create a subscription resource. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBSubscription or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBSubscription, or the result of cls(response) + :return: SBSubscription or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBSubscription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBSubscription] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBSubscription] - _json = self._serialize.body(parameters, 'SBSubscription') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBSubscription") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -382,7 +441,8 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -390,10 +450,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -401,52 +460,43 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBSubscription', pipeline_response) + 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 - + 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: str, - namespace_name: str, - topic_name: str, - subscription_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -454,7 +504,7 @@ def delete( # pylint: disable=inconsistent-return-statements subscription_name=subscription_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -462,10 +512,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -476,45 +525,36 @@ def delete( # pylint: disable=inconsistent-return-statements 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: str, - namespace_name: str, - topic_name: str, - subscription_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param subscription_name: The subscription name. + :param subscription_name: The subscription name. Required. :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) + :return: SBSubscription or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBSubscription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBSubscription] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBSubscription] - request = build_get_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -522,7 +562,7 @@ def get( subscription_name=subscription_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -530,10 +570,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -541,12 +580,11 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBSubscription', pipeline_response) + 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 - + 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/v2022_01_01_preview/operations/_topics_operations.py b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_topics_operations.py index b22c057aba16..d2fc55257efc 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_topics_operations.py +++ b/sdk/servicebus/azure-mgmt-servicebus/azure/mgmt/servicebus/v2022_01_01_preview/operations/_topics_operations.py @@ -6,11 +6,16 @@ # 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, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -20,50 +25,48 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") 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 + resource_group_name: str, namespace_name: str, topic_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_authorization_rule_request( @@ -72,47 +75,43 @@ def build_create_or_update_authorization_rule_request( topic_name: str, authorization_rule_name: str, subscription_id: str, - *, - json: Optional[_models.SBAuthorizationRule] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_authorization_rule_request( @@ -126,34 +125,35 @@ def build_get_authorization_rule_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_authorization_rule_request( @@ -167,34 +167,35 @@ def build_delete_authorization_rule_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( @@ -208,34 +209,35 @@ def build_list_keys_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_regenerate_keys_request( @@ -244,47 +246,43 @@ def build_regenerate_keys_request( topic_name: str, authorization_rule_name: str, subscription_id: str, - *, - json: Optional[_models.RegenerateAccessKeyParameters] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_namespace_request( @@ -299,161 +297,141 @@ def build_list_by_namespace_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if skip is not None: - _params['$skip'] = _SERIALIZER.query("skip", skip, 'int', maximum=1000, minimum=0) + _params["$skip"] = _SERIALIZER.query("skip", skip, "int", maximum=1000, minimum=0) if top is not None: - _params['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + _params["$top"] = _SERIALIZER.query("top", top, "int", maximum=1000, minimum=1) # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_id: str, - *, - json: Optional[_models.SBTopic] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, namespace_name: str, topic_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, topic_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - namespace_name: str, - topic_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, namespace_name: str, topic_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + accept = _headers.pop("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 + _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'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", 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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class TopicsOperations: """ @@ -474,50 +452,43 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_authorization_rules( - self, - resource_group_name: str, - namespace_name: str, - topic_name: str, - **kwargs: Any - ) -> Iterable[_models.SBAuthorizationRuleListResult]: + self, resource_group_name: str, namespace_name: str, topic_name: str, **kwargs: Any + ) -> Iterable["_models.SBAuthorizationRule"]: """Gets authorization rules for a topic. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :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) + :return: An iterator like instance of either SBAuthorizationRule or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.SBAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.SBAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRuleListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_authorization_rules.metadata["url"], headers=_headers, params=_params, ) @@ -525,17 +496,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -551,10 +516,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -565,13 +528,11 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 + @overload def create_or_update_authorization_rule( self, resource_group_name: str, @@ -579,38 +540,112 @@ def create_or_update_authorization_rule( topic_name: str, authorization_rule_name: str, parameters: _models.SBAuthorizationRule, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. + :param parameters: The shared access authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBAuthorizationRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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.v2022_01_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBAuthorizationRule, or the result of cls(response) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @distributed_trace + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: Union[_models.SBAuthorizationRule, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: The shared access authorization rule. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBAuthorizationRule or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2022_01_01_preview.models.SBAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - _json = self._serialize.body(parameters, 'SBAuthorizationRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBAuthorizationRule") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -621,7 +656,8 @@ def create_or_update_authorization_rule( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_authorization_rule.metadata['url'], + content=_content, + template_url=self.create_or_update_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -629,10 +665,9 @@ def create_or_update_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -640,15 +675,14 @@ def create_or_update_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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( @@ -661,31 +695,28 @@ def get_authorization_rule( ) -> _models.SBAuthorizationRule: """Returns the specified authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: SBAuthorizationRule or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBAuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBAuthorizationRule] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBAuthorizationRule] - request = build_get_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -693,7 +724,7 @@ def get_authorization_rule( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_authorization_rule.metadata['url'], + template_url=self.get_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -701,10 +732,9 @@ def get_authorization_rule( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -712,15 +742,14 @@ def get_authorization_rule( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBAuthorizationRule', pipeline_response) + 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 - + 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 @@ -733,31 +762,28 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes a topic authorization rule. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_authorization_rule_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -765,7 +791,7 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_authorization_rule.metadata['url'], + template_url=self.delete_authorization_rule.metadata["url"], headers=_headers, params=_params, ) @@ -773,10 +799,9 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -787,8 +812,7 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements 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( @@ -801,31 +825,28 @@ def list_keys( ) -> _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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :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) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - request = build_list_keys_request( resource_group_name=resource_group_name, namespace_name=namespace_name, @@ -833,7 +854,7 @@ def list_keys( authorization_rule_name=authorization_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -841,10 +862,9 @@ def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -852,17 +872,16 @@ def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 - + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys"} # type: ignore - @distributed_trace + @overload def regenerate_keys( self, resource_group_name: str, @@ -870,39 +889,114 @@ def regenerate_keys( topic_name: str, authorization_rule_name: str, parameters: _models.RegenerateAccessKeyParameters, + *, + content_type: str = "application/json", **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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param authorization_rule_name: The authorization rule name. + :param authorization_rule_name: The authorization rule name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the authorization rule. + :param parameters: Parameters supplied to regenerate the authorization rule. Required. :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.RegenerateAccessKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) + :return: AccessKeys or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2022_01_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + authorization_rule_name: str, + parameters: Union[_models.RegenerateAccessKeyParameters, IO], + **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. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param authorization_rule_name: The authorization rule name. Required. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate the authorization rule. Is either a model + type or a IO type. Required. + :type parameters: + ~azure.mgmt.servicebus.v2022_01_01_preview.models.RegenerateAccessKeyParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2022_01_01_preview.models.AccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AccessKeys] - _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateAccessKeyParameters") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -913,7 +1007,8 @@ def regenerate_keys( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_keys.metadata['url'], + content=_content, + template_url=self.regenerate_keys.metadata["url"], headers=_headers, params=_params, ) @@ -921,10 +1016,9 @@ def regenerate_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -932,15 +1026,14 @@ def regenerate_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + 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 - + 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( @@ -950,12 +1043,12 @@ def list_by_namespace( skip: Optional[int] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable[_models.SBTopicListResult]: + ) -> Iterable["_models.SBTopic"]: """Gets all the topics in a namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :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 @@ -965,32 +1058,30 @@ def list_by_namespace( 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.v2022_01_01_preview.models.SBTopicListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either SBTopic or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicebus.v2022_01_01_preview.models.SBTopic] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBTopicListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-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", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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'], + api_version=api_version, + template_url=self.list_by_namespace.metadata["url"], headers=_headers, params=_params, ) @@ -998,18 +1089,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -1025,10 +1109,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1039,49 +1121,115 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 + @overload def create_or_update( self, resource_group_name: str, namespace_name: str, topic_name: str, parameters: _models.SBTopic, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SBTopic: """Creates a topic in the specified namespace. - :param resource_group_name: Name of the Resource group within the Azure subscription. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :type topic_name: str - :param parameters: Parameters supplied to create a topic resource. + :param parameters: Parameters supplied to create a topic resource. Required. :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBTopic + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SBTopic, or the result of cls(response) + :return: SBTopic or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBTopic - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + + @overload + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SBTopic: + """Creates a topic in the specified namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param parameters: Parameters supplied to create a topic resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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.v2022_01_01_preview.models.SBTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + topic_name: str, + parameters: Union[_models.SBTopic, IO], + **kwargs: Any + ) -> _models.SBTopic: + """Creates a topic in the specified namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. + :type resource_group_name: str + :param namespace_name: The namespace name. Required. + :type namespace_name: str + :param topic_name: The topic name. Required. + :type topic_name: str + :param parameters: Parameters supplied to create a topic resource. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBTopic or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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.v2022_01_01_preview.models.SBTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBTopic] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBTopic] - _json = self._serialize.body(parameters, 'SBTopic') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SBTopic") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -1091,7 +1239,8 @@ def create_or_update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -1099,10 +1248,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1110,56 +1258,48 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBTopic', pipeline_response) + 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 - + 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: str, - namespace_name: str, - topic_name: str, - **kwargs: Any + self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -1167,10 +1307,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1181,49 +1320,39 @@ def delete( # pylint: disable=inconsistent-return-statements 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: str, - namespace_name: str, - topic_name: str, - **kwargs: Any - ) -> _models.SBTopic: + def get(self, 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. + :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param namespace_name: The namespace name. + :param namespace_name: The namespace name. Required. :type namespace_name: str - :param topic_name: The topic name. + :param topic_name: The topic name. Required. :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) + :return: SBTopic or the result of cls(response) :rtype: ~azure.mgmt.servicebus.v2022_01_01_preview.models.SBTopic - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SBTopic] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SBTopic] - 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'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -1231,10 +1360,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1242,12 +1370,11 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SBTopic', pipeline_response) + 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 - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}"} # type: ignore diff --git a/sdk/servicebus/azure-mgmt-servicebus/tests/recordings/test_cli_mgmt_servicebus_queue.pyTestMgmtServiceBustest_queue.json b/sdk/servicebus/azure-mgmt-servicebus/tests/recordings/test_cli_mgmt_servicebus_queue.pyTestMgmtServiceBustest_queue.json index c11f2e6bccf6..c47bf1612c41 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/tests/recordings/test_cli_mgmt_servicebus_queue.pyTestMgmtServiceBustest_queue.json +++ b/sdk/servicebus/azure-mgmt-servicebus/tests/recordings/test_cli_mgmt_servicebus_queue.pyTestMgmtServiceBustest_queue.json @@ -7,7 +7,7 @@ "Accept": "*/*", "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", - "User-Agent": "azsdk-python-identity/1.11.0b4 Python/3.8.13 (Linux-5.15.0-1014-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" + "User-Agent": "azsdk-python-identity/1.11.0b4 Python/3.8.13 (Linux-5.15.0-1017-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" }, "RequestBody": null, "StatusCode": 200, @@ -16,13 +16,14 @@ "Access-Control-Allow-Origin": "*", "Cache-Control": "max-age=86400, private", "Content-Length": "1753", + "Content-Security-Policy-Report-Only": "script-src \u0027self\u0027 \u0027nonce-ZX8xTZ0Lk59Qfqu_FdCP6Q\u0027 \u0027unsafe-eval\u0027 \u0027unsafe-inline\u0027; object-src \u0027none\u0027; base-uri \u0027none\u0027; report-uri https://csp.microsoft.com/report/ESTS-UX-All", "Content-Type": "application/json; charset=utf-8", - "Date": "Wed, 10 Aug 2022 07:38:37 GMT", + "Date": "Tue, 06 Sep 2022 09:07:13 GMT", "P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022", "Set-Cookie": "[set-cookie;]", "Strict-Transport-Security": "max-age=31536000; includeSubDomains", "X-Content-Type-Options": "nosniff", - "x-ms-ests-server": "2.1.13481.9 - WUS2 ProdSlices", + "x-ms-ests-server": "2.1.13622.6 - WUS2 ProdSlices", "X-XSS-Protection": "0" }, "ResponseBody": { @@ -86,7 +87,7 @@ "email" ], "kerberos_endpoint": "https://login.microsoftonline.com/00000000-0000-0000-0000-000000000000/kerberos", - "tenant_region_scope": "NA", + "tenant_region_scope": "WW", "cloud_instance_name": "microsoftonline.com", "cloud_graph_host_name": "graph.windows.net", "msgraph_host": "graph.microsoft.com", @@ -101,7 +102,7 @@ "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", "Cookie": "cookie;", - "User-Agent": "azsdk-python-identity/1.11.0b4 Python/3.8.13 (Linux-5.15.0-1014-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" + "User-Agent": "azsdk-python-identity/1.11.0b4 Python/3.8.13 (Linux-5.15.0-1017-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" }, "RequestBody": null, "StatusCode": 200, @@ -111,12 +112,12 @@ "Cache-Control": "max-age=86400, private", "Content-Length": "945", "Content-Type": "application/json; charset=utf-8", - "Date": "Wed, 10 Aug 2022 07:38:37 GMT", + "Date": "Tue, 06 Sep 2022 09:07:13 GMT", "P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022", "Set-Cookie": "[set-cookie;]", "Strict-Transport-Security": "max-age=31536000; includeSubDomains", "X-Content-Type-Options": "nosniff", - "x-ms-ests-server": "2.1.13481.9 - WUS2 ProdSlices", + "x-ms-ests-server": "2.1.13622.4 - NCUS ProdSlices", "X-XSS-Protection": "0" }, "ResponseBody": { @@ -172,12 +173,12 @@ "RequestHeaders": { "Accept": "application/json", "Accept-Encoding": "gzip, deflate", - "client-request-id": "cc27736b-6479-42c6-af59-789c8bea5526", + "client-request-id": "3d02deab-9ca7-499a-b7fd-319ff3c94c10", "Connection": "keep-alive", "Content-Length": "288", "Content-Type": "application/x-www-form-urlencoded", "Cookie": "cookie;", - "User-Agent": "azsdk-python-identity/1.11.0b4 Python/3.8.13 (Linux-5.15.0-1014-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0", + "User-Agent": "azsdk-python-identity/1.11.0b4 Python/3.8.13 (Linux-5.15.0-1017-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0", "x-client-cpu": "x64", "x-client-current-telemetry": "4|730,0|", "x-client-last-telemetry": "4|0|||", @@ -190,10 +191,10 @@ "StatusCode": 200, "ResponseHeaders": { "Cache-Control": "no-store, no-cache", - "client-request-id": "cc27736b-6479-42c6-af59-789c8bea5526", - "Content-Length": "93", + "client-request-id": "3d02deab-9ca7-499a-b7fd-319ff3c94c10", + "Content-Length": "114", "Content-Type": "application/json; charset=utf-8", - "Date": "Wed, 10 Aug 2022 07:38:37 GMT", + "Date": "Tue, 06 Sep 2022 09:07:13 GMT", "Expires": "-1", "P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022", "Pragma": "no-cache", @@ -201,13 +202,14 @@ "Strict-Transport-Security": "max-age=31536000; includeSubDomains", "X-Content-Type-Options": "nosniff", "x-ms-clitelem": "1,0,0,,", - "x-ms-ests-server": "2.1.13418.10 - SCUS ProdSlices", + "x-ms-ests-server": "2.1.13622.6 - EUS ProdSlices", "X-XSS-Protection": "0" }, "ResponseBody": { "token_type": "Bearer", - "expires_in": 3599, - "ext_expires_in": 3599, + "expires_in": 86399, + "ext_expires_in": 86399, + "refresh_in": 43199, "access_token": "access_token" } }, @@ -220,7 +222,7 @@ "Connection": "keep-alive", "Content-Length": "117", "Content-Type": "application/json", - "User-Agent": "azsdk-python-azure-mgmt-servicebus/8.1.0 Python/3.8.13 (Linux-5.15.0-1014-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" + "User-Agent": "azsdk-python-azure-mgmt-servicebus/0.0.0 (it should be stable) Python/3.8.13 (Linux-5.15.0-1017-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" }, "RequestBody": { "location": "eastus", @@ -238,7 +240,7 @@ "Cache-Control": "no-cache", "Content-Encoding": "gzip", "Content-Type": "application/json; charset=utf-8", - "Date": "Wed, 10 Aug 2022 07:38:38 GMT", + "Date": "Tue, 06 Sep 2022 09:07:17 GMT", "Expires": "-1", "Pragma": "no-cache", "Server": [ @@ -250,9 +252,9 @@ "Transfer-Encoding": "chunked", "Vary": "Accept-Encoding", "X-Content-Type-Options": "nosniff", - "x-ms-correlation-request-id": "4b083547-2c18-40f1-9e0a-d29794fca99e", + "x-ms-correlation-request-id": "0d4c99e6-0880-4380-bef4-29238403b711", "x-ms-ratelimit-remaining-subscription-writes": "1199", - "x-ms-routing-request-id": "EASTUS2:20220810T073839Z:4b083547-2c18-40f1-9e0a-d29794fca99e" + "x-ms-routing-request-id": "WESTUS:20220906T090717Z:0d4c99e6-0880-4380-bef4-29238403b711" }, "ResponseBody": { "sku": { @@ -272,8 +274,8 @@ "zoneRedundant": false, "provisioningState": "Created", "metricId": "00000000-0000-0000-0000-000000000000:mynamespacexxyyzzybx", - "createdAt": "2022-08-10T07:38:38.457Z", - "updatedAt": "2022-08-10T07:38:38.457Z", + "createdAt": "2022-09-06T09:07:16.177Z", + "updatedAt": "2022-09-06T09:07:16.177Z", "serviceBusEndpoint": "https://myNamespacexxyyzzybx.servicebus.windows.net:443/", "status": "Activating" } @@ -286,7 +288,7 @@ "Accept": "*/*", "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", - "User-Agent": "azsdk-python-azure-mgmt-servicebus/8.1.0 Python/3.8.13 (Linux-5.15.0-1014-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" + "User-Agent": "azsdk-python-azure-mgmt-servicebus/0.0.0 (it should be stable) Python/3.8.13 (Linux-5.15.0-1017-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" }, "RequestBody": null, "StatusCode": 200, @@ -294,7 +296,7 @@ "Cache-Control": "no-cache", "Content-Encoding": "gzip", "Content-Type": "application/json; charset=utf-8", - "Date": "Wed, 10 Aug 2022 07:39:08 GMT", + "Date": "Tue, 06 Sep 2022 09:07:47 GMT", "Expires": "-1", "Pragma": "no-cache", "Server": [ @@ -306,9 +308,9 @@ "Transfer-Encoding": "chunked", "Vary": "Accept-Encoding", "X-Content-Type-Options": "nosniff", - "x-ms-correlation-request-id": "b80b9b2a-b9ec-4cb7-82da-915d99bd2794", + "x-ms-correlation-request-id": "b7132317-ebbf-4fcd-84e4-5f6321124b50", "x-ms-ratelimit-remaining-subscription-reads": "11999", - "x-ms-routing-request-id": "EASTUS2:20220810T073909Z:b80b9b2a-b9ec-4cb7-82da-915d99bd2794" + "x-ms-routing-request-id": "WESTUS:20220906T090747Z:b7132317-ebbf-4fcd-84e4-5f6321124b50" }, "ResponseBody": { "sku": { @@ -328,8 +330,8 @@ "zoneRedundant": false, "provisioningState": "Created", "metricId": "00000000-0000-0000-0000-000000000000:mynamespacexxyyzzybx", - "createdAt": "2022-08-10T07:38:38.457Z", - "updatedAt": "2022-08-10T07:38:38.457Z", + "createdAt": "2022-09-06T09:07:16.177Z", + "updatedAt": "2022-09-06T09:07:16.177Z", "serviceBusEndpoint": "https://myNamespacexxyyzzybx.servicebus.windows.net:443/", "status": "Activating" } @@ -342,7 +344,7 @@ "Accept": "*/*", "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", - "User-Agent": "azsdk-python-azure-mgmt-servicebus/8.1.0 Python/3.8.13 (Linux-5.15.0-1014-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" + "User-Agent": "azsdk-python-azure-mgmt-servicebus/0.0.0 (it should be stable) Python/3.8.13 (Linux-5.15.0-1017-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" }, "RequestBody": null, "StatusCode": 200, @@ -350,7 +352,7 @@ "Cache-Control": "no-cache", "Content-Encoding": "gzip", "Content-Type": "application/json; charset=utf-8", - "Date": "Wed, 10 Aug 2022 07:39:39 GMT", + "Date": "Tue, 06 Sep 2022 09:08:17 GMT", "Expires": "-1", "Pragma": "no-cache", "Server": [ @@ -362,9 +364,9 @@ "Transfer-Encoding": "chunked", "Vary": "Accept-Encoding", "X-Content-Type-Options": "nosniff", - "x-ms-correlation-request-id": "93d16c98-14dc-4d5f-b0b1-cf924e6c8e8c", + "x-ms-correlation-request-id": "732cc852-8b9c-444b-be20-ca06ed07101a", "x-ms-ratelimit-remaining-subscription-reads": "11998", - "x-ms-routing-request-id": "EASTUS2:20220810T073939Z:93d16c98-14dc-4d5f-b0b1-cf924e6c8e8c" + "x-ms-routing-request-id": "WESTUS:20220906T090818Z:732cc852-8b9c-444b-be20-ca06ed07101a" }, "ResponseBody": { "sku": { @@ -384,8 +386,8 @@ "zoneRedundant": false, "provisioningState": "Succeeded", "metricId": "00000000-0000-0000-0000-000000000000:mynamespacexxyyzzybx", - "createdAt": "2022-08-10T07:38:38.457Z", - "updatedAt": "2022-08-10T07:39:22.887Z", + "createdAt": "2022-09-06T09:07:16.177Z", + "updatedAt": "2022-09-06T09:08:04.05Z", "serviceBusEndpoint": "https://myNamespacexxyyzzybx.servicebus.windows.net:443/", "status": "Active" } @@ -400,7 +402,7 @@ "Connection": "keep-alive", "Content-Length": "44", "Content-Type": "application/json", - "User-Agent": "azsdk-python-azure-mgmt-servicebus/8.1.0 Python/3.8.13 (Linux-5.15.0-1014-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" + "User-Agent": "azsdk-python-azure-mgmt-servicebus/0.0.0 (it should be stable) Python/3.8.13 (Linux-5.15.0-1017-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" }, "RequestBody": { "properties": { @@ -412,7 +414,7 @@ "Cache-Control": "no-cache", "Content-Encoding": "gzip", "Content-Type": "application/json; charset=utf-8", - "Date": "Wed, 10 Aug 2022 07:39:41 GMT", + "Date": "Tue, 06 Sep 2022 09:08:19 GMT", "Expires": "-1", "Pragma": "no-cache", "Server": "Microsoft-HTTPAPI/2.0", @@ -420,9 +422,9 @@ "Transfer-Encoding": "chunked", "Vary": "Accept-Encoding", "X-Content-Type-Options": "nosniff", - "x-ms-correlation-request-id": "15ac0e18-be25-46dc-845c-c5c7a9018d6a", + "x-ms-correlation-request-id": "d66f363f-1338-4dd7-a4e9-8c0a58516221", "x-ms-ratelimit-remaining-subscription-writes": "1198", - "x-ms-routing-request-id": "EASTUS2:20220810T073941Z:15ac0e18-be25-46dc-845c-c5c7a9018d6a" + "x-ms-routing-request-id": "WESTUS:20220906T090820Z:d66f363f-1338-4dd7-a4e9-8c0a58516221" }, "ResponseBody": { "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgname/providers/Microsoft.ServiceBus/namespaces/myNamespacexxyyzzybx/queues/myQueue", @@ -453,8 +455,8 @@ "transferMessageCount": 0, "transferDeadLetterMessageCount": 0 }, - "createdAt": "2022-08-10T07:39:41.137Z", - "updatedAt": "2022-08-10T07:39:41.243Z", + "createdAt": "2022-09-06T09:08:19.383Z", + "updatedAt": "2022-09-06T09:08:19.643Z", "accessedAt": "0001-01-01T00:00:00" } } @@ -468,7 +470,7 @@ "Connection": "keep-alive", "Content-Length": "46", "Content-Type": "application/json", - "User-Agent": "azsdk-python-azure-mgmt-servicebus/8.1.0 Python/3.8.13 (Linux-5.15.0-1014-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" + "User-Agent": "azsdk-python-azure-mgmt-servicebus/0.0.0 (it should be stable) Python/3.8.13 (Linux-5.15.0-1017-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" }, "RequestBody": { "properties": { @@ -483,7 +485,7 @@ "Cache-Control": "no-cache", "Content-Encoding": "gzip", "Content-Type": "application/json; charset=utf-8", - "Date": "Wed, 10 Aug 2022 07:39:41 GMT", + "Date": "Tue, 06 Sep 2022 09:08:19 GMT", "Expires": "-1", "Pragma": "no-cache", "Server": "Microsoft-HTTPAPI/2.0", @@ -491,9 +493,9 @@ "Transfer-Encoding": "chunked", "Vary": "Accept-Encoding", "X-Content-Type-Options": "nosniff", - "x-ms-correlation-request-id": "c5707e79-db26-4ddc-8c66-c3d3d3f9baa2", + "x-ms-correlation-request-id": "121311f3-531c-433a-8905-0def25a7356e", "x-ms-ratelimit-remaining-subscription-writes": "1197", - "x-ms-routing-request-id": "EASTUS2:20220810T073941Z:c5707e79-db26-4ddc-8c66-c3d3d3f9baa2" + "x-ms-routing-request-id": "WESTUS:20220906T090820Z:121311f3-531c-433a-8905-0def25a7356e" }, "ResponseBody": { "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgname/providers/Microsoft.ServiceBus/namespaces/myNamespacexxyyzzybx/queues/myQueue/authorizationRules/myAuthorizationRule", @@ -514,7 +516,7 @@ "Accept": "application/json", "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", - "User-Agent": "azsdk-python-azure-mgmt-servicebus/8.1.0 Python/3.8.13 (Linux-5.15.0-1014-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" + "User-Agent": "azsdk-python-azure-mgmt-servicebus/0.0.0 (it should be stable) Python/3.8.13 (Linux-5.15.0-1017-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" }, "RequestBody": null, "StatusCode": 200, @@ -522,7 +524,7 @@ "Cache-Control": "no-cache", "Content-Encoding": "gzip", "Content-Type": "application/json; charset=utf-8", - "Date": "Wed, 10 Aug 2022 07:39:41 GMT", + "Date": "Tue, 06 Sep 2022 09:08:20 GMT", "Expires": "-1", "Pragma": "no-cache", "Server": "Microsoft-HTTPAPI/2.0", @@ -530,9 +532,9 @@ "Transfer-Encoding": "chunked", "Vary": "Accept-Encoding", "X-Content-Type-Options": "nosniff", - "x-ms-correlation-request-id": "5e672805-4724-4c9d-b87d-39d962b5f903", + "x-ms-correlation-request-id": "13cef440-ac10-443c-8b3c-d7310664fa96", "x-ms-ratelimit-remaining-subscription-reads": "11997", - "x-ms-routing-request-id": "EASTUS2:20220810T073942Z:5e672805-4724-4c9d-b87d-39d962b5f903" + "x-ms-routing-request-id": "WESTUS:20220906T090820Z:13cef440-ac10-443c-8b3c-d7310664fa96" }, "ResponseBody": { "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rgname/providers/Microsoft.ServiceBus/namespaces/myNamespacexxyyzzybx/queues/myQueue/authorizationrules/myAuthorizationRule", @@ -554,7 +556,7 @@ "Accept": "application/json", "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", - "User-Agent": "azsdk-python-azure-mgmt-servicebus/8.1.0 Python/3.8.13 (Linux-5.15.0-1014-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" + "User-Agent": "azsdk-python-azure-mgmt-servicebus/0.0.0 (it should be stable) Python/3.8.13 (Linux-5.15.0-1017-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" }, "RequestBody": null, "StatusCode": 200, @@ -562,7 +564,7 @@ "Cache-Control": "no-cache", "Content-Encoding": "gzip", "Content-Type": "application/json; charset=utf-8", - "Date": "Wed, 10 Aug 2022 07:39:41 GMT", + "Date": "Tue, 06 Sep 2022 09:08:20 GMT", "Expires": "-1", "Pragma": "no-cache", "Server": "Microsoft-HTTPAPI/2.0", @@ -570,9 +572,9 @@ "Transfer-Encoding": "chunked", "Vary": "Accept-Encoding", "X-Content-Type-Options": "nosniff", - "x-ms-correlation-request-id": "aa5b1208-8810-4c89-b172-a632b58cb92c", + "x-ms-correlation-request-id": "d0e36b7a-99a3-4e35-932d-d634032c0a51", "x-ms-ratelimit-remaining-subscription-reads": "11996", - "x-ms-routing-request-id": "EASTUS2:20220810T073942Z:aa5b1208-8810-4c89-b172-a632b58cb92c" + "x-ms-routing-request-id": "WESTUS:20220906T090820Z:d0e36b7a-99a3-4e35-932d-d634032c0a51" }, "ResponseBody": { "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgname/providers/Microsoft.ServiceBus/namespaces/myNamespacexxyyzzybx/queues/myQueue", @@ -603,8 +605,8 @@ "transferMessageCount": 0, "transferDeadLetterMessageCount": 0 }, - "createdAt": "2022-08-10T07:39:41.137Z", - "updatedAt": "2022-08-10T07:39:41.91Z", + "createdAt": "2022-09-06T09:08:19.383Z", + "updatedAt": "2022-09-06T09:08:20.303Z", "accessedAt": "0001-01-01T00:00:00Z" } } @@ -618,7 +620,7 @@ "Connection": "keep-alive", "Content-Length": "25", "Content-Type": "application/json", - "User-Agent": "azsdk-python-azure-mgmt-servicebus/8.1.0 Python/3.8.13 (Linux-5.15.0-1014-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" + "User-Agent": "azsdk-python-azure-mgmt-servicebus/0.0.0 (it should be stable) Python/3.8.13 (Linux-5.15.0-1017-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" }, "RequestBody": { "keyType": "PrimaryKey" @@ -628,7 +630,7 @@ "Cache-Control": "no-cache", "Content-Encoding": "gzip", "Content-Type": "application/json; charset=utf-8", - "Date": "Wed, 10 Aug 2022 07:39:42 GMT", + "Date": "Tue, 06 Sep 2022 09:08:20 GMT", "Expires": "-1", "Pragma": "no-cache", "Server": "Microsoft-HTTPAPI/2.0", @@ -636,9 +638,9 @@ "Transfer-Encoding": "chunked", "Vary": "Accept-Encoding", "X-Content-Type-Options": "nosniff", - "x-ms-correlation-request-id": "c7d9fd25-64f7-4a06-a664-44e5b76686bd", + "x-ms-correlation-request-id": "da080f0d-f3b9-4122-8231-4989451e18ca", "x-ms-ratelimit-remaining-subscription-writes": "1199", - "x-ms-routing-request-id": "EASTUS2:20220810T073942Z:c7d9fd25-64f7-4a06-a664-44e5b76686bd" + "x-ms-routing-request-id": "WESTUS:20220906T090821Z:da080f0d-f3b9-4122-8231-4989451e18ca" }, "ResponseBody": { "primaryConnectionString": "Endpoint=sb://mynamespacexxyyzzybx.servicebus.windows.net/;SharedAccessKeyName=myAuthorizationRule;SharedAccessKey=SharedAccessKey;EntityPath=myQueue", @@ -656,7 +658,7 @@ "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", "Content-Length": "0", - "User-Agent": "azsdk-python-azure-mgmt-servicebus/8.1.0 Python/3.8.13 (Linux-5.15.0-1014-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" + "User-Agent": "azsdk-python-azure-mgmt-servicebus/0.0.0 (it should be stable) Python/3.8.13 (Linux-5.15.0-1017-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" }, "RequestBody": null, "StatusCode": 200, @@ -664,7 +666,7 @@ "Cache-Control": "no-cache", "Content-Encoding": "gzip", "Content-Type": "application/json; charset=utf-8", - "Date": "Wed, 10 Aug 2022 07:39:42 GMT", + "Date": "Tue, 06 Sep 2022 09:08:21 GMT", "Expires": "-1", "Pragma": "no-cache", "Server": "Microsoft-HTTPAPI/2.0", @@ -672,9 +674,9 @@ "Transfer-Encoding": "chunked", "Vary": "Accept-Encoding", "X-Content-Type-Options": "nosniff", - "x-ms-correlation-request-id": "8af7cfcc-e372-4350-ae5c-dc167530f44f", + "x-ms-correlation-request-id": "4ad3b5ac-d179-4ade-a8c8-0b4b1b52e6f9", "x-ms-ratelimit-remaining-subscription-writes": "1198", - "x-ms-routing-request-id": "EASTUS2:20220810T073943Z:8af7cfcc-e372-4350-ae5c-dc167530f44f" + "x-ms-routing-request-id": "WESTUS:20220906T090821Z:4ad3b5ac-d179-4ade-a8c8-0b4b1b52e6f9" }, "ResponseBody": { "primaryConnectionString": "Endpoint=sb://mynamespacexxyyzzybx.servicebus.windows.net/;SharedAccessKeyName=myAuthorizationRule;SharedAccessKey=SharedAccessKey;EntityPath=myQueue", @@ -692,22 +694,22 @@ "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", "Content-Length": "0", - "User-Agent": "azsdk-python-azure-mgmt-servicebus/8.1.0 Python/3.8.13 (Linux-5.15.0-1014-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" + "User-Agent": "azsdk-python-azure-mgmt-servicebus/0.0.0 (it should be stable) Python/3.8.13 (Linux-5.15.0-1017-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" }, "RequestBody": null, "StatusCode": 200, "ResponseHeaders": { "Cache-Control": "no-cache", "Content-Length": "0", - "Date": "Wed, 10 Aug 2022 07:39:42 GMT", + "Date": "Tue, 06 Sep 2022 09:08:21 GMT", "Expires": "-1", "Pragma": "no-cache", "Server": "Microsoft-HTTPAPI/2.0", "Strict-Transport-Security": "max-age=31536000; includeSubDomains", "X-Content-Type-Options": "nosniff", - "x-ms-correlation-request-id": "7cc6832d-43cb-4fb7-aea2-8b1f750b9b69", + "x-ms-correlation-request-id": "f4944879-e44a-4edf-9010-b29d41677741", "x-ms-ratelimit-remaining-subscription-deletes": "14999", - "x-ms-routing-request-id": "EASTUS2:20220810T073943Z:7cc6832d-43cb-4fb7-aea2-8b1f750b9b69" + "x-ms-routing-request-id": "WESTUS:20220906T090822Z:f4944879-e44a-4edf-9010-b29d41677741" }, "ResponseBody": null }, @@ -719,22 +721,22 @@ "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", "Content-Length": "0", - "User-Agent": "azsdk-python-azure-mgmt-servicebus/8.1.0 Python/3.8.13 (Linux-5.15.0-1014-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" + "User-Agent": "azsdk-python-azure-mgmt-servicebus/0.0.0 (it should be stable) Python/3.8.13 (Linux-5.15.0-1017-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" }, "RequestBody": null, "StatusCode": 200, "ResponseHeaders": { "Cache-Control": "no-cache", "Content-Length": "0", - "Date": "Wed, 10 Aug 2022 07:39:43 GMT", + "Date": "Tue, 06 Sep 2022 09:08:22 GMT", "Expires": "-1", "Pragma": "no-cache", "Server": "Microsoft-HTTPAPI/2.0", "Strict-Transport-Security": "max-age=31536000; includeSubDomains", "X-Content-Type-Options": "nosniff", - "x-ms-correlation-request-id": "59634352-71d4-47dd-b269-eb6b72275ac3", + "x-ms-correlation-request-id": "663f9537-fa31-4b57-99d0-363773d06c93", "x-ms-ratelimit-remaining-subscription-deletes": "14998", - "x-ms-routing-request-id": "EASTUS2:20220810T073943Z:59634352-71d4-47dd-b269-eb6b72275ac3" + "x-ms-routing-request-id": "WESTUS:20220906T090823Z:663f9537-fa31-4b57-99d0-363773d06c93" }, "ResponseBody": null }, @@ -746,14 +748,14 @@ "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", "Content-Length": "0", - "User-Agent": "azsdk-python-azure-mgmt-servicebus/8.1.0 Python/3.8.13 (Linux-5.15.0-1014-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" + "User-Agent": "azsdk-python-azure-mgmt-servicebus/0.0.0 (it should be stable) Python/3.8.13 (Linux-5.15.0-1017-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" }, "RequestBody": null, "StatusCode": 202, "ResponseHeaders": { "Cache-Control": "no-cache", "Content-Length": "0", - "Date": "Wed, 10 Aug 2022 07:39:44 GMT", + "Date": "Tue, 06 Sep 2022 09:08:23 GMT", "Expires": "-1", "Location": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgname/providers/Microsoft.ServiceBus/namespaces/myNamespacexxyyzzybx/operationresults/myNamespacexxyyzzybx?api-version=2021-11-01", "Pragma": "no-cache", @@ -764,9 +766,9 @@ "Server-SB": "Service-Bus-Resource-Provider/SN1", "Strict-Transport-Security": "max-age=31536000; includeSubDomains", "X-Content-Type-Options": "nosniff", - "x-ms-correlation-request-id": "35a7ec53-3091-4eac-8e17-8f2493d71a29", + "x-ms-correlation-request-id": "7a5745c2-41dc-4c23-81a0-e0412827e027", "x-ms-ratelimit-remaining-subscription-deletes": "14997", - "x-ms-routing-request-id": "EASTUS2:20220810T073945Z:35a7ec53-3091-4eac-8e17-8f2493d71a29" + "x-ms-routing-request-id": "WESTUS:20220906T090824Z:7a5745c2-41dc-4c23-81a0-e0412827e027" }, "ResponseBody": null }, @@ -777,14 +779,14 @@ "Accept": "*/*", "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", - "User-Agent": "azsdk-python-azure-mgmt-servicebus/8.1.0 Python/3.8.13 (Linux-5.15.0-1014-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" + "User-Agent": "azsdk-python-azure-mgmt-servicebus/0.0.0 (it should be stable) Python/3.8.13 (Linux-5.15.0-1017-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" }, "RequestBody": null, "StatusCode": 200, "ResponseHeaders": { "Cache-Control": "no-cache", "Content-Length": "0", - "Date": "Wed, 10 Aug 2022 07:40:15 GMT", + "Date": "Tue, 06 Sep 2022 09:08:54 GMT", "Expires": "-1", "Pragma": "no-cache", "Server": [ @@ -794,9 +796,9 @@ "Server-SB": "Service-Bus-Resource-Provider/SN1", "Strict-Transport-Security": "max-age=31536000; includeSubDomains", "X-Content-Type-Options": "nosniff", - "x-ms-correlation-request-id": "7fb92471-710d-4873-9005-cc587e8bee73", + "x-ms-correlation-request-id": "025a1a88-772f-4094-8cc9-9e9a4d164722", "x-ms-ratelimit-remaining-subscription-reads": "11995", - "x-ms-routing-request-id": "EASTUS2:20220810T074015Z:7fb92471-710d-4873-9005-cc587e8bee73" + "x-ms-routing-request-id": "WESTUS:20220906T090854Z:025a1a88-772f-4094-8cc9-9e9a4d164722" }, "ResponseBody": null } diff --git a/sdk/servicebus/azure-mgmt-servicebus/tests/recordings/test_cli_mgmt_servicebus_topic.pyTestMgmtServiceBustest_subscrpition_and_rule.json b/sdk/servicebus/azure-mgmt-servicebus/tests/recordings/test_cli_mgmt_servicebus_topic.pyTestMgmtServiceBustest_subscrpition_and_rule.json index b9ff7ddecafb..3127f92e7c5b 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/tests/recordings/test_cli_mgmt_servicebus_topic.pyTestMgmtServiceBustest_subscrpition_and_rule.json +++ b/sdk/servicebus/azure-mgmt-servicebus/tests/recordings/test_cli_mgmt_servicebus_topic.pyTestMgmtServiceBustest_subscrpition_and_rule.json @@ -7,7 +7,7 @@ "Accept": "*/*", "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", - "User-Agent": "azsdk-python-identity/1.11.0b4 Python/3.8.13 (Linux-5.15.0-1014-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" + "User-Agent": "azsdk-python-identity/1.11.0b4 Python/3.8.13 (Linux-5.15.0-1017-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" }, "RequestBody": null, "StatusCode": 200, @@ -16,13 +16,14 @@ "Access-Control-Allow-Origin": "*", "Cache-Control": "max-age=86400, private", "Content-Length": "1753", + "Content-Security-Policy-Report-Only": "script-src \u0027self\u0027 \u0027nonce-i2UiOZqVLb2C-Ye4kuhv5g\u0027 \u0027unsafe-eval\u0027 \u0027unsafe-inline\u0027; object-src \u0027none\u0027; base-uri \u0027none\u0027; report-uri https://csp.microsoft.com/report/ESTS-UX-All", "Content-Type": "application/json; charset=utf-8", - "Date": "Wed, 10 Aug 2022 07:40:22 GMT", + "Date": "Tue, 06 Sep 2022 09:08:58 GMT", "P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022", "Set-Cookie": "[set-cookie;]", "Strict-Transport-Security": "max-age=31536000; includeSubDomains", "X-Content-Type-Options": "nosniff", - "x-ms-ests-server": "2.1.13418.10 - NCUS ProdSlices", + "x-ms-ests-server": "2.1.13622.6 - WUS2 ProdSlices", "X-XSS-Protection": "0" }, "ResponseBody": { @@ -86,7 +87,7 @@ "email" ], "kerberos_endpoint": "https://login.microsoftonline.com/00000000-0000-0000-0000-000000000000/kerberos", - "tenant_region_scope": "NA", + "tenant_region_scope": "WW", "cloud_instance_name": "microsoftonline.com", "cloud_graph_host_name": "graph.windows.net", "msgraph_host": "graph.microsoft.com", @@ -101,7 +102,7 @@ "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", "Cookie": "cookie;", - "User-Agent": "azsdk-python-identity/1.11.0b4 Python/3.8.13 (Linux-5.15.0-1014-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" + "User-Agent": "azsdk-python-identity/1.11.0b4 Python/3.8.13 (Linux-5.15.0-1017-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" }, "RequestBody": null, "StatusCode": 200, @@ -111,12 +112,12 @@ "Cache-Control": "max-age=86400, private", "Content-Length": "945", "Content-Type": "application/json; charset=utf-8", - "Date": "Wed, 10 Aug 2022 07:40:22 GMT", + "Date": "Tue, 06 Sep 2022 09:08:58 GMT", "P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022", "Set-Cookie": "[set-cookie;]", "Strict-Transport-Security": "max-age=31536000; includeSubDomains", "X-Content-Type-Options": "nosniff", - "x-ms-ests-server": "2.1.13418.10 - SCUS ProdSlices", + "x-ms-ests-server": "2.1.13562.12 - EUS ProdSlices", "X-XSS-Protection": "0" }, "ResponseBody": { @@ -172,12 +173,12 @@ "RequestHeaders": { "Accept": "application/json", "Accept-Encoding": "gzip, deflate", - "client-request-id": "019e1cff-9f15-4eae-96e7-cb610617cf34", + "client-request-id": "1f4921c7-9c9c-43c2-82a8-c3a7f4c971c1", "Connection": "keep-alive", "Content-Length": "288", "Content-Type": "application/x-www-form-urlencoded", "Cookie": "cookie;", - "User-Agent": "azsdk-python-identity/1.11.0b4 Python/3.8.13 (Linux-5.15.0-1014-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0", + "User-Agent": "azsdk-python-identity/1.11.0b4 Python/3.8.13 (Linux-5.15.0-1017-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0", "x-client-cpu": "x64", "x-client-current-telemetry": "4|730,0|", "x-client-last-telemetry": "4|0|||", @@ -190,10 +191,10 @@ "StatusCode": 200, "ResponseHeaders": { "Cache-Control": "no-store, no-cache", - "client-request-id": "019e1cff-9f15-4eae-96e7-cb610617cf34", - "Content-Length": "93", + "client-request-id": "1f4921c7-9c9c-43c2-82a8-c3a7f4c971c1", + "Content-Length": "114", "Content-Type": "application/json; charset=utf-8", - "Date": "Wed, 10 Aug 2022 07:40:22 GMT", + "Date": "Tue, 06 Sep 2022 09:08:58 GMT", "Expires": "-1", "P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022", "Pragma": "no-cache", @@ -201,13 +202,14 @@ "Strict-Transport-Security": "max-age=31536000; includeSubDomains", "X-Content-Type-Options": "nosniff", "x-ms-clitelem": "1,0,0,,", - "x-ms-ests-server": "2.1.13418.10 - EUS ProdSlices", + "x-ms-ests-server": "2.1.13622.6 - SCUS ProdSlices", "X-XSS-Protection": "0" }, "ResponseBody": { "token_type": "Bearer", - "expires_in": 3599, - "ext_expires_in": 3599, + "expires_in": 86399, + "ext_expires_in": 86399, + "refresh_in": 43199, "access_token": "access_token" } }, @@ -220,7 +222,7 @@ "Connection": "keep-alive", "Content-Length": "117", "Content-Type": "application/json", - "User-Agent": "azsdk-python-azure-mgmt-servicebus/8.1.0 Python/3.8.13 (Linux-5.15.0-1014-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" + "User-Agent": "azsdk-python-azure-mgmt-servicebus/0.0.0 (it should be stable) Python/3.8.13 (Linux-5.15.0-1017-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" }, "RequestBody": { "location": "eastus", @@ -238,7 +240,7 @@ "Cache-Control": "no-cache", "Content-Encoding": "gzip", "Content-Type": "application/json; charset=utf-8", - "Date": "Wed, 10 Aug 2022 07:40:23 GMT", + "Date": "Tue, 06 Sep 2022 09:09:00 GMT", "Expires": "-1", "Pragma": "no-cache", "Server": [ @@ -250,9 +252,9 @@ "Transfer-Encoding": "chunked", "Vary": "Accept-Encoding", "X-Content-Type-Options": "nosniff", - "x-ms-correlation-request-id": "c358e3a7-6138-4d17-988a-6b647e39f1f3", + "x-ms-correlation-request-id": "6b951a51-367e-4171-9ae3-ece19ef42ec3", "x-ms-ratelimit-remaining-subscription-writes": "1196", - "x-ms-routing-request-id": "EASTUS2:20220810T074024Z:c358e3a7-6138-4d17-988a-6b647e39f1f3" + "x-ms-routing-request-id": "WESTUS:20220906T090901Z:6b951a51-367e-4171-9ae3-ece19ef42ec3" }, "ResponseBody": { "sku": { @@ -272,8 +274,8 @@ "zoneRedundant": false, "provisioningState": "Created", "metricId": "00000000-0000-0000-0000-000000000000:mynamespacexxyyzzxyye", - "createdAt": "2022-08-10T07:40:23.5Z", - "updatedAt": "2022-08-10T07:40:23.5Z", + "createdAt": "2022-09-06T09:09:00.807Z", + "updatedAt": "2022-09-06T09:09:00.807Z", "serviceBusEndpoint": "https://myNamespacexxyyzzxyye.servicebus.windows.net:443/", "status": "Activating" } @@ -286,7 +288,7 @@ "Accept": "*/*", "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", - "User-Agent": "azsdk-python-azure-mgmt-servicebus/8.1.0 Python/3.8.13 (Linux-5.15.0-1014-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" + "User-Agent": "azsdk-python-azure-mgmt-servicebus/0.0.0 (it should be stable) Python/3.8.13 (Linux-5.15.0-1017-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" }, "RequestBody": null, "StatusCode": 200, @@ -294,7 +296,7 @@ "Cache-Control": "no-cache", "Content-Encoding": "gzip", "Content-Type": "application/json; charset=utf-8", - "Date": "Wed, 10 Aug 2022 07:40:54 GMT", + "Date": "Tue, 06 Sep 2022 09:09:31 GMT", "Expires": "-1", "Pragma": "no-cache", "Server": [ @@ -306,9 +308,9 @@ "Transfer-Encoding": "chunked", "Vary": "Accept-Encoding", "X-Content-Type-Options": "nosniff", - "x-ms-correlation-request-id": "44d7d325-bd3a-4dd1-bcc8-d923490f98c6", + "x-ms-correlation-request-id": "6e5287f2-d3a2-4526-b459-8d8b30686630", "x-ms-ratelimit-remaining-subscription-reads": "11994", - "x-ms-routing-request-id": "EASTUS2:20220810T074054Z:44d7d325-bd3a-4dd1-bcc8-d923490f98c6" + "x-ms-routing-request-id": "WESTUS:20220906T090932Z:6e5287f2-d3a2-4526-b459-8d8b30686630" }, "ResponseBody": { "sku": { @@ -328,8 +330,8 @@ "zoneRedundant": false, "provisioningState": "Created", "metricId": "00000000-0000-0000-0000-000000000000:mynamespacexxyyzzxyye", - "createdAt": "2022-08-10T07:40:23.5Z", - "updatedAt": "2022-08-10T07:40:23.5Z", + "createdAt": "2022-09-06T09:09:00.807Z", + "updatedAt": "2022-09-06T09:09:00.807Z", "serviceBusEndpoint": "https://myNamespacexxyyzzxyye.servicebus.windows.net:443/", "status": "Activating" } @@ -342,7 +344,7 @@ "Accept": "*/*", "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", - "User-Agent": "azsdk-python-azure-mgmt-servicebus/8.1.0 Python/3.8.13 (Linux-5.15.0-1014-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" + "User-Agent": "azsdk-python-azure-mgmt-servicebus/0.0.0 (it should be stable) Python/3.8.13 (Linux-5.15.0-1017-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" }, "RequestBody": null, "StatusCode": 200, @@ -350,7 +352,7 @@ "Cache-Control": "no-cache", "Content-Encoding": "gzip", "Content-Type": "application/json; charset=utf-8", - "Date": "Wed, 10 Aug 2022 07:41:23 GMT", + "Date": "Tue, 06 Sep 2022 09:10:02 GMT", "Expires": "-1", "Pragma": "no-cache", "Server": [ @@ -362,9 +364,9 @@ "Transfer-Encoding": "chunked", "Vary": "Accept-Encoding", "X-Content-Type-Options": "nosniff", - "x-ms-correlation-request-id": "ee06fb19-1297-4e1e-8afd-b9a1362ebe69", + "x-ms-correlation-request-id": "f3ca0bae-ec4e-4bcb-8654-3327559da8dd", "x-ms-ratelimit-remaining-subscription-reads": "11993", - "x-ms-routing-request-id": "EASTUS2:20220810T074124Z:ee06fb19-1297-4e1e-8afd-b9a1362ebe69" + "x-ms-routing-request-id": "WESTUS:20220906T091002Z:f3ca0bae-ec4e-4bcb-8654-3327559da8dd" }, "ResponseBody": { "sku": { @@ -384,8 +386,8 @@ "zoneRedundant": false, "provisioningState": "Succeeded", "metricId": "00000000-0000-0000-0000-000000000000:mynamespacexxyyzzxyye", - "createdAt": "2022-08-10T07:40:23.5Z", - "updatedAt": "2022-08-10T07:41:07.82Z", + "createdAt": "2022-09-06T09:09:00.807Z", + "updatedAt": "2022-09-06T09:09:48.623Z", "serviceBusEndpoint": "https://myNamespacexxyyzzxyye.servicebus.windows.net:443/", "status": "Active" } @@ -400,7 +402,7 @@ "Connection": "keep-alive", "Content-Length": "39", "Content-Type": "application/json", - "User-Agent": "azsdk-python-azure-mgmt-servicebus/8.1.0 Python/3.8.13 (Linux-5.15.0-1014-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" + "User-Agent": "azsdk-python-azure-mgmt-servicebus/0.0.0 (it should be stable) Python/3.8.13 (Linux-5.15.0-1017-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" }, "RequestBody": { "properties": { @@ -412,7 +414,7 @@ "Cache-Control": "no-cache", "Content-Encoding": "gzip", "Content-Type": "application/json; charset=utf-8", - "Date": "Wed, 10 Aug 2022 07:41:25 GMT", + "Date": "Tue, 06 Sep 2022 09:10:03 GMT", "Expires": "-1", "Pragma": "no-cache", "Server": "Microsoft-HTTPAPI/2.0", @@ -420,9 +422,9 @@ "Transfer-Encoding": "chunked", "Vary": "Accept-Encoding", "X-Content-Type-Options": "nosniff", - "x-ms-correlation-request-id": "69a4d415-2464-4e94-8f85-f1f76551173e", + "x-ms-correlation-request-id": "adc59365-07ca-4a46-ace8-d97ed12140a0", "x-ms-ratelimit-remaining-subscription-writes": "1195", - "x-ms-routing-request-id": "EASTUS2:20220810T074126Z:69a4d415-2464-4e94-8f85-f1f76551173e" + "x-ms-routing-request-id": "WESTUS:20220906T091004Z:adc59365-07ca-4a46-ace8-d97ed12140a0" }, "ResponseBody": { "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgname/providers/Microsoft.ServiceBus/namespaces/myNamespacexxyyzzxyye/topics/myTopic", @@ -442,8 +444,8 @@ "autoDeleteOnIdle": "P10675199DT2H48M5.4775807S", "enablePartitioning": false, "enableExpress": true, - "createdAt": "2022-08-10T07:41:25.853Z", - "updatedAt": "2022-08-10T07:41:25.953Z", + "createdAt": "2022-09-06T09:10:03.893Z", + "updatedAt": "2022-09-06T09:10:03.943Z", "accessedAt": "0001-01-01T00:00:00", "subscriptionCount": 0, "countDetails": { @@ -465,7 +467,7 @@ "Connection": "keep-alive", "Content-Length": "49", "Content-Type": "application/json", - "User-Agent": "azsdk-python-azure-mgmt-servicebus/8.1.0 Python/3.8.13 (Linux-5.15.0-1014-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" + "User-Agent": "azsdk-python-azure-mgmt-servicebus/0.0.0 (it should be stable) Python/3.8.13 (Linux-5.15.0-1017-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" }, "RequestBody": { "properties": { @@ -477,7 +479,7 @@ "Cache-Control": "no-cache", "Content-Encoding": "gzip", "Content-Type": "application/json; charset=utf-8", - "Date": "Wed, 10 Aug 2022 07:41:27 GMT", + "Date": "Tue, 06 Sep 2022 09:10:05 GMT", "Expires": "-1", "Pragma": "no-cache", "Server": "Microsoft-HTTPAPI/2.0", @@ -485,9 +487,9 @@ "Transfer-Encoding": "chunked", "Vary": "Accept-Encoding", "X-Content-Type-Options": "nosniff", - "x-ms-correlation-request-id": "ba48436c-e00f-413b-899e-93bcbe2c55b7", + "x-ms-correlation-request-id": "2b5fa8fa-3167-4ac1-900e-2bf571b3fe89", "x-ms-ratelimit-remaining-subscription-writes": "1194", - "x-ms-routing-request-id": "EASTUS2:20220810T074128Z:ba48436c-e00f-413b-899e-93bcbe2c55b7" + "x-ms-routing-request-id": "WESTUS:20220906T091005Z:2b5fa8fa-3167-4ac1-900e-2bf571b3fe89" }, "ResponseBody": { "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgname/providers/Microsoft.ServiceBus/namespaces/myNamespacexxyyzzxyye/topics/myTopic/subscriptions/mySubscription", @@ -505,8 +507,8 @@ "maxDeliveryCount": 10, "status": "Active", "enableBatchedOperations": true, - "createdAt": "2022-08-10T07:41:27.5024915Z", - "updatedAt": "2022-08-10T07:41:27.5024915Z", + "createdAt": "2022-09-06T09:10:05.6466245Z", + "updatedAt": "2022-09-06T09:10:05.6466245Z", "accessedAt": "0001-01-01T00:00:00", "countDetails": { "activeMessageCount": 0, @@ -528,7 +530,7 @@ "Connection": "keep-alive", "Content-Length": "2", "Content-Type": "application/json", - "User-Agent": "azsdk-python-azure-mgmt-servicebus/8.1.0 Python/3.8.13 (Linux-5.15.0-1014-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" + "User-Agent": "azsdk-python-azure-mgmt-servicebus/0.0.0 (it should be stable) Python/3.8.13 (Linux-5.15.0-1017-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" }, "RequestBody": {}, "StatusCode": 200, @@ -536,7 +538,7 @@ "Cache-Control": "no-cache", "Content-Encoding": "gzip", "Content-Type": "application/json; charset=utf-8", - "Date": "Wed, 10 Aug 2022 07:41:28 GMT", + "Date": "Tue, 06 Sep 2022 09:10:06 GMT", "Expires": "-1", "Pragma": "no-cache", "Server": "Microsoft-HTTPAPI/2.0", @@ -544,9 +546,9 @@ "Transfer-Encoding": "chunked", "Vary": "Accept-Encoding", "X-Content-Type-Options": "nosniff", - "x-ms-correlation-request-id": "9892fc3e-1a56-48c4-963c-f68947bb8e33", + "x-ms-correlation-request-id": "d1ccd4c7-ddc7-4a54-bfaa-7120428b43b9", "x-ms-ratelimit-remaining-subscription-writes": "1193", - "x-ms-routing-request-id": "EASTUS2:20220810T074129Z:9892fc3e-1a56-48c4-963c-f68947bb8e33" + "x-ms-routing-request-id": "WESTUS:20220906T091007Z:d1ccd4c7-ddc7-4a54-bfaa-7120428b43b9" }, "ResponseBody": { "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgname/providers/Microsoft.ServiceBus/namespaces/myNamespacexxyyzzxyye/topics/myTopic/subscriptions/mySubscription/rules/myRule", @@ -570,7 +572,7 @@ "Accept": "application/json", "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", - "User-Agent": "azsdk-python-azure-mgmt-servicebus/8.1.0 Python/3.8.13 (Linux-5.15.0-1014-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" + "User-Agent": "azsdk-python-azure-mgmt-servicebus/0.0.0 (it should be stable) Python/3.8.13 (Linux-5.15.0-1017-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" }, "RequestBody": null, "StatusCode": 200, @@ -578,7 +580,7 @@ "Cache-Control": "no-cache", "Content-Encoding": "gzip", "Content-Type": "application/json; charset=utf-8", - "Date": "Wed, 10 Aug 2022 07:41:28 GMT", + "Date": "Tue, 06 Sep 2022 09:10:06 GMT", "Expires": "-1", "Pragma": "no-cache", "Server": "Microsoft-HTTPAPI/2.0", @@ -586,9 +588,9 @@ "Transfer-Encoding": "chunked", "Vary": "Accept-Encoding", "X-Content-Type-Options": "nosniff", - "x-ms-correlation-request-id": "488fc438-f9c5-46b8-960d-466e9c341cc8", + "x-ms-correlation-request-id": "e02dfb0e-89dc-43c5-9deb-a4f99c927310", "x-ms-ratelimit-remaining-subscription-reads": "11992", - "x-ms-routing-request-id": "EASTUS2:20220810T074129Z:488fc438-f9c5-46b8-960d-466e9c341cc8" + "x-ms-routing-request-id": "WESTUS:20220906T091007Z:e02dfb0e-89dc-43c5-9deb-a4f99c927310" }, "ResponseBody": { "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgname/providers/Microsoft.ServiceBus/namespaces/myNamespacexxyyzzxyye/topics/myTopic/subscriptions/mySubscription", @@ -606,9 +608,9 @@ "maxDeliveryCount": 10, "status": "Active", "enableBatchedOperations": true, - "createdAt": "2022-08-10T07:41:27.5055751Z", - "updatedAt": "2022-08-10T07:41:27.5055751Z", - "accessedAt": "2022-08-10T07:41:27.507Z", + "createdAt": "2022-09-06T09:10:05.6483876Z", + "updatedAt": "2022-09-06T09:10:05.6483876Z", + "accessedAt": "2022-09-06T09:10:05.65Z", "countDetails": { "activeMessageCount": 0, "deadLetterMessageCount": 0, @@ -627,7 +629,7 @@ "Accept": "application/json", "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", - "User-Agent": "azsdk-python-azure-mgmt-servicebus/8.1.0 Python/3.8.13 (Linux-5.15.0-1014-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" + "User-Agent": "azsdk-python-azure-mgmt-servicebus/0.0.0 (it should be stable) Python/3.8.13 (Linux-5.15.0-1017-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" }, "RequestBody": null, "StatusCode": 200, @@ -635,7 +637,7 @@ "Cache-Control": "no-cache", "Content-Encoding": "gzip", "Content-Type": "application/json; charset=utf-8", - "Date": "Wed, 10 Aug 2022 07:41:28 GMT", + "Date": "Tue, 06 Sep 2022 09:10:07 GMT", "Expires": "-1", "Pragma": "no-cache", "Server": "Microsoft-HTTPAPI/2.0", @@ -643,9 +645,9 @@ "Transfer-Encoding": "chunked", "Vary": "Accept-Encoding", "X-Content-Type-Options": "nosniff", - "x-ms-correlation-request-id": "657eb57c-9af8-4138-9585-eeec1611c158", + "x-ms-correlation-request-id": "4ce5aacf-6c87-46db-904c-43e7f039be5f", "x-ms-ratelimit-remaining-subscription-reads": "11991", - "x-ms-routing-request-id": "EASTUS2:20220810T074129Z:657eb57c-9af8-4138-9585-eeec1611c158" + "x-ms-routing-request-id": "WESTUS:20220906T091007Z:4ce5aacf-6c87-46db-904c-43e7f039be5f" }, "ResponseBody": { "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgname/providers/Microsoft.ServiceBus/namespaces/myNamespacexxyyzzxyye/topics/myTopic/subscriptions/mySubscription/rules/myRule", @@ -670,22 +672,22 @@ "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", "Content-Length": "0", - "User-Agent": "azsdk-python-azure-mgmt-servicebus/8.1.0 Python/3.8.13 (Linux-5.15.0-1014-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" + "User-Agent": "azsdk-python-azure-mgmt-servicebus/0.0.0 (it should be stable) Python/3.8.13 (Linux-5.15.0-1017-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" }, "RequestBody": null, "StatusCode": 200, "ResponseHeaders": { "Cache-Control": "no-cache", "Content-Length": "0", - "Date": "Wed, 10 Aug 2022 07:41:29 GMT", + "Date": "Tue, 06 Sep 2022 09:10:07 GMT", "Expires": "-1", "Pragma": "no-cache", "Server": "Microsoft-HTTPAPI/2.0", "Strict-Transport-Security": "max-age=31536000; includeSubDomains", "X-Content-Type-Options": "nosniff", - "x-ms-correlation-request-id": "01f4935b-21d3-4da8-9f4a-a09e8e206f65", + "x-ms-correlation-request-id": "bbfdde8b-733e-4512-bdaf-79f50c491a3e", "x-ms-ratelimit-remaining-subscription-deletes": "14996", - "x-ms-routing-request-id": "EASTUS2:20220810T074129Z:01f4935b-21d3-4da8-9f4a-a09e8e206f65" + "x-ms-routing-request-id": "WESTUS:20220906T091007Z:bbfdde8b-733e-4512-bdaf-79f50c491a3e" }, "ResponseBody": null }, @@ -697,22 +699,22 @@ "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", "Content-Length": "0", - "User-Agent": "azsdk-python-azure-mgmt-servicebus/8.1.0 Python/3.8.13 (Linux-5.15.0-1014-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" + "User-Agent": "azsdk-python-azure-mgmt-servicebus/0.0.0 (it should be stable) Python/3.8.13 (Linux-5.15.0-1017-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" }, "RequestBody": null, "StatusCode": 200, "ResponseHeaders": { "Cache-Control": "no-cache", "Content-Length": "0", - "Date": "Wed, 10 Aug 2022 07:41:29 GMT", + "Date": "Tue, 06 Sep 2022 09:10:07 GMT", "Expires": "-1", "Pragma": "no-cache", "Server": "Microsoft-HTTPAPI/2.0", "Strict-Transport-Security": "max-age=31536000; includeSubDomains", "X-Content-Type-Options": "nosniff", - "x-ms-correlation-request-id": "489497a8-3cca-4e2b-9d2e-4589361a1966", + "x-ms-correlation-request-id": "5e85936e-6dbf-4517-944c-642251c8cb46", "x-ms-ratelimit-remaining-subscription-deletes": "14995", - "x-ms-routing-request-id": "EASTUS2:20220810T074129Z:489497a8-3cca-4e2b-9d2e-4589361a1966" + "x-ms-routing-request-id": "WESTUS:20220906T091008Z:5e85936e-6dbf-4517-944c-642251c8cb46" }, "ResponseBody": null }, @@ -724,22 +726,22 @@ "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", "Content-Length": "0", - "User-Agent": "azsdk-python-azure-mgmt-servicebus/8.1.0 Python/3.8.13 (Linux-5.15.0-1014-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" + "User-Agent": "azsdk-python-azure-mgmt-servicebus/0.0.0 (it should be stable) Python/3.8.13 (Linux-5.15.0-1017-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" }, "RequestBody": null, "StatusCode": 200, "ResponseHeaders": { "Cache-Control": "no-cache", "Content-Length": "0", - "Date": "Wed, 10 Aug 2022 07:41:29 GMT", + "Date": "Tue, 06 Sep 2022 09:10:08 GMT", "Expires": "-1", "Pragma": "no-cache", "Server": "Microsoft-HTTPAPI/2.0", "Strict-Transport-Security": "max-age=31536000; includeSubDomains", "X-Content-Type-Options": "nosniff", - "x-ms-correlation-request-id": "ed4493cc-d63a-4beb-9be3-0c1f32f2ca0a", + "x-ms-correlation-request-id": "6db62de3-d37b-41f7-a979-f78e97e693d9", "x-ms-ratelimit-remaining-subscription-deletes": "14994", - "x-ms-routing-request-id": "EASTUS2:20220810T074130Z:ed4493cc-d63a-4beb-9be3-0c1f32f2ca0a" + "x-ms-routing-request-id": "WESTUS:20220906T091009Z:6db62de3-d37b-41f7-a979-f78e97e693d9" }, "ResponseBody": null }, @@ -751,14 +753,14 @@ "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", "Content-Length": "0", - "User-Agent": "azsdk-python-azure-mgmt-servicebus/8.1.0 Python/3.8.13 (Linux-5.15.0-1014-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" + "User-Agent": "azsdk-python-azure-mgmt-servicebus/0.0.0 (it should be stable) Python/3.8.13 (Linux-5.15.0-1017-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" }, "RequestBody": null, "StatusCode": 202, "ResponseHeaders": { "Cache-Control": "no-cache", "Content-Length": "0", - "Date": "Wed, 10 Aug 2022 07:41:30 GMT", + "Date": "Tue, 06 Sep 2022 09:10:09 GMT", "Expires": "-1", "Location": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgname/providers/Microsoft.ServiceBus/namespaces/myNamespacexxyyzzxyye/operationresults/myNamespacexxyyzzxyye?api-version=2021-11-01", "Pragma": "no-cache", @@ -769,9 +771,9 @@ "Server-SB": "Service-Bus-Resource-Provider/SN1", "Strict-Transport-Security": "max-age=31536000; includeSubDomains", "X-Content-Type-Options": "nosniff", - "x-ms-correlation-request-id": "138d1d36-3019-4570-b5cb-b25e4a372f6b", + "x-ms-correlation-request-id": "ed62c617-657e-4203-8521-93ba15dd0192", "x-ms-ratelimit-remaining-subscription-deletes": "14993", - "x-ms-routing-request-id": "EASTUS2:20220810T074131Z:138d1d36-3019-4570-b5cb-b25e4a372f6b" + "x-ms-routing-request-id": "WESTUS:20220906T091010Z:ed62c617-657e-4203-8521-93ba15dd0192" }, "ResponseBody": null }, @@ -782,16 +784,19 @@ "Accept": "*/*", "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", - "User-Agent": "azsdk-python-azure-mgmt-servicebus/8.1.0 Python/3.8.13 (Linux-5.15.0-1014-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" + "User-Agent": "azsdk-python-azure-mgmt-servicebus/0.0.0 (it should be stable) Python/3.8.13 (Linux-5.15.0-1017-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" }, "RequestBody": null, - "StatusCode": 200, + "StatusCode": 202, "ResponseHeaders": { "Cache-Control": "no-cache", - "Content-Length": "0", - "Date": "Wed, 10 Aug 2022 07:42:01 GMT", + "Content-Length": "669", + "Content-Type": "application/json; charset=utf-8", + "Date": "Tue, 06 Sep 2022 09:10:40 GMT", "Expires": "-1", + "Location": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgname/providers/Microsoft.ServiceBus/namespaces/myNamespacexxyyzzxyye/operationresults/myNamespacexxyyzzxyye?api-version=2021-11-01", "Pragma": "no-cache", + "Retry-After": "44", "Server": [ "Service-Bus-Resource-Provider/SN1", "Microsoft-HTTPAPI/2.0" @@ -799,11 +804,65 @@ "Server-SB": "Service-Bus-Resource-Provider/SN1", "Strict-Transport-Security": "max-age=31536000; includeSubDomains", "X-Content-Type-Options": "nosniff", - "x-ms-correlation-request-id": "30c3018a-cf51-4cd3-a3ec-da0218b15491", + "x-ms-correlation-request-id": "cd631eff-faca-4c1b-9020-024bf842aff3", "x-ms-ratelimit-remaining-subscription-reads": "11990", - "x-ms-routing-request-id": "EASTUS2:20220810T074201Z:30c3018a-cf51-4cd3-a3ec-da0218b15491" + "x-ms-routing-request-id": "WESTUS:20220906T091040Z:cd631eff-faca-4c1b-9020-024bf842aff3" }, - "ResponseBody": null + "ResponseBody": { + "sku": { + "name": "Standard", + "tier": "Standard" + }, + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgname/providers/Microsoft.ServiceBus/namespaces/myNamespacexxyyzzxyye", + "name": "myNamespacexxyyzzxyye", + "type": "Microsoft.ServiceBus/Namespaces", + "location": "East US", + "tags": { + "tag1": "value1", + "tag2": "value2" + }, + "properties": { + "disableLocalAuth": false, + "zoneRedundant": false, + "provisioningState": "Succeeded", + "metricId": "00000000-0000-0000-0000-000000000000:mynamespacexxyyzzxyye", + "createdAt": "2022-09-06T09:09:00.807Z", + "updatedAt": "2022-09-06T09:10:10.023Z", + "serviceBusEndpoint": "https://myNamespacexxyyzzxyye.servicebus.windows.net:443/", + "status": "Removing" + } + } + }, + { + "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgname/providers/Microsoft.ServiceBus/namespaces/myNamespacexxyyzzxyye/operationresults/myNamespacexxyyzzxyye?api-version=2021-11-01", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azsdk-python-azure-mgmt-servicebus/0.0.0 (it should be stable) Python/3.8.13 (Linux-5.15.0-1017-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" + }, + "RequestBody": null, + "StatusCode": 404, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "231", + "Content-Type": "application/json; charset=utf-8", + "Date": "Tue, 06 Sep 2022 09:11:24 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "d95243ff-63e1-4df9-bdbe-de9f3c829a70", + "x-ms-failure-cause": "gateway", + "x-ms-routing-request-id": "WESTUS:20220906T091125Z:d95243ff-63e1-4df9-bdbe-de9f3c829a70" + }, + "ResponseBody": { + "error": { + "code": "ResourceNotFound", + "message": "The Resource \u0027Microsoft.ServiceBus/namespaces/myNamespacexxyyzzxyye\u0027 under resource group \u0027rgname\u0027 was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix" + } + } } ], "Variables": {} diff --git a/sdk/servicebus/azure-mgmt-servicebus/tests/recordings/test_cli_mgmt_servicebus_topic.pyTestMgmtServiceBustest_topic.json b/sdk/servicebus/azure-mgmt-servicebus/tests/recordings/test_cli_mgmt_servicebus_topic.pyTestMgmtServiceBustest_topic.json index 55afbb06d5f9..d738ce47d0c6 100644 --- a/sdk/servicebus/azure-mgmt-servicebus/tests/recordings/test_cli_mgmt_servicebus_topic.pyTestMgmtServiceBustest_topic.json +++ b/sdk/servicebus/azure-mgmt-servicebus/tests/recordings/test_cli_mgmt_servicebus_topic.pyTestMgmtServiceBustest_topic.json @@ -7,7 +7,7 @@ "Accept": "*/*", "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", - "User-Agent": "azsdk-python-identity/1.11.0b4 Python/3.8.13 (Linux-5.15.0-1014-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" + "User-Agent": "azsdk-python-identity/1.11.0b4 Python/3.8.13 (Linux-5.15.0-1017-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" }, "RequestBody": null, "StatusCode": 200, @@ -16,13 +16,14 @@ "Access-Control-Allow-Origin": "*", "Cache-Control": "max-age=86400, private", "Content-Length": "1753", + "Content-Security-Policy-Report-Only": "script-src \u0027self\u0027 \u0027nonce-ZkJPLqS9dcYDgf3VLHK87g\u0027 \u0027unsafe-eval\u0027 \u0027unsafe-inline\u0027; object-src \u0027none\u0027; base-uri \u0027none\u0027; report-uri https://csp.microsoft.com/report/ESTS-UX-All", "Content-Type": "application/json; charset=utf-8", - "Date": "Wed, 10 Aug 2022 07:42:03 GMT", + "Date": "Tue, 06 Sep 2022 09:11:28 GMT", "P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022", "Set-Cookie": "[set-cookie;]", "Strict-Transport-Security": "max-age=31536000; includeSubDomains", "X-Content-Type-Options": "nosniff", - "x-ms-ests-server": "2.1.13418.10 - EUS ProdSlices", + "x-ms-ests-server": "2.1.13622.6 - WUS2 ProdSlices", "X-XSS-Protection": "0" }, "ResponseBody": { @@ -86,7 +87,7 @@ "email" ], "kerberos_endpoint": "https://login.microsoftonline.com/00000000-0000-0000-0000-000000000000/kerberos", - "tenant_region_scope": "NA", + "tenant_region_scope": "WW", "cloud_instance_name": "microsoftonline.com", "cloud_graph_host_name": "graph.windows.net", "msgraph_host": "graph.microsoft.com", @@ -101,7 +102,7 @@ "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", "Cookie": "cookie;", - "User-Agent": "azsdk-python-identity/1.11.0b4 Python/3.8.13 (Linux-5.15.0-1014-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" + "User-Agent": "azsdk-python-identity/1.11.0b4 Python/3.8.13 (Linux-5.15.0-1017-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" }, "RequestBody": null, "StatusCode": 200, @@ -111,12 +112,12 @@ "Cache-Control": "max-age=86400, private", "Content-Length": "945", "Content-Type": "application/json; charset=utf-8", - "Date": "Wed, 10 Aug 2022 07:42:03 GMT", + "Date": "Tue, 06 Sep 2022 09:11:28 GMT", "P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022", "Set-Cookie": "[set-cookie;]", "Strict-Transport-Security": "max-age=31536000; includeSubDomains", "X-Content-Type-Options": "nosniff", - "x-ms-ests-server": "2.1.13418.10 - EUS ProdSlices", + "x-ms-ests-server": "2.1.13562.12 - WUS2 ProdSlices", "X-XSS-Protection": "0" }, "ResponseBody": { @@ -172,12 +173,12 @@ "RequestHeaders": { "Accept": "application/json", "Accept-Encoding": "gzip, deflate", - "client-request-id": "2224dd6b-2b52-4724-a69b-e745800a68eb", + "client-request-id": "be5f404a-5c10-40bd-ba31-b016a7ed217c", "Connection": "keep-alive", "Content-Length": "288", "Content-Type": "application/x-www-form-urlencoded", "Cookie": "cookie;", - "User-Agent": "azsdk-python-identity/1.11.0b4 Python/3.8.13 (Linux-5.15.0-1014-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0", + "User-Agent": "azsdk-python-identity/1.11.0b4 Python/3.8.13 (Linux-5.15.0-1017-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0", "x-client-cpu": "x64", "x-client-current-telemetry": "4|730,0|", "x-client-last-telemetry": "4|0|||", @@ -190,10 +191,11 @@ "StatusCode": 200, "ResponseHeaders": { "Cache-Control": "no-store, no-cache", - "client-request-id": "2224dd6b-2b52-4724-a69b-e745800a68eb", - "Content-Length": "93", + "client-request-id": "be5f404a-5c10-40bd-ba31-b016a7ed217c", + "Content-Length": "114", + "Content-Security-Policy-Report-Only": "script-src \u0027self\u0027 \u0027nonce-qECHcnCYv11irLGQa--Dhg\u0027 \u0027unsafe-eval\u0027 \u0027unsafe-inline\u0027; object-src \u0027none\u0027; base-uri \u0027none\u0027; report-uri https://csp.microsoft.com/report/ESTS-UX-All", "Content-Type": "application/json; charset=utf-8", - "Date": "Wed, 10 Aug 2022 07:42:03 GMT", + "Date": "Tue, 06 Sep 2022 09:11:28 GMT", "Expires": "-1", "P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022", "Pragma": "no-cache", @@ -201,13 +203,14 @@ "Strict-Transport-Security": "max-age=31536000; includeSubDomains", "X-Content-Type-Options": "nosniff", "x-ms-clitelem": "1,0,0,,", - "x-ms-ests-server": "2.1.13418.10 - SCUS ProdSlices", + "x-ms-ests-server": "2.1.13622.6 - WUS2 ProdSlices", "X-XSS-Protection": "0" }, "ResponseBody": { "token_type": "Bearer", - "expires_in": 3599, - "ext_expires_in": 3599, + "expires_in": 86399, + "ext_expires_in": 86399, + "refresh_in": 43199, "access_token": "access_token" } }, @@ -220,7 +223,7 @@ "Connection": "keep-alive", "Content-Length": "117", "Content-Type": "application/json", - "User-Agent": "azsdk-python-azure-mgmt-servicebus/8.1.0 Python/3.8.13 (Linux-5.15.0-1014-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" + "User-Agent": "azsdk-python-azure-mgmt-servicebus/0.0.0 (it should be stable) Python/3.8.13 (Linux-5.15.0-1017-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" }, "RequestBody": { "location": "eastus", @@ -238,7 +241,7 @@ "Cache-Control": "no-cache", "Content-Encoding": "gzip", "Content-Type": "application/json; charset=utf-8", - "Date": "Wed, 10 Aug 2022 07:42:05 GMT", + "Date": "Tue, 06 Sep 2022 09:11:31 GMT", "Expires": "-1", "Pragma": "no-cache", "Server": [ @@ -250,9 +253,9 @@ "Transfer-Encoding": "chunked", "Vary": "Accept-Encoding", "X-Content-Type-Options": "nosniff", - "x-ms-correlation-request-id": "253165bc-7e46-4a9a-a8f1-1f66e2990d02", + "x-ms-correlation-request-id": "87610f27-fd02-4ce9-8987-d46724570191", "x-ms-ratelimit-remaining-subscription-writes": "1192", - "x-ms-routing-request-id": "EASTUS2:20220810T074205Z:253165bc-7e46-4a9a-a8f1-1f66e2990d02" + "x-ms-routing-request-id": "WESTUS:20220906T091131Z:87610f27-fd02-4ce9-8987-d46724570191" }, "ResponseBody": { "sku": { @@ -272,8 +275,8 @@ "zoneRedundant": false, "provisioningState": "Created", "metricId": "00000000-0000-0000-0000-000000000000:mynamespacexxyyzzxyyf", - "createdAt": "2022-08-10T07:42:04.623Z", - "updatedAt": "2022-08-10T07:42:04.623Z", + "createdAt": "2022-09-06T09:11:30.317Z", + "updatedAt": "2022-09-06T09:11:30.317Z", "serviceBusEndpoint": "https://myNamespacexxyyzzxyyf.servicebus.windows.net:443/", "status": "Activating" } @@ -286,7 +289,7 @@ "Accept": "*/*", "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", - "User-Agent": "azsdk-python-azure-mgmt-servicebus/8.1.0 Python/3.8.13 (Linux-5.15.0-1014-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" + "User-Agent": "azsdk-python-azure-mgmt-servicebus/0.0.0 (it should be stable) Python/3.8.13 (Linux-5.15.0-1017-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" }, "RequestBody": null, "StatusCode": 200, @@ -294,7 +297,7 @@ "Cache-Control": "no-cache", "Content-Encoding": "gzip", "Content-Type": "application/json; charset=utf-8", - "Date": "Wed, 10 Aug 2022 07:42:34 GMT", + "Date": "Tue, 06 Sep 2022 09:12:01 GMT", "Expires": "-1", "Pragma": "no-cache", "Server": [ @@ -306,9 +309,9 @@ "Transfer-Encoding": "chunked", "Vary": "Accept-Encoding", "X-Content-Type-Options": "nosniff", - "x-ms-correlation-request-id": "ed885d22-ca2e-4959-9ada-0a8a3276abfb", - "x-ms-ratelimit-remaining-subscription-reads": "11989", - "x-ms-routing-request-id": "EASTUS2:20220810T074235Z:ed885d22-ca2e-4959-9ada-0a8a3276abfb" + "x-ms-correlation-request-id": "1a5d4170-f25d-4326-9890-f6a3373139bc", + "x-ms-ratelimit-remaining-subscription-reads": "11988", + "x-ms-routing-request-id": "WESTUS:20220906T091201Z:1a5d4170-f25d-4326-9890-f6a3373139bc" }, "ResponseBody": { "sku": { @@ -328,8 +331,8 @@ "zoneRedundant": false, "provisioningState": "Created", "metricId": "00000000-0000-0000-0000-000000000000:mynamespacexxyyzzxyyf", - "createdAt": "2022-08-10T07:42:04.623Z", - "updatedAt": "2022-08-10T07:42:04.623Z", + "createdAt": "2022-09-06T09:11:30.317Z", + "updatedAt": "2022-09-06T09:11:30.317Z", "serviceBusEndpoint": "https://myNamespacexxyyzzxyyf.servicebus.windows.net:443/", "status": "Activating" } @@ -342,7 +345,7 @@ "Accept": "*/*", "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", - "User-Agent": "azsdk-python-azure-mgmt-servicebus/8.1.0 Python/3.8.13 (Linux-5.15.0-1014-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" + "User-Agent": "azsdk-python-azure-mgmt-servicebus/0.0.0 (it should be stable) Python/3.8.13 (Linux-5.15.0-1017-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" }, "RequestBody": null, "StatusCode": 200, @@ -350,7 +353,7 @@ "Cache-Control": "no-cache", "Content-Encoding": "gzip", "Content-Type": "application/json; charset=utf-8", - "Date": "Wed, 10 Aug 2022 07:43:04 GMT", + "Date": "Tue, 06 Sep 2022 09:12:31 GMT", "Expires": "-1", "Pragma": "no-cache", "Server": [ @@ -362,9 +365,9 @@ "Transfer-Encoding": "chunked", "Vary": "Accept-Encoding", "X-Content-Type-Options": "nosniff", - "x-ms-correlation-request-id": "3669c55f-5edd-47dc-a489-deedd5a64b05", - "x-ms-ratelimit-remaining-subscription-reads": "11988", - "x-ms-routing-request-id": "EASTUS2:20220810T074305Z:3669c55f-5edd-47dc-a489-deedd5a64b05" + "x-ms-correlation-request-id": "1b0463d2-bc58-4485-ac97-8aca36bfea8d", + "x-ms-ratelimit-remaining-subscription-reads": "11987", + "x-ms-routing-request-id": "WESTUS:20220906T091232Z:1b0463d2-bc58-4485-ac97-8aca36bfea8d" }, "ResponseBody": { "sku": { @@ -384,8 +387,8 @@ "zoneRedundant": false, "provisioningState": "Succeeded", "metricId": "00000000-0000-0000-0000-000000000000:mynamespacexxyyzzxyyf", - "createdAt": "2022-08-10T07:42:04.623Z", - "updatedAt": "2022-08-10T07:42:47.293Z", + "createdAt": "2022-09-06T09:11:30.317Z", + "updatedAt": "2022-09-06T09:12:16.777Z", "serviceBusEndpoint": "https://myNamespacexxyyzzxyyf.servicebus.windows.net:443/", "status": "Active" } @@ -400,7 +403,7 @@ "Connection": "keep-alive", "Content-Length": "39", "Content-Type": "application/json", - "User-Agent": "azsdk-python-azure-mgmt-servicebus/8.1.0 Python/3.8.13 (Linux-5.15.0-1014-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" + "User-Agent": "azsdk-python-azure-mgmt-servicebus/0.0.0 (it should be stable) Python/3.8.13 (Linux-5.15.0-1017-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" }, "RequestBody": { "properties": { @@ -412,7 +415,7 @@ "Cache-Control": "no-cache", "Content-Encoding": "gzip", "Content-Type": "application/json; charset=utf-8", - "Date": "Wed, 10 Aug 2022 07:43:06 GMT", + "Date": "Tue, 06 Sep 2022 09:12:33 GMT", "Expires": "-1", "Pragma": "no-cache", "Server": "Microsoft-HTTPAPI/2.0", @@ -420,9 +423,9 @@ "Transfer-Encoding": "chunked", "Vary": "Accept-Encoding", "X-Content-Type-Options": "nosniff", - "x-ms-correlation-request-id": "116749ca-8d57-4c70-8c6e-39b1bf658f0b", + "x-ms-correlation-request-id": "db6d63ef-fc7e-486e-b691-b38e4cae36d4", "x-ms-ratelimit-remaining-subscription-writes": "1191", - "x-ms-routing-request-id": "EASTUS2:20220810T074307Z:116749ca-8d57-4c70-8c6e-39b1bf658f0b" + "x-ms-routing-request-id": "WESTUS:20220906T091234Z:db6d63ef-fc7e-486e-b691-b38e4cae36d4" }, "ResponseBody": { "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgname/providers/Microsoft.ServiceBus/namespaces/myNamespacexxyyzzxyyf/topics/myTopic", @@ -442,8 +445,8 @@ "autoDeleteOnIdle": "P10675199DT2H48M5.4775807S", "enablePartitioning": false, "enableExpress": true, - "createdAt": "2022-08-10T07:43:06.987Z", - "updatedAt": "2022-08-10T07:43:07.27Z", + "createdAt": "2022-09-06T09:12:33.437Z", + "updatedAt": "2022-09-06T09:12:33.56Z", "accessedAt": "0001-01-01T00:00:00", "subscriptionCount": 0, "countDetails": { @@ -465,7 +468,7 @@ "Connection": "keep-alive", "Content-Length": "46", "Content-Type": "application/json", - "User-Agent": "azsdk-python-azure-mgmt-servicebus/8.1.0 Python/3.8.13 (Linux-5.15.0-1014-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" + "User-Agent": "azsdk-python-azure-mgmt-servicebus/0.0.0 (it should be stable) Python/3.8.13 (Linux-5.15.0-1017-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" }, "RequestBody": { "properties": { @@ -480,7 +483,7 @@ "Cache-Control": "no-cache", "Content-Encoding": "gzip", "Content-Type": "application/json; charset=utf-8", - "Date": "Wed, 10 Aug 2022 07:43:06 GMT", + "Date": "Tue, 06 Sep 2022 09:12:33 GMT", "Expires": "-1", "Pragma": "no-cache", "Server": "Microsoft-HTTPAPI/2.0", @@ -488,9 +491,9 @@ "Transfer-Encoding": "chunked", "Vary": "Accept-Encoding", "X-Content-Type-Options": "nosniff", - "x-ms-correlation-request-id": "c35b7c50-e460-44e1-ac52-3d49d816860e", + "x-ms-correlation-request-id": "f61be11f-f110-4ec6-8e96-d8a9250e3932", "x-ms-ratelimit-remaining-subscription-writes": "1190", - "x-ms-routing-request-id": "EASTUS2:20220810T074307Z:c35b7c50-e460-44e1-ac52-3d49d816860e" + "x-ms-routing-request-id": "WESTUS:20220906T091234Z:f61be11f-f110-4ec6-8e96-d8a9250e3932" }, "ResponseBody": { "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgname/providers/Microsoft.ServiceBus/namespaces/myNamespacexxyyzzxyyf/topics/myTopic/authorizationRules/myAuthorizationRule", @@ -511,7 +514,7 @@ "Accept": "application/json", "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", - "User-Agent": "azsdk-python-azure-mgmt-servicebus/8.1.0 Python/3.8.13 (Linux-5.15.0-1014-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" + "User-Agent": "azsdk-python-azure-mgmt-servicebus/0.0.0 (it should be stable) Python/3.8.13 (Linux-5.15.0-1017-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" }, "RequestBody": null, "StatusCode": 200, @@ -519,7 +522,7 @@ "Cache-Control": "no-cache", "Content-Encoding": "gzip", "Content-Type": "application/json; charset=utf-8", - "Date": "Wed, 10 Aug 2022 07:43:07 GMT", + "Date": "Tue, 06 Sep 2022 09:12:33 GMT", "Expires": "-1", "Pragma": "no-cache", "Server": "Microsoft-HTTPAPI/2.0", @@ -527,9 +530,9 @@ "Transfer-Encoding": "chunked", "Vary": "Accept-Encoding", "X-Content-Type-Options": "nosniff", - "x-ms-correlation-request-id": "2b55d4e5-e34f-4782-b10d-3019572c0612", - "x-ms-ratelimit-remaining-subscription-reads": "11987", - "x-ms-routing-request-id": "EASTUS2:20220810T074307Z:2b55d4e5-e34f-4782-b10d-3019572c0612" + "x-ms-correlation-request-id": "bc0e7274-f7e5-4bb8-af84-809f7c45ba38", + "x-ms-ratelimit-remaining-subscription-reads": "11986", + "x-ms-routing-request-id": "WESTUS:20220906T091234Z:bc0e7274-f7e5-4bb8-af84-809f7c45ba38" }, "ResponseBody": { "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rgname/providers/Microsoft.ServiceBus/namespaces/myNamespacexxyyzzxyyf/topics/myTopic/authorizationrules/myAuthorizationRule", @@ -553,7 +556,7 @@ "Connection": "keep-alive", "Content-Length": "25", "Content-Type": "application/json", - "User-Agent": "azsdk-python-azure-mgmt-servicebus/8.1.0 Python/3.8.13 (Linux-5.15.0-1014-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" + "User-Agent": "azsdk-python-azure-mgmt-servicebus/0.0.0 (it should be stable) Python/3.8.13 (Linux-5.15.0-1017-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" }, "RequestBody": { "keyType": "PrimaryKey" @@ -563,7 +566,7 @@ "Cache-Control": "no-cache", "Content-Encoding": "gzip", "Content-Type": "application/json; charset=utf-8", - "Date": "Wed, 10 Aug 2022 07:43:07 GMT", + "Date": "Tue, 06 Sep 2022 09:12:34 GMT", "Expires": "-1", "Pragma": "no-cache", "Server": "Microsoft-HTTPAPI/2.0", @@ -571,9 +574,9 @@ "Transfer-Encoding": "chunked", "Vary": "Accept-Encoding", "X-Content-Type-Options": "nosniff", - "x-ms-correlation-request-id": "e84631bf-601e-4668-b352-9e4df78e5066", + "x-ms-correlation-request-id": "a75f9f82-e550-4cf5-943e-d89d456ae548", "x-ms-ratelimit-remaining-subscription-writes": "1197", - "x-ms-routing-request-id": "EASTUS2:20220810T074307Z:e84631bf-601e-4668-b352-9e4df78e5066" + "x-ms-routing-request-id": "WESTUS:20220906T091234Z:a75f9f82-e550-4cf5-943e-d89d456ae548" }, "ResponseBody": { "primaryConnectionString": "Endpoint=sb://mynamespacexxyyzzxyyf.servicebus.windows.net/;SharedAccessKeyName=myAuthorizationRule;SharedAccessKey=SharedAccessKey;EntityPath=myTopic", @@ -591,7 +594,7 @@ "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", "Content-Length": "0", - "User-Agent": "azsdk-python-azure-mgmt-servicebus/8.1.0 Python/3.8.13 (Linux-5.15.0-1014-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" + "User-Agent": "azsdk-python-azure-mgmt-servicebus/0.0.0 (it should be stable) Python/3.8.13 (Linux-5.15.0-1017-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" }, "RequestBody": null, "StatusCode": 200, @@ -599,7 +602,7 @@ "Cache-Control": "no-cache", "Content-Encoding": "gzip", "Content-Type": "application/json; charset=utf-8", - "Date": "Wed, 10 Aug 2022 07:43:07 GMT", + "Date": "Tue, 06 Sep 2022 09:12:34 GMT", "Expires": "-1", "Pragma": "no-cache", "Server": "Microsoft-HTTPAPI/2.0", @@ -607,9 +610,9 @@ "Transfer-Encoding": "chunked", "Vary": "Accept-Encoding", "X-Content-Type-Options": "nosniff", - "x-ms-correlation-request-id": "9e1eec0d-2146-4903-a820-34a986d6660c", + "x-ms-correlation-request-id": "6e332174-dc71-4238-b505-1feedf608bbb", "x-ms-ratelimit-remaining-subscription-writes": "1196", - "x-ms-routing-request-id": "EASTUS2:20220810T074308Z:9e1eec0d-2146-4903-a820-34a986d6660c" + "x-ms-routing-request-id": "WESTUS:20220906T091235Z:6e332174-dc71-4238-b505-1feedf608bbb" }, "ResponseBody": { "primaryConnectionString": "Endpoint=sb://mynamespacexxyyzzxyyf.servicebus.windows.net/;SharedAccessKeyName=myAuthorizationRule;SharedAccessKey=SharedAccessKey;EntityPath=myTopic", @@ -627,22 +630,22 @@ "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", "Content-Length": "0", - "User-Agent": "azsdk-python-azure-mgmt-servicebus/8.1.0 Python/3.8.13 (Linux-5.15.0-1014-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" + "User-Agent": "azsdk-python-azure-mgmt-servicebus/0.0.0 (it should be stable) Python/3.8.13 (Linux-5.15.0-1017-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" }, "RequestBody": null, "StatusCode": 200, "ResponseHeaders": { "Cache-Control": "no-cache", "Content-Length": "0", - "Date": "Wed, 10 Aug 2022 07:43:07 GMT", + "Date": "Tue, 06 Sep 2022 09:12:35 GMT", "Expires": "-1", "Pragma": "no-cache", "Server": "Microsoft-HTTPAPI/2.0", "Strict-Transport-Security": "max-age=31536000; includeSubDomains", "X-Content-Type-Options": "nosniff", - "x-ms-correlation-request-id": "61d6366e-124e-49c1-9264-01eddebdc473", + "x-ms-correlation-request-id": "92849e2d-efc7-4574-986d-b573362e2ce3", "x-ms-ratelimit-remaining-subscription-deletes": "14992", - "x-ms-routing-request-id": "EASTUS2:20220810T074308Z:61d6366e-124e-49c1-9264-01eddebdc473" + "x-ms-routing-request-id": "WESTUS:20220906T091235Z:92849e2d-efc7-4574-986d-b573362e2ce3" }, "ResponseBody": null }, @@ -654,22 +657,22 @@ "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", "Content-Length": "0", - "User-Agent": "azsdk-python-azure-mgmt-servicebus/8.1.0 Python/3.8.13 (Linux-5.15.0-1014-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" + "User-Agent": "azsdk-python-azure-mgmt-servicebus/0.0.0 (it should be stable) Python/3.8.13 (Linux-5.15.0-1017-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" }, "RequestBody": null, "StatusCode": 200, "ResponseHeaders": { "Cache-Control": "no-cache", "Content-Length": "0", - "Date": "Wed, 10 Aug 2022 07:43:08 GMT", + "Date": "Tue, 06 Sep 2022 09:12:35 GMT", "Expires": "-1", "Pragma": "no-cache", "Server": "Microsoft-HTTPAPI/2.0", "Strict-Transport-Security": "max-age=31536000; includeSubDomains", "X-Content-Type-Options": "nosniff", - "x-ms-correlation-request-id": "72fdf75f-aa75-4ae5-ba94-4921c3d0a209", + "x-ms-correlation-request-id": "8f7a967b-bc15-473c-b8ea-74945d3ddd98", "x-ms-ratelimit-remaining-subscription-deletes": "14991", - "x-ms-routing-request-id": "EASTUS2:20220810T074309Z:72fdf75f-aa75-4ae5-ba94-4921c3d0a209" + "x-ms-routing-request-id": "WESTUS:20220906T091236Z:8f7a967b-bc15-473c-b8ea-74945d3ddd98" }, "ResponseBody": null }, @@ -681,14 +684,14 @@ "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", "Content-Length": "0", - "User-Agent": "azsdk-python-azure-mgmt-servicebus/8.1.0 Python/3.8.13 (Linux-5.15.0-1014-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" + "User-Agent": "azsdk-python-azure-mgmt-servicebus/0.0.0 (it should be stable) Python/3.8.13 (Linux-5.15.0-1017-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" }, "RequestBody": null, "StatusCode": 202, "ResponseHeaders": { "Cache-Control": "no-cache", "Content-Length": "0", - "Date": "Wed, 10 Aug 2022 07:43:10 GMT", + "Date": "Tue, 06 Sep 2022 09:12:37 GMT", "Expires": "-1", "Location": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgname/providers/Microsoft.ServiceBus/namespaces/myNamespacexxyyzzxyyf/operationresults/myNamespacexxyyzzxyyf?api-version=2021-11-01", "Pragma": "no-cache", @@ -699,9 +702,9 @@ "Server-SB": "Service-Bus-Resource-Provider/SN1", "Strict-Transport-Security": "max-age=31536000; includeSubDomains", "X-Content-Type-Options": "nosniff", - "x-ms-correlation-request-id": "b8847605-cac1-4894-8c09-6be18f7fade7", + "x-ms-correlation-request-id": "54ad06bb-d959-4935-996d-6056f615b271", "x-ms-ratelimit-remaining-subscription-deletes": "14990", - "x-ms-routing-request-id": "EASTUS2:20220810T074310Z:b8847605-cac1-4894-8c09-6be18f7fade7" + "x-ms-routing-request-id": "WESTUS:20220906T091237Z:54ad06bb-d959-4935-996d-6056f615b271" }, "ResponseBody": null }, @@ -712,14 +715,14 @@ "Accept": "*/*", "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", - "User-Agent": "azsdk-python-azure-mgmt-servicebus/8.1.0 Python/3.8.13 (Linux-5.15.0-1014-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" + "User-Agent": "azsdk-python-azure-mgmt-servicebus/0.0.0 (it should be stable) Python/3.8.13 (Linux-5.15.0-1017-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2500_0" }, "RequestBody": null, "StatusCode": 200, "ResponseHeaders": { "Cache-Control": "no-cache", "Content-Length": "0", - "Date": "Wed, 10 Aug 2022 07:43:40 GMT", + "Date": "Tue, 06 Sep 2022 09:13:07 GMT", "Expires": "-1", "Pragma": "no-cache", "Server": [ @@ -729,9 +732,9 @@ "Server-SB": "Service-Bus-Resource-Provider/SN1", "Strict-Transport-Security": "max-age=31536000; includeSubDomains", "X-Content-Type-Options": "nosniff", - "x-ms-correlation-request-id": "e965692f-f188-4283-987d-798ac57facbb", - "x-ms-ratelimit-remaining-subscription-reads": "11986", - "x-ms-routing-request-id": "EASTUS2:20220810T074341Z:e965692f-f188-4283-987d-798ac57facbb" + "x-ms-correlation-request-id": "208e5c6e-cee4-4493-90f4-fa009fbd5b37", + "x-ms-ratelimit-remaining-subscription-reads": "11985", + "x-ms-routing-request-id": "WESTUS:20220906T091308Z:208e5c6e-cee4-4493-90f4-fa009fbd5b37" }, "ResponseBody": null } diff --git a/shared_requirements.txt b/shared_requirements.txt index c55e517be4f9..bdd4478e2dd5 100644 --- a/shared_requirements.txt +++ b/shared_requirements.txt @@ -432,8 +432,8 @@ opentelemetry-sdk<2.0.0,>=1.5.0,!=1.10a0 #override azure-mgmt-keyvault azure-mgmt-core>=1.3.1,<2.0.0 #override azure-mgmt-advisor msrest>=0.6.21 #override azure-mgmt-advisor azure-mgmt-core>=1.3.1,<2.0.0 -#override azure-mgmt-servicebus msrest>=0.6.21 -#override azure-mgmt-servicebus azure-mgmt-core>=1.3.1,<2.0.0 +#override azure-mgmt-servicebus msrest>=0.7.1 +#override azure-mgmt-servicebus azure-mgmt-core>=1.3.2,<2.0.0 #override azure-mgmt-relay msrest>=0.6.21 #override azure-mgmt-relay azure-mgmt-core>=1.3.1,<2.0.0 #override azure-mgmt-nginx msrest>=0.7.1