From 7b189f8423b00f4c6f7820916df8229dfd28372b Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Fri, 20 May 2022 06:13:17 +0000 Subject: [PATCH] CodeGen from PR 19156 in Azure/azure-rest-api-specs Merge 041fae4dcc5ddce450e10d96a71f2e07ea143cbb into a8a52b9e6c305f03c3a4c5411d59fc4454b5b372 --- sdk/relay/azure-mgmt-relay/_meta.json | 10 +- .../azure/mgmt/relay/__init__.py | 9 +- .../azure/mgmt/relay/_configuration.py | 31 +- .../azure/mgmt/relay/_metadata.json | 31 +- .../azure/mgmt/relay/_patch.py | 31 + .../azure/mgmt/relay/_relay_api.py | 112 +- .../azure/mgmt/relay/_vendor.py | 27 + .../azure/mgmt/relay/_version.py | 2 +- .../azure/mgmt/relay/aio/__init__.py | 5 + .../azure/mgmt/relay/aio/_configuration.py | 18 +- .../azure/mgmt/relay/aio/_patch.py | 31 + .../azure/mgmt/relay/aio/_relay_api.py | 98 +- .../mgmt/relay/aio/operations/__init__.py | 8 +- .../_hybrid_connections_operations.py | 776 +++---- .../aio/operations/_namespaces_operations.py | 1265 ++++++----- .../mgmt/relay/aio/operations/_operations.py | 58 +- ...private_endpoint_connections_operations.py | 384 ++++ .../_private_link_resources_operations.py | 166 ++ .../aio/operations/_wcf_relays_operations.py | 782 +++---- .../azure/mgmt/relay/models/__init__.py | 108 +- .../azure/mgmt/relay/models/_models.py | 811 ------- .../azure/mgmt/relay/models/_models_py3.py | 1018 +++++++-- .../mgmt/relay/models/_relay_api_enums.py | 94 +- .../azure/mgmt/relay/operations/__init__.py | 8 +- .../_hybrid_connections_operations.py | 1287 +++++++---- .../operations/_namespaces_operations.py | 1944 +++++++++++------ .../mgmt/relay/operations/_operations.py | 100 +- ...private_endpoint_connections_operations.py | 545 +++++ .../_private_link_resources_operations.py | 243 +++ .../operations/_wcf_relays_operations.py | 1294 +++++++---- 30 files changed, 7267 insertions(+), 4029 deletions(-) create mode 100644 sdk/relay/azure-mgmt-relay/azure/mgmt/relay/_patch.py create mode 100644 sdk/relay/azure-mgmt-relay/azure/mgmt/relay/_vendor.py create mode 100644 sdk/relay/azure-mgmt-relay/azure/mgmt/relay/aio/_patch.py create mode 100644 sdk/relay/azure-mgmt-relay/azure/mgmt/relay/aio/operations/_private_endpoint_connections_operations.py create mode 100644 sdk/relay/azure-mgmt-relay/azure/mgmt/relay/aio/operations/_private_link_resources_operations.py delete mode 100644 sdk/relay/azure-mgmt-relay/azure/mgmt/relay/models/_models.py create mode 100644 sdk/relay/azure-mgmt-relay/azure/mgmt/relay/operations/_private_endpoint_connections_operations.py create mode 100644 sdk/relay/azure-mgmt-relay/azure/mgmt/relay/operations/_private_link_resources_operations.py diff --git a/sdk/relay/azure-mgmt-relay/_meta.json b/sdk/relay/azure-mgmt-relay/_meta.json index 13e1e65bcc38..04ba221234d6 100644 --- a/sdk/relay/azure-mgmt-relay/_meta.json +++ b/sdk/relay/azure-mgmt-relay/_meta.json @@ -1,11 +1,11 @@ { - "autorest": "3.4.5", + "autorest": "3.7.2", "use": [ - "@autorest/python@5.8.4", - "@autorest/modelerfour@4.19.2" + "@autorest/python@5.13.0", + "@autorest/modelerfour@4.19.3" ], - "commit": "327b222a6bb23bd1edfe14a75fd8cdc53b4faf61", + "commit": "05824b75e8d34f078ab6d7f3e71e2c6d63e6f8ff", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/relay/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --track2 --use=@autorest/python@5.8.4 --use=@autorest/modelerfour@4.19.2 --version=3.4.5", + "autorest_command": "autorest specification/relay/resource-manager/readme.md --multiapi --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --python3-only --use=@autorest/python@5.13.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", "readme": "specification/relay/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/__init__.py b/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/__init__.py index 2fd04de028b3..88b76f303323 100644 --- a/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/__init__.py +++ b/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['RelayAPI'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/_configuration.py b/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/_configuration.py index 78cd5876565e..79a4e27e68b5 100644 --- a/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/_configuration.py +++ b/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/_configuration.py @@ -6,22 +6,20 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential -class RelayAPIConfiguration(Configuration): +class RelayAPIConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for RelayAPI. Note that all parameters used to create this instance are saved as instance @@ -29,26 +27,31 @@ class RelayAPIConfiguration(Configuration): :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: Subscription credentials which uniquely identify the Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2021-11-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(RelayAPIConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(RelayAPIConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2017-04-01" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-relay/{}'.format(VERSION)) self._configure(**kwargs) @@ -68,4 +71,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/_metadata.json b/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/_metadata.json index 4ce42f2ebea1..bd4033e3b2af 100644 --- a/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/_metadata.json +++ b/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/_metadata.json @@ -1,17 +1,17 @@ { - "chosen_version": "2017-04-01", - "total_api_version_list": ["2017-04-01"], + "chosen_version": "2021-11-01", + "total_api_version_list": ["2021-11-01"], "client": { "name": "RelayAPI", "filename": "_relay_api", "description": "Use these API to manage Azure Relay resources through Azure Resource Manager.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"RelayAPIConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"RelayAPIConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"RelayAPIConfiguration\"]}, \"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\": [\"RelayAPIConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,16 +91,17 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { - "operations": "Operations", "namespaces": "NamespacesOperations", "hybrid_connections": "HybridConnectionsOperations", - "wcf_relays": "WCFRelaysOperations" + "wcf_relays": "WCFRelaysOperations", + "private_endpoint_connections": "PrivateEndpointConnectionsOperations", + "private_link_resources": "PrivateLinkResourcesOperations", + "operations": "Operations" } } \ No newline at end of file diff --git a/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/_patch.py b/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/_relay_api.py b/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/_relay_api.py index 3bfceca35349..bf43e73b1f47 100644 --- a/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/_relay_api.py +++ b/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/_relay_api.py @@ -6,89 +6,99 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, TYPE_CHECKING -from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient -from ._configuration import RelayAPIConfiguration -from .operations import Operations -from .operations import NamespacesOperations -from .operations import HybridConnectionsOperations -from .operations import WCFRelaysOperations from . import models +from ._configuration import RelayAPIConfiguration +from .operations import HybridConnectionsOperations, NamespacesOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, WCFRelaysOperations +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential -class RelayAPI(object): +class RelayAPI: """Use these API to manage Azure Relay resources through Azure Resource Manager. - :ivar operations: Operations operations - :vartype operations: azure.mgmt.relay.operations.Operations :ivar namespaces: NamespacesOperations operations :vartype namespaces: azure.mgmt.relay.operations.NamespacesOperations :ivar hybrid_connections: HybridConnectionsOperations operations :vartype hybrid_connections: azure.mgmt.relay.operations.HybridConnectionsOperations :ivar wcf_relays: WCFRelaysOperations operations :vartype wcf_relays: azure.mgmt.relay.operations.WCFRelaysOperations + :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations + :vartype private_endpoint_connections: + azure.mgmt.relay.operations.PrivateEndpointConnectionsOperations + :ivar private_link_resources: PrivateLinkResourcesOperations operations + :vartype private_link_resources: azure.mgmt.relay.operations.PrivateLinkResourcesOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.relay.operations.Operations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: Subscription credentials which uniquely identify the Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2021-11-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = RelayAPIConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = RelayAPIConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.namespaces = NamespacesOperations(self._client, self._config, self._serialize, self._deserialize) + self.hybrid_connections = HybridConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.wcf_relays = WCFRelaysOperations(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.namespaces = NamespacesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.hybrid_connections = HybridConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.wcf_relays = WCFRelaysOperations( - self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) def close(self): # type: () -> None diff --git a/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/_vendor.py b/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [ + c for c in formatted_components if "{}".format(key.args[0]) not in c + ] + template = "/".join(components) diff --git a/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/_version.py b/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/_version.py index 59deb8c7263b..e5754a47ce68 100644 --- a/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/_version.py +++ b/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/aio/__init__.py b/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/aio/__init__.py index 8837f93b82a5..216d218111e0 100644 --- a/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/aio/__init__.py +++ b/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/aio/__init__.py @@ -8,3 +8,8 @@ from ._relay_api import RelayAPI __all__ = ['RelayAPI'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/aio/_configuration.py b/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/aio/_configuration.py index ab055d2c1f98..bd65c2abc2e0 100644 --- a/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/aio/_configuration.py +++ b/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class RelayAPIConfiguration(Configuration): +class RelayAPIConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for RelayAPI. Note that all parameters used to create this instance are saved as instance @@ -27,8 +27,12 @@ class RelayAPIConfiguration(Configuration): :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: Subscription credentials which uniquely identify the Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2021-11-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -37,15 +41,17 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(RelayAPIConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(RelayAPIConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2017-04-01" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-relay/{}'.format(VERSION)) self._configure(**kwargs) @@ -64,4 +70,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/aio/_patch.py b/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/aio/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/aio/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/aio/_relay_api.py b/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/aio/_relay_api.py index fcc4e8abe27e..c25e5c181fe0 100644 --- a/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/aio/_relay_api.py +++ b/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/aio/_relay_api.py @@ -6,85 +6,99 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient -from ._configuration import RelayAPIConfiguration -from .operations import Operations -from .operations import NamespacesOperations -from .operations import HybridConnectionsOperations -from .operations import WCFRelaysOperations from .. import models +from ._configuration import RelayAPIConfiguration +from .operations import HybridConnectionsOperations, NamespacesOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, WCFRelaysOperations +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential -class RelayAPI(object): +class RelayAPI: """Use these API to manage Azure Relay resources through Azure Resource Manager. - :ivar operations: Operations operations - :vartype operations: azure.mgmt.relay.aio.operations.Operations :ivar namespaces: NamespacesOperations operations :vartype namespaces: azure.mgmt.relay.aio.operations.NamespacesOperations :ivar hybrid_connections: HybridConnectionsOperations operations :vartype hybrid_connections: azure.mgmt.relay.aio.operations.HybridConnectionsOperations :ivar wcf_relays: WCFRelaysOperations operations :vartype wcf_relays: azure.mgmt.relay.aio.operations.WCFRelaysOperations + :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations + :vartype private_endpoint_connections: + azure.mgmt.relay.aio.operations.PrivateEndpointConnectionsOperations + :ivar private_link_resources: PrivateLinkResourcesOperations operations + :vartype private_link_resources: azure.mgmt.relay.aio.operations.PrivateLinkResourcesOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.relay.aio.operations.Operations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: Subscription credentials which uniquely identify the Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2021-11-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = RelayAPIConfiguration(credential, subscription_id, **kwargs) + self._config = RelayAPIConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.namespaces = NamespacesOperations(self._client, self._config, self._serialize, self._deserialize) + self.hybrid_connections = HybridConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.wcf_relays = WCFRelaysOperations(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.namespaces = NamespacesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.hybrid_connections = HybridConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.wcf_relays = WCFRelaysOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() diff --git a/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/aio/operations/__init__.py b/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/aio/operations/__init__.py index 772eceb28d8f..53ad9f8031e5 100644 --- a/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/aio/operations/__init__.py +++ b/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/aio/operations/__init__.py @@ -6,14 +6,18 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._operations import Operations from ._namespaces_operations import NamespacesOperations from ._hybrid_connections_operations import HybridConnectionsOperations from ._wcf_relays_operations import WCFRelaysOperations +from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations +from ._private_link_resources_operations import PrivateLinkResourcesOperations +from ._operations import Operations __all__ = [ - 'Operations', 'NamespacesOperations', 'HybridConnectionsOperations', 'WCFRelaysOperations', + 'PrivateEndpointConnectionsOperations', + 'PrivateLinkResourcesOperations', + 'Operations', ] diff --git a/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/aio/operations/_hybrid_connections_operations.py b/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/aio/operations/_hybrid_connections_operations.py index 9a8ddf571bee..5845f3069865 100644 --- a/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/aio/operations/_hybrid_connections_operations.py +++ b/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/aio/operations/_hybrid_connections_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._hybrid_connections_operations import build_create_or_update_authorization_rule_request, build_create_or_update_request, build_delete_authorization_rule_request, build_delete_request, build_get_authorization_rule_request, build_get_request, build_list_authorization_rules_request, build_list_by_namespace_request, build_list_keys_request, build_regenerate_keys_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,58 +45,67 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config - def list_by_namespace( + @distributed_trace + def list_authorization_rules( self, resource_group_name: str, namespace_name: str, + hybrid_connection_name: str, **kwargs: Any - ) -> AsyncIterable["_models.HybridConnectionListResult"]: - """Lists the hybrid connection within the namespace. + ) -> AsyncIterable["_models.AuthorizationRuleListResult"]: + """Authorization rules for a hybrid connection. :param resource_group_name: Name of the Resource group within the Azure subscription. :type resource_group_name: str :param namespace_name: The namespace name. :type namespace_name: str + :param hybrid_connection_name: The hybrid connection name. + :type hybrid_connection_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either HybridConnectionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.relay.models.HybridConnectionListResult] + :return: An iterator like instance of either AuthorizationRuleListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.relay.models.AuthorizationRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.HybridConnectionListResult"] + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.AuthorizationRuleListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_namespace.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + hybrid_connection_name=hybrid_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_authorization_rules.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + hybrid_connection_name=hybrid_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('HybridConnectionListResult', pipeline_response) + deserialized = self._deserialize("AuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -101,30 +114,37 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_namespace.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/hybridConnections'} # type: ignore + list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/hybridConnections/{hybridConnectionName}/authorizationRules"} # type: ignore - async def create_or_update( + @distributed_trace_async + async def create_or_update_authorization_rule( self, resource_group_name: str, namespace_name: str, hybrid_connection_name: str, - parameters: "_models.HybridConnection", + authorization_rule_name: str, + parameters: "_models.AuthorizationRule", **kwargs: Any - ) -> "_models.HybridConnection": - """Creates or updates a service hybrid connection. This operation is idempotent. + ) -> "_models.AuthorizationRule": + """Creates or updates an authorization rule for a hybrid connection. :param resource_group_name: Name of the Resource group within the Azure subscription. :type resource_group_name: str @@ -132,69 +152,72 @@ async def create_or_update( :type namespace_name: str :param hybrid_connection_name: The hybrid connection name. :type hybrid_connection_name: str - :param parameters: Parameters supplied to create a hybrid connection. - :type parameters: ~azure.mgmt.relay.models.HybridConnection + :param authorization_rule_name: The authorization rule name. + :type authorization_rule_name: str + :param parameters: The authorization rule parameters. + :type parameters: ~azure.mgmt.relay.models.AuthorizationRule :keyword callable cls: A custom type or function that will be passed the direct response - :return: HybridConnection, or the result of cls(response) - :rtype: ~azure.mgmt.relay.models.HybridConnection + :return: AuthorizationRule, or the result of cls(response) + :rtype: ~azure.mgmt.relay.models.AuthorizationRule :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.HybridConnection"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.AuthorizationRule"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'hybridConnectionName': self._serialize.url("hybrid_connection_name", hybrid_connection_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'HybridConnection') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'AuthorizationRule') + + request = build_create_or_update_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + hybrid_connection_name=hybrid_connection_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('HybridConnection', pipeline_response) + deserialized = self._deserialize('AuthorizationRule', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/hybridConnections/{hybridConnectionName}'} # type: ignore - async def delete( + create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/hybridConnections/{hybridConnectionName}/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, hybrid_connection_name: str, + authorization_rule_name: str, **kwargs: Any ) -> None: - """Deletes a hybrid connection. + """Deletes a hybrid connection authorization rule. :param resource_group_name: Name of the Resource group within the Azure subscription. :type resource_group_name: str @@ -202,6 +225,8 @@ async def delete( :type namespace_name: str :param hybrid_connection_name: The hybrid connection name. :type hybrid_connection_name: str + :param authorization_rule_name: The authorization rule name. + :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -212,49 +237,50 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'hybridConnectionName': self._serialize.url("hybrid_connection_name", hybrid_connection_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + + + request = build_delete_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + hybrid_connection_name=hybrid_connection_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/hybridConnections/{hybridConnectionName}'} # type: ignore + delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/hybridConnections/{hybridConnectionName}/authorizationRules/{authorizationRuleName}"} # type: ignore - async def get( + + @distributed_trace_async + async def get_authorization_rule( self, resource_group_name: str, namespace_name: str, hybrid_connection_name: str, + authorization_rule_name: str, **kwargs: Any - ) -> "_models.HybridConnection": - """Returns the description for the specified hybrid connection. + ) -> "_models.AuthorizationRule": + """Hybrid connection authorization rule for a hybrid connection by name. :param resource_group_name: Name of the Resource group within the Azure subscription. :type resource_group_name: str @@ -262,62 +288,66 @@ async def get( :type namespace_name: str :param hybrid_connection_name: The hybrid connection name. :type hybrid_connection_name: str + :param authorization_rule_name: The authorization rule name. + :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: HybridConnection, or the result of cls(response) - :rtype: ~azure.mgmt.relay.models.HybridConnection + :return: AuthorizationRule, or the result of cls(response) + :rtype: ~azure.mgmt.relay.models.AuthorizationRule :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.HybridConnection"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.AuthorizationRule"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'hybridConnectionName': self._serialize.url("hybrid_connection_name", hybrid_connection_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + + + request = build_get_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + hybrid_connection_name=hybrid_connection_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('HybridConnection', pipeline_response) + deserialized = self._deserialize('AuthorizationRule', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/hybridConnections/{hybridConnectionName}'} # type: ignore - def list_authorization_rules( + get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/hybridConnections/{hybridConnectionName}/authorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace_async + async def list_keys( self, resource_group_name: str, namespace_name: str, hybrid_connection_name: str, + authorization_rule_name: str, **kwargs: Any - ) -> AsyncIterable["_models.AuthorizationRuleListResult"]: - """Authorization rules for a hybrid connection. + ) -> "_models.AccessKeys": + """Primary and secondary connection strings to the hybrid connection. :param resource_group_name: Name of the Resource group within the Azure subscription. :type resource_group_name: str @@ -325,80 +355,67 @@ def list_authorization_rules( :type namespace_name: str :param hybrid_connection_name: The hybrid connection name. :type hybrid_connection_name: str + :param authorization_rule_name: The authorization rule name. + :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AuthorizationRuleListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.relay.models.AuthorizationRuleListResult] + :return: AccessKeys, or the result of cls(response) + :rtype: ~azure.mgmt.relay.models.AccessKeys :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AuthorizationRuleListResult"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessKeys"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + + + request = build_list_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + hybrid_connection_name=hybrid_connection_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - if not next_link: - # Construct URL - url = self.list_authorization_rules.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'hybridConnectionName': self._serialize.url("hybrid_connection_name", hybrid_connection_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response - async def extract_data(pipeline_response): - deserialized = self._deserialize('AuthorizationRuleListResult', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - async def get_next(next_link=None): - request = prepare_request(next_link) + deserialized = self._deserialize('AccessKeys', pipeline_response) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response + if cls: + return cls(pipeline_response, deserialized, {}) - if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + return deserialized - return pipeline_response + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/hybridConnections/{hybridConnectionName}/authorizationRules/{authorizationRuleName}/listKeys"} # type: ignore - return AsyncItemPaged( - get_next, extract_data - ) - list_authorization_rules.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/hybridConnections/{hybridConnectionName}/authorizationRules'} # type: ignore - async def create_or_update_authorization_rule( + @distributed_trace_async + async def regenerate_keys( self, resource_group_name: str, namespace_name: str, hybrid_connection_name: str, authorization_rule_name: str, - parameters: "_models.AuthorizationRule", + parameters: "_models.RegenerateAccessKeyParameters", **kwargs: Any - ) -> "_models.AuthorizationRule": - """Creates or updates an authorization rule for a hybrid connection. + ) -> "_models.AccessKeys": + """Regenerates the primary or secondary connection strings to the hybrid connection. :param resource_group_name: Name of the Resource group within the Azure subscription. :type resource_group_name: str @@ -408,135 +425,154 @@ async def create_or_update_authorization_rule( :type hybrid_connection_name: str :param authorization_rule_name: The authorization rule name. :type authorization_rule_name: str - :param parameters: The authorization rule parameters. - :type parameters: ~azure.mgmt.relay.models.AuthorizationRule + :param parameters: Parameters supplied to regenerate authorization rule. + :type parameters: ~azure.mgmt.relay.models.RegenerateAccessKeyParameters :keyword callable cls: A custom type or function that will be passed the direct response - :return: AuthorizationRule, or the result of cls(response) - :rtype: ~azure.mgmt.relay.models.AuthorizationRule + :return: AccessKeys, or the result of cls(response) + :rtype: ~azure.mgmt.relay.models.AccessKeys :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AuthorizationRule"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessKeys"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'hybridConnectionName': self._serialize.url("hybrid_connection_name", hybrid_connection_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'AuthorizationRule') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + + request = build_regenerate_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + hybrid_connection_name=hybrid_connection_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.regenerate_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AuthorizationRule', pipeline_response) + deserialized = self._deserialize('AccessKeys', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/hybridConnections/{hybridConnectionName}/authorizationRules/{authorizationRuleName}'} # type: ignore - async def delete_authorization_rule( + regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/hybridConnections/{hybridConnectionName}/authorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore + + + @distributed_trace + def list_by_namespace( self, resource_group_name: str, namespace_name: str, - hybrid_connection_name: str, - authorization_rule_name: str, **kwargs: Any - ) -> None: - """Deletes a hybrid connection authorization rule. + ) -> AsyncIterable["_models.HybridConnectionListResult"]: + """Lists the hybrid connection within the namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. :type resource_group_name: str :param namespace_name: The namespace name. :type namespace_name: str - :param hybrid_connection_name: The hybrid connection name. - :type hybrid_connection_name: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None + :return: An iterator like instance of either HybridConnectionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.relay.models.HybridConnectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.HybridConnectionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.delete_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'hybridConnectionName': self._serialize.url("hybrid_connection_name", hybrid_connection_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + async def extract_data(pipeline_response): + deserialized = self._deserialize("HybridConnectionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + async def get_next(next_link=None): + request = prepare_request(next_link) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if cls: - return cls(pipeline_response, None, {}) + return pipeline_response - delete_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/hybridConnections/{hybridConnectionName}/authorizationRules/{authorizationRuleName}'} # type: ignore - async def get_authorization_rule( + return AsyncItemPaged( + get_next, extract_data + ) + list_by_namespace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/hybridConnections"} # type: ignore + + @distributed_trace_async + async def create_or_update( self, resource_group_name: str, namespace_name: str, hybrid_connection_name: str, - authorization_rule_name: str, + parameters: "_models.HybridConnection", **kwargs: Any - ) -> "_models.AuthorizationRule": - """Hybrid connection authorization rule for a hybrid connection by name. + ) -> "_models.HybridConnection": + """Creates or updates a service hybrid connection. This operation is idempotent. :param resource_group_name: Name of the Resource group within the Azure subscription. :type resource_group_name: str @@ -544,66 +580,68 @@ async def get_authorization_rule( :type namespace_name: str :param hybrid_connection_name: The hybrid connection name. :type hybrid_connection_name: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_name: str + :param parameters: Parameters supplied to create a hybrid connection. + :type parameters: ~azure.mgmt.relay.models.HybridConnection :keyword callable cls: A custom type or function that will be passed the direct response - :return: AuthorizationRule, or the result of cls(response) - :rtype: ~azure.mgmt.relay.models.AuthorizationRule + :return: HybridConnection, or the result of cls(response) + :rtype: ~azure.mgmt.relay.models.HybridConnection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AuthorizationRule"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.HybridConnection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.get_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'hybridConnectionName': self._serialize.url("hybrid_connection_name", hybrid_connection_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'HybridConnection') - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + request = build_create_or_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + hybrid_connection_name=hybrid_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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AuthorizationRule', pipeline_response) + deserialized = self._deserialize('HybridConnection', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/hybridConnections/{hybridConnectionName}/authorizationRules/{authorizationRuleName}'} # type: ignore - async def list_keys( + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/hybridConnections/{hybridConnectionName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, hybrid_connection_name: str, - authorization_rule_name: str, **kwargs: Any - ) -> "_models.AccessKeys": - """Primary and secondary connection strings to the hybrid connection. + ) -> None: + """Deletes a hybrid connection. :param resource_group_name: Name of the Resource group within the Azure subscription. :type resource_group_name: str @@ -611,67 +649,58 @@ async def list_keys( :type namespace_name: str :param hybrid_connection_name: The hybrid connection name. :type hybrid_connection_name: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) - :rtype: ~azure.mgmt.relay.models.AccessKeys + :return: None, or the result of cls(response) + :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessKeys"] + cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'hybridConnectionName': self._serialize.url("hybrid_connection_name", hybrid_connection_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-11-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + hybrid_connection_name=hybrid_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, None, {}) - return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/hybridConnections/{hybridConnectionName}/authorizationRules/{authorizationRuleName}/listKeys'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/hybridConnections/{hybridConnectionName}"} # type: ignore - async def regenerate_keys( + + @distributed_trace_async + async def get( self, resource_group_name: str, namespace_name: str, hybrid_connection_name: str, - authorization_rule_name: str, - parameters: "_models.RegenerateAccessKeyParameters", **kwargs: Any - ) -> "_models.AccessKeys": - """Regenerates the primary or secondary connection strings to the hybrid connection. + ) -> "_models.HybridConnection": + """Returns the description for the specified hybrid connection. :param resource_group_name: Name of the Resource group within the Azure subscription. :type resource_group_name: str @@ -679,60 +708,49 @@ async def regenerate_keys( :type namespace_name: str :param hybrid_connection_name: The hybrid connection name. :type hybrid_connection_name: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate authorization rule. - :type parameters: ~azure.mgmt.relay.models.RegenerateAccessKeyParameters :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) - :rtype: ~azure.mgmt.relay.models.AccessKeys + :return: HybridConnection, or the result of cls(response) + :rtype: ~azure.mgmt.relay.models.HybridConnection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessKeys"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.HybridConnection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.regenerate_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'hybridConnectionName': self._serialize.url("hybrid_connection_name", hybrid_connection_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + hybrid_connection_name=hybrid_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = self._deserialize('HybridConnection', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/hybridConnections/{hybridConnectionName}/authorizationRules/{authorizationRuleName}/regenerateKeys'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/hybridConnections/{hybridConnectionName}"} # type: ignore + diff --git a/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/aio/operations/_namespaces_operations.py b/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/aio/operations/_namespaces_operations.py index 0a213e54d254..96518b68bbb8 100644 --- a/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/aio/operations/_namespaces_operations.py +++ b/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/aio/operations/_namespaces_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,19 +6,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._namespaces_operations import build_check_name_availability_request, build_create_or_update_authorization_rule_request, build_create_or_update_network_rule_set_request, build_create_or_update_request_initial, build_delete_authorization_rule_request, build_delete_request_initial, build_get_authorization_rule_request, build_get_network_rule_set_request, build_get_request, build_list_authorization_rules_request, build_list_by_resource_group_request, build_list_keys_request, build_list_request, build_regenerate_keys_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -37,12 +41,422 @@ class NamespacesOperations: models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list_authorization_rules( + self, + resource_group_name: str, + namespace_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.AuthorizationRuleListResult"]: + """Authorization rules for a namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. + :type resource_group_name: str + :param namespace_name: The namespace name. + :type namespace_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AuthorizationRuleListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.relay.models.AuthorizationRuleListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.AuthorizationRuleListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("AuthorizationRuleListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/authorizationRules"} # type: ignore + + @distributed_trace_async + async def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: "_models.AuthorizationRule", + **kwargs: Any + ) -> "_models.AuthorizationRule": + """Creates or updates an authorization rule for a namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. + :type resource_group_name: str + :param namespace_name: The namespace name. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. + :type authorization_rule_name: str + :param parameters: The authorization rule parameters. + :type parameters: ~azure.mgmt.relay.models.AuthorizationRule + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AuthorizationRule, or the result of cls(response) + :rtype: ~azure.mgmt.relay.models.AuthorizationRule + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AuthorizationRule"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'AuthorizationRule') + + request = build_create_or_update_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('AuthorizationRule', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/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 + ) -> None: + """Deletes a namespace authorization rule. + + :param resource_group_name: Name of the Resource group within the Azure subscription. + :type resource_group_name: str + :param namespace_name: The namespace name. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. + :type authorization_rule_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + + + request = build_delete_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/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 + ) -> "_models.AuthorizationRule": + """Authorization rule for a namespace by name. + + :param resource_group_name: Name of the Resource group within the Azure subscription. + :type resource_group_name: str + :param namespace_name: The namespace name. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. + :type authorization_rule_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AuthorizationRule, or the result of cls(response) + :rtype: ~azure.mgmt.relay.models.AuthorizationRule + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AuthorizationRule"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + + + request = build_get_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('AuthorizationRule', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/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 + ) -> "_models.AccessKeys": + """Primary and secondary connection strings to the namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. + :type resource_group_name: str + :param namespace_name: The namespace name. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. + :type authorization_rule_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AccessKeys, or the result of cls(response) + :rtype: ~azure.mgmt.relay.models.AccessKeys + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessKeys"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + + + request = build_list_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + 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.Relay/namespaces/{namespaceName}/authorizationRules/{authorizationRuleName}/listKeys"} # type: ignore + + + @distributed_trace_async + async def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: "_models.RegenerateAccessKeyParameters", + **kwargs: Any + ) -> "_models.AccessKeys": + """Regenerates the primary or secondary connection strings to the namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. + :type resource_group_name: str + :param namespace_name: The namespace name. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate authorization rule. + :type parameters: ~azure.mgmt.relay.models.RegenerateAccessKeyParameters + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AccessKeys, or the result of cls(response) + :rtype: ~azure.mgmt.relay.models.AccessKeys + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessKeys"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + + request = build_regenerate_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.regenerate_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('AccessKeys', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/authorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore + + @distributed_trace_async async def check_name_availability( self, parameters: "_models.CheckNameAvailability", @@ -62,36 +476,32 @@ async def check_name_availability( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_name_availability.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'CheckNameAvailability') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'CheckNameAvailability') + + request = build_check_name_availability_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.check_name_availability.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) @@ -100,8 +510,11 @@ async def check_name_availability( return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Relay/checkNameAvailability'} # type: ignore + check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Relay/checkNameAvailability"} # type: ignore + + + @distributed_trace def list( self, **kwargs: Any @@ -109,43 +522,44 @@ def list( """Lists all the available namespaces within the subscription regardless of the resourceGroups. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RelayNamespaceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.relay.models.RelayNamespaceListResult] + :return: An iterator like instance of either RelayNamespaceListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.relay.models.RelayNamespaceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RelayNamespaceListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RelayNamespaceListResult', pipeline_response) + deserialized = self._deserialize("RelayNamespaceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -154,21 +568,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Relay/namespaces'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Relay/namespaces"} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -179,44 +599,46 @@ def list_by_resource_group( :param resource_group_name: Name of the Resource group within the Azure subscription. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RelayNamespaceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.relay.models.RelayNamespaceListResult] + :return: An iterator like instance of either RelayNamespaceListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.relay.models.RelayNamespaceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RelayNamespaceListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RelayNamespaceListResult', pipeline_response) + deserialized = self._deserialize("RelayNamespaceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -225,20 +647,25 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces"} # type: ignore async def _create_or_update_initial( self, @@ -252,39 +679,34 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RelayNamespace') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RelayNamespace') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('RelayNamespace', pipeline_response) @@ -296,8 +718,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}'} # type: ignore + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}"} # type: ignore + + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -315,14 +740,19 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.relay.models.RelayNamespace :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either RelayNamespace or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either RelayNamespace or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.relay.models.RelayNamespace] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.RelayNamespace"] lro_delay = kwargs.pop( @@ -335,27 +765,22 @@ async def begin_create_or_update( resource_group_name=resource_group_name, namespace_name=namespace_name, parameters=parameters, + api_version=api_version, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('RelayNamespace', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -365,11 +790,11 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}"} # type: ignore - async def _delete_initial( + async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -380,41 +805,39 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-11-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}'} # type: ignore + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}"} # type: ignore - async def begin_delete( + + @distributed_trace_async + async def begin_delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, @@ -429,14 +852,17 @@ async def begin_delete( :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-11-01") # type: str polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( @@ -448,24 +874,18 @@ async def begin_delete( raw_result = await self._delete_initial( resource_group_name=resource_group_name, namespace_name=namespace_name, + api_version=api_version, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -475,10 +895,11 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}"} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -501,33 +922,30 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-11-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RelayNamespace', pipeline_response) @@ -536,8 +954,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}"} # type: ignore + + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -564,38 +985,34 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RelayUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RelayUpdateParameters') + + request = build_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -608,407 +1025,131 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}'} # type: ignore - def list_authorization_rules( + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}"} # type: ignore + + + @distributed_trace_async + async def create_or_update_network_rule_set( self, resource_group_name: str, namespace_name: str, + parameters: "_models.NetworkRuleSet", **kwargs: Any - ) -> AsyncIterable["_models.AuthorizationRuleListResult"]: - """Authorization rules for a namespace. + ) -> "_models.NetworkRuleSet": + """Create or update NetworkRuleSet for a Namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. :type resource_group_name: str :param namespace_name: The namespace name. :type namespace_name: str + :param parameters: The Namespace IpFilterRule. + :type parameters: ~azure.mgmt.relay.models.NetworkRuleSet :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AuthorizationRuleListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.relay.models.AuthorizationRuleListResult] + :return: NetworkRuleSet, or the result of cls(response) + :rtype: ~azure.mgmt.relay.models.NetworkRuleSet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AuthorizationRuleListResult"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.NetworkRuleSet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_authorization_rules.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('AuthorizationRuleListResult', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - return pipeline_response + _json = self._serialize.body(parameters, 'NetworkRuleSet') - return AsyncItemPaged( - get_next, extract_data + request = build_create_or_update_network_rule_set_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update_network_rule_set.metadata['url'], ) - list_authorization_rules.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/authorizationRules'} # type: ignore - - async def create_or_update_authorization_rule( - self, - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - parameters: "_models.AuthorizationRule", - **kwargs: Any - ) -> "_models.AuthorizationRule": - """Creates or updates an authorization rule for a namespace. + request = _convert_request(request) + request.url = self._client.format_url(request.url) - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_name: str - :param parameters: The authorization rule parameters. - :type parameters: ~azure.mgmt.relay.models.AuthorizationRule - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AuthorizationRule, or the result of cls(response) - :rtype: ~azure.mgmt.relay.models.AuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AuthorizationRule"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'AuthorizationRule') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AuthorizationRule', pipeline_response) + deserialized = self._deserialize('NetworkRuleSet', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/authorizationRules/{authorizationRuleName}'} # type: ignore - - async def delete_authorization_rule( - 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. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.delete_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/authorizationRules/{authorizationRuleName}'} # type: ignore - - async def get_authorization_rule( - self, - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - **kwargs: Any - ) -> "_models.AuthorizationRule": - """Authorization rule for a namespace by name. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AuthorizationRule, or the result of cls(response) - :rtype: ~azure.mgmt.relay.models.AuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AuthorizationRule"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.get_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('AuthorizationRule', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) + create_or_update_network_rule_set.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/networkRuleSets/default"} # type: ignore - return deserialized - get_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/authorizationRules/{authorizationRuleName}'} # type: ignore - async def list_keys( + @distributed_trace_async + async def get_network_rule_set( self, resource_group_name: str, namespace_name: str, - authorization_rule_name: str, **kwargs: Any - ) -> "_models.AccessKeys": - """Primary and secondary connection strings to the namespace. + ) -> "_models.NetworkRuleSet": + """Gets NetworkRuleSet for a Namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. :type resource_group_name: str :param namespace_name: The namespace name. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) - :rtype: ~azure.mgmt.relay.models.AccessKeys + :return: NetworkRuleSet, or the result of cls(response) + :rtype: ~azure.mgmt.relay.models.NetworkRuleSet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessKeys"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.NetworkRuleSet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-11-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_network_rule_set_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_network_rule_set.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = self._deserialize('NetworkRuleSet', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/authorizationRules/{authorizationRuleName}/listKeys'} # type: ignore - - async def regenerate_keys( - self, - resource_group_name: str, - namespace_name: str, - authorization_rule_name: str, - parameters: "_models.RegenerateAccessKeyParameters", - **kwargs: Any - ) -> "_models.AccessKeys": - """Regenerates the primary or secondary connection strings to the namespace. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate authorization rule. - :type parameters: ~azure.mgmt.relay.models.RegenerateAccessKeyParameters - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) - :rtype: ~azure.mgmt.relay.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessKeys"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.regenerate_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('AccessKeys', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) + get_network_rule_set.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/networkRuleSets/default"} # type: ignore - return deserialized - regenerate_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/authorizationRules/{authorizationRuleName}/regenerateKeys'} # type: ignore diff --git a/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/aio/operations/_operations.py b/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/aio/operations/_operations.py index ae7b426b5abd..82103dac85ce 100644 --- a/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/aio/operations/_operations.py +++ b/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -52,35 +56,36 @@ def list( :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.relay.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.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', {})) - api_version = "2017-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -89,17 +94,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Relay/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Relay/operations"} # type: ignore diff --git a/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/aio/operations/_private_endpoint_connections_operations.py b/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/aio/operations/_private_endpoint_connections_operations.py new file mode 100644 index 000000000000..c7e733704754 --- /dev/null +++ b/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/aio/operations/_private_endpoint_connections_operations.py @@ -0,0 +1,384 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._private_endpoint_connections_operations import build_create_or_update_request, build_delete_request_initial, build_get_request, build_list_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class PrivateEndpointConnectionsOperations: + """PrivateEndpointConnectionsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.relay.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list( + self, + resource_group_name: str, + namespace_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.PrivateEndpointConnectionListResult"]: + """Gets the available PrivateEndpointConnections within a namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. + :type resource_group_name: str + :param namespace_name: The namespace name. + :type namespace_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.relay.models.PrivateEndpointConnectionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.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', {})) + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/privateEndpointConnections"} # type: ignore + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + parameters: "_models.PrivateEndpointConnection", + **kwargs: Any + ) -> "_models.PrivateEndpointConnection": + """Creates or updates PrivateEndpointConnections of service namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. + :type resource_group_name: str + :param namespace_name: The namespace name. + :type namespace_name: str + :param private_endpoint_connection_name: The PrivateEndpointConnection name. + :type private_endpoint_connection_name: str + :param parameters: Parameters supplied to update Status of PrivateEndPoint Connection to + namespace resource. + :type parameters: ~azure.mgmt.relay.models.PrivateEndpointConnection + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PrivateEndpointConnection, or the result of cls(response) + :rtype: ~azure.mgmt.relay.models.PrivateEndpointConnection + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PrivateEndpointConnection') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + namespace_name=namespace_name, + private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + + if response.status_code == 202: + 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.Relay/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 + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/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 + ) -> AsyncLROPoller[None]: + """Deletes an existing namespace. This operation also removes all associated resources under the + namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. + :type resource_group_name: str + :param namespace_name: The namespace name. + :type namespace_name: str + :param private_endpoint_connection_name: The PrivateEndpointConnection name. + :type private_endpoint_connection_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: 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 None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/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 + ) -> "_models.PrivateEndpointConnection": + """Gets a description for the specified Private Endpoint Connection name. + + :param resource_group_name: Name of the Resource group within the Azure subscription. + :type resource_group_name: str + :param namespace_name: The namespace name. + :type namespace_name: str + :param private_endpoint_connection_name: The PrivateEndpointConnection name. + :type private_endpoint_connection_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PrivateEndpointConnection, or the result of cls(response) + :rtype: ~azure.mgmt.relay.models.PrivateEndpointConnection + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + diff --git a/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/aio/operations/_private_link_resources_operations.py b/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/aio/operations/_private_link_resources_operations.py new file mode 100644 index 000000000000..4b9991c2ee40 --- /dev/null +++ b/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/aio/operations/_private_link_resources_operations.py @@ -0,0 +1,166 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._private_link_resources_operations import build_get_request, build_list_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class PrivateLinkResourcesOperations: + """PrivateLinkResourcesOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.relay.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + namespace_name: str, + private_link_resource_name: str, + **kwargs: Any + ) -> "_models.PrivateLinkResource": + """Gets a description for the specified Private Endpoint Connection name. + + :param resource_group_name: Name of the Resource group within the Azure subscription. + :type resource_group_name: str + :param namespace_name: The namespace name. + :type namespace_name: str + :param private_link_resource_name: The PrivateLinkResource name. + :type private_link_resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PrivateLinkResource, or the result of cls(response) + :rtype: ~azure.mgmt.relay.models.PrivateLinkResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResource"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + private_link_resource_name=private_link_resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PrivateLinkResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/privateLinkResources/{privateLinkResourceName}"} # type: ignore + + + @distributed_trace_async + async def list( + 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. + :type resource_group_name: str + :param namespace_name: The namespace name. + :type namespace_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PrivateLinkResourcesListResult, or the result of cls(response) + :rtype: ~azure.mgmt.relay.models.PrivateLinkResourcesListResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResourcesListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + + + request = build_list_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PrivateLinkResourcesListResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/privateLinkResources"} # type: ignore + diff --git a/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/aio/operations/_wcf_relays_operations.py b/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/aio/operations/_wcf_relays_operations.py index 495577abf105..68d68d08c6e5 100644 --- a/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/aio/operations/_wcf_relays_operations.py +++ b/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/aio/operations/_wcf_relays_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._wcf_relays_operations import build_create_or_update_authorization_rule_request, build_create_or_update_request, build_delete_authorization_rule_request, build_delete_request, build_get_authorization_rule_request, build_get_request, build_list_authorization_rules_request, build_list_by_namespace_request, build_list_keys_request, build_regenerate_keys_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,58 +45,67 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config - def list_by_namespace( + @distributed_trace + def list_authorization_rules( self, resource_group_name: str, namespace_name: str, + relay_name: str, **kwargs: Any - ) -> AsyncIterable["_models.WcfRelaysListResult"]: - """Lists the WCF relays within the namespace. + ) -> AsyncIterable["_models.AuthorizationRuleListResult"]: + """Authorization rules for a WCF relay. :param resource_group_name: Name of the Resource group within the Azure subscription. :type resource_group_name: str :param namespace_name: The namespace name. :type namespace_name: str + :param relay_name: The relay name. + :type relay_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either WcfRelaysListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.relay.models.WcfRelaysListResult] + :return: An iterator like instance of either AuthorizationRuleListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.relay.models.AuthorizationRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WcfRelaysListResult"] + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.AuthorizationRuleListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_namespace.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + relay_name=relay_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_authorization_rules.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + relay_name=relay_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('WcfRelaysListResult', pipeline_response) + deserialized = self._deserialize("AuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -101,30 +114,36 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_namespace.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/wcfRelays'} # type: ignore + list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/wcfRelays/{relayName}/authorizationRules"} # type: ignore - async def create_or_update( + @distributed_trace_async + async def create_or_update_authorization_rule( self, resource_group_name: str, namespace_name: str, relay_name: str, - parameters: "_models.WcfRelay", + authorization_rule_name: str, + parameters: "_models.AuthorizationRule", **kwargs: Any - ) -> "_models.WcfRelay": - """Creates or updates a WCF relay. This operation is idempotent. + ) -> "_models.AuthorizationRule": + """Creates or updates an authorization rule for a WCF relay. :param resource_group_name: Name of the Resource group within the Azure subscription. :type resource_group_name: str @@ -132,69 +151,72 @@ async def create_or_update( :type namespace_name: str :param relay_name: The relay name. :type relay_name: str - :param parameters: Parameters supplied to create a WCF relay. - :type parameters: ~azure.mgmt.relay.models.WcfRelay + :param authorization_rule_name: The authorization rule name. + :type authorization_rule_name: str + :param parameters: The authorization rule parameters. + :type parameters: ~azure.mgmt.relay.models.AuthorizationRule :keyword callable cls: A custom type or function that will be passed the direct response - :return: WcfRelay, or the result of cls(response) - :rtype: ~azure.mgmt.relay.models.WcfRelay + :return: AuthorizationRule, or the result of cls(response) + :rtype: ~azure.mgmt.relay.models.AuthorizationRule :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WcfRelay"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.AuthorizationRule"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'relayName': self._serialize.url("relay_name", relay_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'WcfRelay') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'AuthorizationRule') + + request = build_create_or_update_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + relay_name=relay_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('WcfRelay', pipeline_response) + deserialized = self._deserialize('AuthorizationRule', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/wcfRelays/{relayName}'} # type: ignore - async def delete( + create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/wcfRelays/{relayName}/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, relay_name: str, + authorization_rule_name: str, **kwargs: Any ) -> None: - """Deletes a WCF relay. + """Deletes a WCF relay authorization rule. :param resource_group_name: Name of the Resource group within the Azure subscription. :type resource_group_name: str @@ -202,6 +224,8 @@ async def delete( :type namespace_name: str :param relay_name: The relay name. :type relay_name: str + :param authorization_rule_name: The authorization rule name. + :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -212,49 +236,50 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'relayName': self._serialize.url("relay_name", relay_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + + + request = build_delete_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + relay_name=relay_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/wcfRelays/{relayName}'} # type: ignore + delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/wcfRelays/{relayName}/authorizationRules/{authorizationRuleName}"} # type: ignore - async def get( + + @distributed_trace_async + async def get_authorization_rule( self, resource_group_name: str, namespace_name: str, relay_name: str, + authorization_rule_name: str, **kwargs: Any - ) -> Optional["_models.WcfRelay"]: - """Returns the description for the specified WCF relay. + ) -> "_models.AuthorizationRule": + """Get authorizationRule for a WCF relay by name. :param resource_group_name: Name of the Resource group within the Azure subscription. :type resource_group_name: str @@ -262,64 +287,66 @@ async def get( :type namespace_name: str :param relay_name: The relay name. :type relay_name: str + :param authorization_rule_name: The authorization rule name. + :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: WcfRelay, or the result of cls(response) - :rtype: ~azure.mgmt.relay.models.WcfRelay or None + :return: AuthorizationRule, or the result of cls(response) + :rtype: ~azure.mgmt.relay.models.AuthorizationRule :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WcfRelay"]] + cls = kwargs.pop('cls', None) # type: ClsType["_models.AuthorizationRule"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'relayName': self._serialize.url("relay_name", relay_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + + + request = build_get_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + relay_name=relay_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response - if response.status_code not in [200, 204]: + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('WcfRelay', pipeline_response) + deserialized = self._deserialize('AuthorizationRule', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/wcfRelays/{relayName}'} # type: ignore - def list_authorization_rules( + get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/wcfRelays/{relayName}/authorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace_async + async def list_keys( self, resource_group_name: str, namespace_name: str, relay_name: str, + authorization_rule_name: str, **kwargs: Any - ) -> AsyncIterable["_models.AuthorizationRuleListResult"]: - """Authorization rules for a WCF relay. + ) -> "_models.AccessKeys": + """Primary and secondary connection strings to the WCF relay. :param resource_group_name: Name of the Resource group within the Azure subscription. :type resource_group_name: str @@ -327,79 +354,67 @@ def list_authorization_rules( :type namespace_name: str :param relay_name: The relay name. :type relay_name: str + :param authorization_rule_name: The authorization rule name. + :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AuthorizationRuleListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.relay.models.AuthorizationRuleListResult] + :return: AccessKeys, or the result of cls(response) + :rtype: ~azure.mgmt.relay.models.AccessKeys :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AuthorizationRuleListResult"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessKeys"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + + + request = build_list_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + relay_name=relay_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - if not next_link: - # Construct URL - url = self.list_authorization_rules.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'relayName': self._serialize.url("relay_name", relay_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response - async def extract_data(pipeline_response): - deserialized = self._deserialize('AuthorizationRuleListResult', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - async def get_next(next_link=None): - request = prepare_request(next_link) + deserialized = self._deserialize('AccessKeys', pipeline_response) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response + if cls: + return cls(pipeline_response, deserialized, {}) - 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) + return deserialized - return pipeline_response + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/wcfRelays/{relayName}/authorizationRules/{authorizationRuleName}/listKeys"} # type: ignore - return AsyncItemPaged( - get_next, extract_data - ) - list_authorization_rules.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/wcfRelays/{relayName}/authorizationRules'} # type: ignore - async def create_or_update_authorization_rule( + @distributed_trace_async + async def regenerate_keys( self, resource_group_name: str, namespace_name: str, relay_name: str, authorization_rule_name: str, - parameters: "_models.AuthorizationRule", + parameters: "_models.RegenerateAccessKeyParameters", **kwargs: Any - ) -> "_models.AuthorizationRule": - """Creates or updates an authorization rule for a WCF relay. + ) -> "_models.AccessKeys": + """Regenerates the primary or secondary connection strings to the WCF relay. :param resource_group_name: Name of the Resource group within the Azure subscription. :type resource_group_name: str @@ -409,135 +424,152 @@ async def create_or_update_authorization_rule( :type relay_name: str :param authorization_rule_name: The authorization rule name. :type authorization_rule_name: str - :param parameters: The authorization rule parameters. - :type parameters: ~azure.mgmt.relay.models.AuthorizationRule + :param parameters: Parameters supplied to regenerate authorization rule. + :type parameters: ~azure.mgmt.relay.models.RegenerateAccessKeyParameters :keyword callable cls: A custom type or function that will be passed the direct response - :return: AuthorizationRule, or the result of cls(response) - :rtype: ~azure.mgmt.relay.models.AuthorizationRule + :return: AccessKeys, or the result of cls(response) + :rtype: ~azure.mgmt.relay.models.AccessKeys :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AuthorizationRule"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessKeys"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'relayName': self._serialize.url("relay_name", relay_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'AuthorizationRule') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + + request = build_regenerate_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + relay_name=relay_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.regenerate_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AuthorizationRule', pipeline_response) + deserialized = self._deserialize('AccessKeys', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/wcfRelays/{relayName}/authorizationRules/{authorizationRuleName}'} # type: ignore - async def delete_authorization_rule( + regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/wcfRelays/{relayName}/authorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore + + + @distributed_trace + def list_by_namespace( self, resource_group_name: str, namespace_name: str, - relay_name: str, - authorization_rule_name: str, **kwargs: Any - ) -> None: - """Deletes a WCF relay authorization rule. + ) -> AsyncIterable["_models.WcfRelaysListResult"]: + """Lists the WCF relays within the namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. :type resource_group_name: str :param namespace_name: The namespace name. :type namespace_name: str - :param relay_name: The relay name. - :type relay_name: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None + :return: An iterator like instance of either WcfRelaysListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.relay.models.WcfRelaysListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.WcfRelaysListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.delete_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'relayName': self._serialize.url("relay_name", relay_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + async def extract_data(pipeline_response): + deserialized = self._deserialize("WcfRelaysListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + async def get_next(next_link=None): + request = prepare_request(next_link) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if cls: - return cls(pipeline_response, None, {}) + return pipeline_response - delete_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/wcfRelays/{relayName}/authorizationRules/{authorizationRuleName}'} # type: ignore - async def get_authorization_rule( + return AsyncItemPaged( + get_next, extract_data + ) + list_by_namespace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/wcfRelays"} # type: ignore + + @distributed_trace_async + async def create_or_update( self, resource_group_name: str, namespace_name: str, relay_name: str, - authorization_rule_name: str, + parameters: "_models.WcfRelay", **kwargs: Any - ) -> "_models.AuthorizationRule": - """Get authorizationRule for a WCF relay by name. + ) -> "_models.WcfRelay": + """Creates or updates a WCF relay. This operation is idempotent. :param resource_group_name: Name of the Resource group within the Azure subscription. :type resource_group_name: str @@ -545,66 +577,68 @@ async def get_authorization_rule( :type namespace_name: str :param relay_name: The relay name. :type relay_name: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_name: str + :param parameters: Parameters supplied to create a WCF relay. + :type parameters: ~azure.mgmt.relay.models.WcfRelay :keyword callable cls: A custom type or function that will be passed the direct response - :return: AuthorizationRule, or the result of cls(response) - :rtype: ~azure.mgmt.relay.models.AuthorizationRule + :return: WcfRelay, or the result of cls(response) + :rtype: ~azure.mgmt.relay.models.WcfRelay :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AuthorizationRule"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.WcfRelay"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.get_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'relayName': self._serialize.url("relay_name", relay_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'WcfRelay') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + relay_name=relay_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AuthorizationRule', pipeline_response) + deserialized = self._deserialize('WcfRelay', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/wcfRelays/{relayName}/authorizationRules/{authorizationRuleName}'} # type: ignore - async def list_keys( + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/wcfRelays/{relayName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, relay_name: str, - authorization_rule_name: str, **kwargs: Any - ) -> "_models.AccessKeys": - """Primary and secondary connection strings to the WCF relay. + ) -> None: + """Deletes a WCF relay. :param resource_group_name: Name of the Resource group within the Azure subscription. :type resource_group_name: str @@ -612,67 +646,58 @@ async def list_keys( :type namespace_name: str :param relay_name: The relay name. :type relay_name: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) - :rtype: ~azure.mgmt.relay.models.AccessKeys + :return: None, or the result of cls(response) + :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessKeys"] + cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'relayName': self._serialize.url("relay_name", relay_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-11-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + relay_name=relay_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, None, {}) - return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/wcfRelays/{relayName}/authorizationRules/{authorizationRuleName}/listKeys'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/wcfRelays/{relayName}"} # type: ignore - async def regenerate_keys( + + @distributed_trace_async + async def get( self, resource_group_name: str, namespace_name: str, relay_name: str, - authorization_rule_name: str, - parameters: "_models.RegenerateAccessKeyParameters", **kwargs: Any - ) -> "_models.AccessKeys": - """Regenerates the primary or secondary connection strings to the WCF relay. + ) -> Optional["_models.WcfRelay"]: + """Returns the description for the specified WCF relay. :param resource_group_name: Name of the Resource group within the Azure subscription. :type resource_group_name: str @@ -680,60 +705,51 @@ async def regenerate_keys( :type namespace_name: str :param relay_name: The relay name. :type relay_name: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate authorization rule. - :type parameters: ~azure.mgmt.relay.models.RegenerateAccessKeyParameters :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) - :rtype: ~azure.mgmt.relay.models.AccessKeys + :return: WcfRelay, or the result of cls(response) + :rtype: ~azure.mgmt.relay.models.WcfRelay or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessKeys"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WcfRelay"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.regenerate_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'relayName': self._serialize.url("relay_name", relay_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + relay_name=relay_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('WcfRelay', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/wcfRelays/{relayName}/authorizationRules/{authorizationRuleName}/regenerateKeys'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/wcfRelays/{relayName}"} # type: ignore + diff --git a/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/models/__init__.py b/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/models/__init__.py index 9feb1e8435df..ba6329e3e017 100644 --- a/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/models/__init__.py +++ b/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/models/__init__.py @@ -6,56 +6,53 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import AccessKeys - from ._models_py3 import AuthorizationRule - from ._models_py3 import AuthorizationRuleListResult - from ._models_py3 import CheckNameAvailability - from ._models_py3 import CheckNameAvailabilityResult - from ._models_py3 import ErrorResponse - from ._models_py3 import HybridConnection - from ._models_py3 import HybridConnectionListResult - from ._models_py3 import Operation - from ._models_py3 import OperationDisplay - from ._models_py3 import OperationListResult - from ._models_py3 import RegenerateAccessKeyParameters - from ._models_py3 import RelayNamespace - from ._models_py3 import RelayNamespaceListResult - from ._models_py3 import RelayUpdateParameters - from ._models_py3 import Resource - from ._models_py3 import ResourceNamespacePatch - from ._models_py3 import Sku - from ._models_py3 import TrackedResource - from ._models_py3 import WcfRelay - from ._models_py3 import WcfRelaysListResult -except (SyntaxError, ImportError): - from ._models import AccessKeys # type: ignore - from ._models import AuthorizationRule # type: ignore - from ._models import AuthorizationRuleListResult # type: ignore - from ._models import CheckNameAvailability # type: ignore - from ._models import CheckNameAvailabilityResult # type: ignore - from ._models import ErrorResponse # type: ignore - from ._models import HybridConnection # type: ignore - from ._models import HybridConnectionListResult # type: ignore - from ._models import Operation # type: ignore - from ._models import OperationDisplay # type: ignore - from ._models import OperationListResult # type: ignore - from ._models import RegenerateAccessKeyParameters # type: ignore - from ._models import RelayNamespace # type: ignore - from ._models import RelayNamespaceListResult # type: ignore - from ._models import RelayUpdateParameters # type: ignore - from ._models import Resource # type: ignore - from ._models import ResourceNamespacePatch # type: ignore - from ._models import Sku # type: ignore - from ._models import TrackedResource # type: ignore - from ._models import WcfRelay # type: ignore - from ._models import WcfRelaysListResult # type: ignore +from ._models_py3 import AccessKeys +from ._models_py3 import AuthorizationRule +from ._models_py3 import AuthorizationRuleListResult +from ._models_py3 import CheckNameAvailability +from ._models_py3 import CheckNameAvailabilityResult +from ._models_py3 import ConnectionState +from ._models_py3 import ErrorAdditionalInfo +from ._models_py3 import ErrorDetail +from ._models_py3 import ErrorResponse +from ._models_py3 import HybridConnection +from ._models_py3 import HybridConnectionListResult +from ._models_py3 import NWRuleSetIpRules +from ._models_py3 import NetworkRuleSet +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationListResult +from ._models_py3 import PrivateEndpoint +from ._models_py3 import PrivateEndpointConnection +from ._models_py3 import PrivateEndpointConnectionListResult +from ._models_py3 import PrivateLinkResource +from ._models_py3 import PrivateLinkResourcesListResult +from ._models_py3 import ProxyResource +from ._models_py3 import RegenerateAccessKeyParameters +from ._models_py3 import RelayNamespace +from ._models_py3 import RelayNamespaceListResult +from ._models_py3 import RelayUpdateParameters +from ._models_py3 import Resource +from ._models_py3 import ResourceNamespacePatch +from ._models_py3 import Sku +from ._models_py3 import SystemData +from ._models_py3 import TrackedResource +from ._models_py3 import WcfRelay +from ._models_py3 import WcfRelaysListResult + from ._relay_api_enums import ( AccessRights, + CreatedByType, + DefaultAction, + EndPointProvisioningState, KeyType, - ProvisioningStateEnum, + NetworkRuleIPAction, + PrivateLinkConnectionStatus, + PublicNetworkAccess, Relaytype, + SkuName, + SkuTier, UnavailableReason, ) @@ -65,12 +62,23 @@ 'AuthorizationRuleListResult', 'CheckNameAvailability', 'CheckNameAvailabilityResult', + 'ConnectionState', + 'ErrorAdditionalInfo', + 'ErrorDetail', 'ErrorResponse', 'HybridConnection', 'HybridConnectionListResult', + 'NWRuleSetIpRules', + 'NetworkRuleSet', 'Operation', 'OperationDisplay', 'OperationListResult', + 'PrivateEndpoint', + 'PrivateEndpointConnection', + 'PrivateEndpointConnectionListResult', + 'PrivateLinkResource', + 'PrivateLinkResourcesListResult', + 'ProxyResource', 'RegenerateAccessKeyParameters', 'RelayNamespace', 'RelayNamespaceListResult', @@ -78,12 +86,20 @@ 'Resource', 'ResourceNamespacePatch', 'Sku', + 'SystemData', 'TrackedResource', 'WcfRelay', 'WcfRelaysListResult', 'AccessRights', + 'CreatedByType', + 'DefaultAction', + 'EndPointProvisioningState', 'KeyType', - 'ProvisioningStateEnum', + 'NetworkRuleIPAction', + 'PrivateLinkConnectionStatus', + 'PublicNetworkAccess', 'Relaytype', + 'SkuName', + 'SkuTier', 'UnavailableReason', ] diff --git a/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/models/_models.py b/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/models/_models.py deleted file mode 100644 index 1c63266d15fd..000000000000 --- a/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/models/_models.py +++ /dev/null @@ -1,811 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class AccessKeys(msrest.serialization.Model): - """Namespace/Relay Connection String. - - :param primary_connection_string: Primary connection string of the created namespace - authorization rule. - :type primary_connection_string: str - :param secondary_connection_string: Secondary connection string of the created namespace - authorization rule. - :type secondary_connection_string: str - :param primary_key: A base64-encoded 256-bit primary key for signing and validating the SAS - token. - :type primary_key: str - :param secondary_key: A base64-encoded 256-bit secondary key for signing and validating the SAS - token. - :type secondary_key: str - :param key_name: A string that describes the authorization rule. - :type key_name: str - """ - - _attribute_map = { - 'primary_connection_string': {'key': 'primaryConnectionString', 'type': 'str'}, - 'secondary_connection_string': {'key': 'secondaryConnectionString', 'type': 'str'}, - 'primary_key': {'key': 'primaryKey', 'type': 'str'}, - 'secondary_key': {'key': 'secondaryKey', 'type': 'str'}, - 'key_name': {'key': 'keyName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AccessKeys, self).__init__(**kwargs) - self.primary_connection_string = kwargs.get('primary_connection_string', None) - self.secondary_connection_string = kwargs.get('secondary_connection_string', None) - self.primary_key = kwargs.get('primary_key', None) - self.secondary_key = kwargs.get('secondary_key', None) - self.key_name = kwargs.get('key_name', None) - - -class Resource(msrest.serialization.Model): - """The resource definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Resource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class AuthorizationRule(Resource): - """Description of a namespace authorization rule. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param rights: Required. The rights associated with the rule. - :type rights: list[str or ~azure.mgmt.relay.models.AccessRights] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'rights': {'required': True, 'unique': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'rights': {'key': 'properties.rights', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(AuthorizationRule, self).__init__(**kwargs) - self.rights = kwargs['rights'] - - -class AuthorizationRuleListResult(msrest.serialization.Model): - """The response from the list namespace operation. - - :param value: Result of the list authorization rules operation. - :type value: list[~azure.mgmt.relay.models.AuthorizationRule] - :param next_link: Link to the next set of results. Not empty if value contains incomplete list - of authorization rules. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[AuthorizationRule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AuthorizationRuleListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class CheckNameAvailability(msrest.serialization.Model): - """Description of the check name availability request properties. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. The namespace name to check for availability. The namespace name can - contain only letters, numbers, and hyphens. The namespace must start with a letter, and it must - end with a letter or number. - :type name: str - """ - - _validation = { - 'name': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CheckNameAvailability, self).__init__(**kwargs) - self.name = kwargs['name'] - - -class CheckNameAvailabilityResult(msrest.serialization.Model): - """Description of the check name availability request properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar message: The detailed info regarding the reason associated with the namespace. - :vartype message: str - :param name_available: Value indicating namespace is available. Returns true if the namespace - is available; otherwise, false. - :type name_available: bool - :param reason: The reason for unavailability of a namespace. Possible values include: "None", - "InvalidName", "SubscriptionIsDisabled", "NameInUse", "NameInLockdown", - "TooManyNamespaceInCurrentSubscription". - :type reason: str or ~azure.mgmt.relay.models.UnavailableReason - """ - - _validation = { - 'message': {'readonly': True}, - } - - _attribute_map = { - 'message': {'key': 'message', 'type': 'str'}, - 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, - 'reason': {'key': 'reason', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CheckNameAvailabilityResult, self).__init__(**kwargs) - self.message = None - self.name_available = kwargs.get('name_available', None) - self.reason = kwargs.get('reason', None) - - -class ErrorResponse(msrest.serialization.Model): - """Error reponse indicates Relay service is not able to process the incoming request. The reason is provided in the error message. - - :param code: Error code. - :type code: str - :param message: Error message indicating why the operation failed. - :type message: str - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - - -class HybridConnection(Resource): - """Description of hybrid connection resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar created_at: The time the hybrid connection was created. - :vartype created_at: ~datetime.datetime - :ivar updated_at: The time the namespace was updated. - :vartype updated_at: ~datetime.datetime - :ivar listener_count: The number of listeners for this hybrid connection. Note that min : 1 and - max:25 are supported. - :vartype listener_count: int - :param requires_client_authorization: Returns true if client authorization is needed for this - hybrid connection; otherwise, false. - :type requires_client_authorization: bool - :param user_metadata: The usermetadata is a placeholder to store user-defined string data for - the hybrid connection endpoint. For example, it can be used to store descriptive data, such as - a list of teams and their contact information. Also, user-defined configuration settings can be - stored. - :type user_metadata: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'created_at': {'readonly': True}, - 'updated_at': {'readonly': True}, - 'listener_count': {'readonly': True, 'maximum': 25, 'minimum': 0}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, - 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, - 'listener_count': {'key': 'properties.listenerCount', 'type': 'int'}, - 'requires_client_authorization': {'key': 'properties.requiresClientAuthorization', 'type': 'bool'}, - 'user_metadata': {'key': 'properties.userMetadata', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(HybridConnection, self).__init__(**kwargs) - self.created_at = None - self.updated_at = None - self.listener_count = None - self.requires_client_authorization = kwargs.get('requires_client_authorization', None) - self.user_metadata = kwargs.get('user_metadata', None) - - -class HybridConnectionListResult(msrest.serialization.Model): - """The response of the list hybrid connection operation. - - :param value: Result of the list hybrid connections. - :type value: list[~azure.mgmt.relay.models.HybridConnection] - :param next_link: Link to the next set of results. Not empty if value contains incomplete list - hybrid connection operation. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[HybridConnection]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(HybridConnectionListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class Operation(msrest.serialization.Model): - """A Relay REST API operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Operation name: {provider}/{resource}/{operation}. - :vartype name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.relay.models.OperationDisplay - """ - - _validation = { - 'name': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - } - - def __init__( - self, - **kwargs - ): - super(Operation, self).__init__(**kwargs) - self.name = None - self.display = kwargs.get('display', None) - - -class OperationDisplay(msrest.serialization.Model): - """The object that represents the operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provider: Service provider: Relay. - :vartype provider: str - :ivar resource: Resource on which the operation is performed: Invoice, etc. - :vartype resource: str - :ivar operation: Operation type: Read, write, delete, etc. - :vartype operation: str - """ - - _validation = { - 'provider': {'readonly': True}, - 'resource': {'readonly': True}, - 'operation': {'readonly': True}, - } - - _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationDisplay, self).__init__(**kwargs) - self.provider = None - self.resource = None - self.operation = None - - -class OperationListResult(msrest.serialization.Model): - """Result of the request to list Relay operations. It contains a list of operations and a URL link to get the next set of results. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: List of Relay operations supported by resource provider. - :vartype value: list[~azure.mgmt.relay.models.Operation] - :ivar next_link: URL to get the next set of operation list results if there are any. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class RegenerateAccessKeyParameters(msrest.serialization.Model): - """Parameters supplied to the regenerate authorization rule operation, specifies which key neeeds to be reset. - - All required parameters must be populated in order to send to Azure. - - :param key_type: Required. The access key to regenerate. Possible values include: "PrimaryKey", - "SecondaryKey". - :type key_type: str or ~azure.mgmt.relay.models.KeyType - :param key: Optional. If the key value is provided, this is set to key type, or autogenerated - key value set for key type. - :type key: str - """ - - _validation = { - 'key_type': {'required': True}, - } - - _attribute_map = { - 'key_type': {'key': 'keyType', 'type': 'str'}, - 'key': {'key': 'key', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RegenerateAccessKeyParameters, self).__init__(**kwargs) - self.key_type = kwargs['key_type'] - self.key = kwargs.get('key', None) - - -class TrackedResource(Resource): - """Definition of resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(TrackedResource, self).__init__(**kwargs) - self.location = kwargs['location'] - self.tags = kwargs.get('tags', None) - - -class RelayNamespace(TrackedResource): - """Description of a namespace resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param sku: SKU of the namespace. - :type sku: ~azure.mgmt.relay.models.Sku - :ivar provisioning_state: Possible values include: "Created", "Succeeded", "Deleted", - "Failed", "Updating", "Unknown". - :vartype provisioning_state: str or ~azure.mgmt.relay.models.ProvisioningStateEnum - :ivar created_at: The time the namespace was created. - :vartype created_at: ~datetime.datetime - :ivar updated_at: The time the namespace was updated. - :vartype updated_at: ~datetime.datetime - :ivar service_bus_endpoint: Endpoint you can use to perform Service Bus operations. - :vartype service_bus_endpoint: str - :ivar metric_id: Identifier for Azure Insights metrics. - :vartype metric_id: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'provisioning_state': {'readonly': True}, - 'created_at': {'readonly': True}, - 'updated_at': {'readonly': True}, - 'service_bus_endpoint': {'readonly': True}, - 'metric_id': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, - 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, - 'service_bus_endpoint': {'key': 'properties.serviceBusEndpoint', 'type': 'str'}, - 'metric_id': {'key': 'properties.metricId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RelayNamespace, self).__init__(**kwargs) - self.sku = kwargs.get('sku', None) - self.provisioning_state = None - self.created_at = None - self.updated_at = None - self.service_bus_endpoint = None - self.metric_id = None - - -class RelayNamespaceListResult(msrest.serialization.Model): - """The response from the list namespace operation. - - :param value: Result of the list namespace operation. - :type value: list[~azure.mgmt.relay.models.RelayNamespace] - :param next_link: Link to the next set of results. Not empty if value contains incomplete list - of namespaces. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[RelayNamespace]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RelayNamespaceListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class ResourceNamespacePatch(Resource): - """Definition of resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceNamespacePatch, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - - -class RelayUpdateParameters(ResourceNamespacePatch): - """Description of a namespace resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param sku: SKU of the namespace. - :type sku: ~azure.mgmt.relay.models.Sku - :ivar provisioning_state: Possible values include: "Created", "Succeeded", "Deleted", - "Failed", "Updating", "Unknown". - :vartype provisioning_state: str or ~azure.mgmt.relay.models.ProvisioningStateEnum - :ivar created_at: The time the namespace was created. - :vartype created_at: ~datetime.datetime - :ivar updated_at: The time the namespace was updated. - :vartype updated_at: ~datetime.datetime - :ivar service_bus_endpoint: Endpoint you can use to perform Service Bus operations. - :vartype service_bus_endpoint: str - :ivar metric_id: Identifier for Azure Insights metrics. - :vartype metric_id: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'created_at': {'readonly': True}, - 'updated_at': {'readonly': True}, - 'service_bus_endpoint': {'readonly': True}, - 'metric_id': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, - 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, - 'service_bus_endpoint': {'key': 'properties.serviceBusEndpoint', 'type': 'str'}, - 'metric_id': {'key': 'properties.metricId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RelayUpdateParameters, self).__init__(**kwargs) - self.sku = kwargs.get('sku', None) - self.provisioning_state = None - self.created_at = None - self.updated_at = None - self.service_bus_endpoint = None - self.metric_id = None - - -class Sku(msrest.serialization.Model): - """SKU of the namespace. - - 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 name: Name of this SKU. Has constant value: "Standard". - :vartype name: str - :param tier: The tier of this SKU. The only acceptable values to pass in are None and - "Standard". The default value is None. - :type tier: str - """ - - _validation = { - 'name': {'required': True, 'constant': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - } - - name = "Standard" - - def __init__( - self, - **kwargs - ): - super(Sku, self).__init__(**kwargs) - self.tier = kwargs.get('tier', None) - - -class WcfRelay(Resource): - """Description of the WCF relay resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar is_dynamic: Returns true if the relay is dynamic; otherwise, false. - :vartype is_dynamic: bool - :ivar created_at: The time the WCF relay was created. - :vartype created_at: ~datetime.datetime - :ivar updated_at: The time the namespace was updated. - :vartype updated_at: ~datetime.datetime - :ivar listener_count: The number of listeners for this relay. Note that min :1 and max:25 are - supported. - :vartype listener_count: int - :param relay_type: WCF relay type. Possible values include: "NetTcp", "Http". - :type relay_type: str or ~azure.mgmt.relay.models.Relaytype - :param requires_client_authorization: Returns true if client authorization is needed for this - relay; otherwise, false. - :type requires_client_authorization: bool - :param requires_transport_security: Returns true if transport security is needed for this - relay; otherwise, false. - :type requires_transport_security: bool - :param user_metadata: The usermetadata is a placeholder to store user-defined string data for - the WCF Relay endpoint. For example, it can be used to store descriptive data, such as list of - teams and their contact information. Also, user-defined configuration settings can be stored. - :type user_metadata: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'is_dynamic': {'readonly': True}, - 'created_at': {'readonly': True}, - 'updated_at': {'readonly': True}, - 'listener_count': {'readonly': True, 'maximum': 25, 'minimum': 0}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'is_dynamic': {'key': 'properties.isDynamic', 'type': 'bool'}, - 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, - 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, - 'listener_count': {'key': 'properties.listenerCount', 'type': 'int'}, - 'relay_type': {'key': 'properties.relayType', 'type': 'str'}, - 'requires_client_authorization': {'key': 'properties.requiresClientAuthorization', 'type': 'bool'}, - 'requires_transport_security': {'key': 'properties.requiresTransportSecurity', 'type': 'bool'}, - 'user_metadata': {'key': 'properties.userMetadata', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(WcfRelay, self).__init__(**kwargs) - self.is_dynamic = None - self.created_at = None - self.updated_at = None - self.listener_count = None - self.relay_type = kwargs.get('relay_type', None) - self.requires_client_authorization = kwargs.get('requires_client_authorization', None) - self.requires_transport_security = kwargs.get('requires_transport_security', None) - self.user_metadata = kwargs.get('user_metadata', None) - - -class WcfRelaysListResult(msrest.serialization.Model): - """The response of the list WCF relay operation. - - :param value: Result of the list WCF relay operation. - :type value: list[~azure.mgmt.relay.models.WcfRelay] - :param next_link: Link to the next set of results. Not empty if value contains incomplete list - of WCF relays. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[WcfRelay]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(WcfRelaysListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) diff --git a/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/models/_models_py3.py b/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/models/_models_py3.py index 03221951b2dd..6de78207936e 100644 --- a/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/models/_models_py3.py +++ b/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/models/_models_py3.py @@ -6,7 +6,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Dict, List, Optional, Union +import datetime +from typing import Any, Dict, List, Optional, Union from azure.core.exceptions import HttpResponseError import msrest.serialization @@ -17,20 +18,20 @@ class AccessKeys(msrest.serialization.Model): """Namespace/Relay Connection String. - :param primary_connection_string: Primary connection string of the created namespace + :ivar primary_connection_string: Primary connection string of the created namespace authorization rule. - :type primary_connection_string: str - :param secondary_connection_string: Secondary connection string of the created namespace + :vartype primary_connection_string: str + :ivar secondary_connection_string: Secondary connection string of the created namespace authorization rule. - :type secondary_connection_string: str - :param primary_key: A base64-encoded 256-bit primary key for signing and validating the SAS + :vartype secondary_connection_string: str + :ivar primary_key: A base64-encoded 256-bit primary key for signing and validating the SAS token. - :type primary_key: str - :param secondary_key: A base64-encoded 256-bit secondary key for signing and validating the SAS + :vartype primary_key: str + :ivar secondary_key: A base64-encoded 256-bit secondary key for signing and validating the SAS token. - :type secondary_key: str - :param key_name: A string that describes the authorization rule. - :type key_name: str + :vartype secondary_key: str + :ivar key_name: A string that describes the authorization rule. + :vartype key_name: str """ _attribute_map = { @@ -51,6 +52,22 @@ def __init__( key_name: Optional[str] = None, **kwargs ): + """ + :keyword primary_connection_string: Primary connection string of the created namespace + authorization rule. + :paramtype primary_connection_string: str + :keyword secondary_connection_string: Secondary connection string of the created namespace + authorization rule. + :paramtype secondary_connection_string: str + :keyword primary_key: A base64-encoded 256-bit primary key for signing and validating the SAS + token. + :paramtype primary_key: str + :keyword secondary_key: A base64-encoded 256-bit secondary key for signing and validating the + SAS token. + :paramtype secondary_key: str + :keyword key_name: A string that describes the authorization rule. + :paramtype key_name: str + """ super(AccessKeys, self).__init__(**kwargs) self.primary_connection_string = primary_connection_string self.secondary_connection_string = secondary_connection_string @@ -59,90 +76,111 @@ def __init__( self.key_name = key_name -class Resource(msrest.serialization.Model): - """The resource definition. +class ProxyResource(msrest.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. - :ivar id: Resource ID. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type. + :ivar type: The type of the resource. E.g. "Microsoft.EventHub/Namespaces" or + "Microsoft.EventHub/Namespaces/EventHubs". :vartype type: str + :ivar location: The geo-location where the resource lives. + :vartype location: str """ _validation = { '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'}, } def __init__( self, **kwargs ): - super(Resource, self).__init__(**kwargs) + """ + """ + super(ProxyResource, self).__init__(**kwargs) self.id = None self.name = None self.type = None + self.location = None -class AuthorizationRule(Resource): - """Description of a namespace authorization rule. +class AuthorizationRule(ProxyResource): + """Single item in a List or Get AuthorizationRule 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 id: Resource ID. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type. + :ivar type: The type of the resource. E.g. "Microsoft.EventHub/Namespaces" or + "Microsoft.EventHub/Namespaces/EventHubs". :vartype type: str - :param rights: Required. The rights associated with the rule. - :type rights: list[str or ~azure.mgmt.relay.models.AccessRights] + :ivar location: The geo-location where the resource lives. + :vartype location: str + :ivar system_data: The system meta data relating to this resource. + :vartype system_data: ~azure.mgmt.relay.models.SystemData + :ivar rights: The rights associated with the rule. + :vartype rights: list[str or ~azure.mgmt.relay.models.AccessRights] """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'rights': {'required': True, 'unique': 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]'}, } def __init__( self, *, - rights: List[Union[str, "AccessRights"]], + rights: Optional[List[Union[str, "AccessRights"]]] = None, **kwargs ): + """ + :keyword rights: The rights associated with the rule. + :paramtype rights: list[str or ~azure.mgmt.relay.models.AccessRights] + """ super(AuthorizationRule, self).__init__(**kwargs) + self.system_data = None self.rights = rights class AuthorizationRuleListResult(msrest.serialization.Model): """The response from the list namespace operation. - :param value: Result of the list authorization rules operation. - :type value: list[~azure.mgmt.relay.models.AuthorizationRule] - :param next_link: Link to the next set of results. Not empty if value contains incomplete list + :ivar value: Result of the list authorization rules operation. + :vartype value: list[~azure.mgmt.relay.models.AuthorizationRule] + :ivar next_link: Link to the next set of results. Not empty if value contains incomplete list of authorization rules. - :type next_link: str + :vartype next_link: str """ _attribute_map = { @@ -157,6 +195,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Result of the list authorization rules operation. + :paramtype value: list[~azure.mgmt.relay.models.AuthorizationRule] + :keyword next_link: Link to the next set of results. Not empty if value contains incomplete + list of authorization rules. + :paramtype next_link: str + """ super(AuthorizationRuleListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -167,10 +212,10 @@ class CheckNameAvailability(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The namespace name to check for availability. The namespace name can + :ivar name: Required. The namespace name to check for availability. The namespace name can contain only letters, numbers, and hyphens. The namespace must start with a letter, and it must end with a letter or number. - :type name: str + :vartype name: str """ _validation = { @@ -187,6 +232,12 @@ def __init__( name: str, **kwargs ): + """ + :keyword name: Required. The namespace name to check for availability. The namespace name can + contain only letters, numbers, and hyphens. The namespace must start with a letter, and it must + end with a letter or number. + :paramtype name: str + """ super(CheckNameAvailability, self).__init__(**kwargs) self.name = name @@ -198,13 +249,13 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): :ivar message: The detailed info regarding the reason associated with the namespace. :vartype message: str - :param name_available: Value indicating namespace is available. Returns true if the namespace - is available; otherwise, false. - :type name_available: bool - :param reason: The reason for unavailability of a namespace. Possible values include: "None", + :ivar name_available: Value indicating namespace is available. Returns true if the namespace is + available; otherwise, false. + :vartype name_available: bool + :ivar reason: The reason for unavailability of a namespace. Possible values include: "None", "InvalidName", "SubscriptionIsDisabled", "NameInUse", "NameInLockdown", "TooManyNamespaceInCurrentSubscription". - :type reason: str or ~azure.mgmt.relay.models.UnavailableReason + :vartype reason: str or ~azure.mgmt.relay.models.UnavailableReason """ _validation = { @@ -224,49 +275,176 @@ def __init__( reason: Optional[Union[str, "UnavailableReason"]] = None, **kwargs ): + """ + :keyword name_available: Value indicating namespace is available. Returns true if the namespace + is available; otherwise, false. + :paramtype name_available: bool + :keyword reason: The reason for unavailability of a namespace. Possible values include: "None", + "InvalidName", "SubscriptionIsDisabled", "NameInUse", "NameInLockdown", + "TooManyNamespaceInCurrentSubscription". + :paramtype reason: str or ~azure.mgmt.relay.models.UnavailableReason + """ super(CheckNameAvailabilityResult, self).__init__(**kwargs) self.message = None self.name_available = name_available self.reason = reason -class ErrorResponse(msrest.serialization.Model): - """Error reponse indicates Relay service is not able to process the incoming request. The reason is provided in the error message. +class ConnectionState(msrest.serialization.Model): + """ConnectionState information. - :param code: Error code. - :type code: str - :param message: Error message indicating why the operation failed. - :type message: str + :ivar status: Status of the connection. Possible values include: "Pending", "Approved", + "Rejected", "Disconnected". + :vartype status: str or ~azure.mgmt.relay.models.PrivateLinkConnectionStatus + :ivar description: Description of the connection state. + :vartype description: str """ + _attribute_map = { + 'status': {'key': 'status', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + } + + def __init__( + self, + *, + status: Optional[Union[str, "PrivateLinkConnectionStatus"]] = None, + description: Optional[str] = None, + **kwargs + ): + """ + :keyword status: Status of the connection. Possible values include: "Pending", "Approved", + "Rejected", "Disconnected". + :paramtype status: str or ~azure.mgmt.relay.models.PrivateLinkConnectionStatus + :keyword description: Description of the connection state. + :paramtype description: str + """ + super(ConnectionState, self).__init__(**kwargs) + self.status = status + self.description = description + + +class ErrorAdditionalInfo(msrest.serialization.Model): + """The resource management error additional info. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar type: The additional info type. + :vartype type: str + :ivar info: The additional info. + :vartype info: any + """ + + _validation = { + 'type': {'readonly': True}, + 'info': {'readonly': True}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'info': {'key': 'info', 'type': 'object'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(ErrorAdditionalInfo, self).__init__(**kwargs) + self.type = None + self.info = None + + +class ErrorDetail(msrest.serialization.Model): + """The error detail. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: The error code. + :vartype code: str + :ivar message: The error message. + :vartype message: str + :ivar target: The error target. + :vartype target: str + :ivar details: The error details. + :vartype details: list[~azure.mgmt.relay.models.ErrorDetail] + :ivar additional_info: The error additional info. + :vartype additional_info: list[~azure.mgmt.relay.models.ErrorAdditionalInfo] + """ + + _validation = { + 'code': {'readonly': True}, + 'message': {'readonly': True}, + 'target': {'readonly': True}, + 'details': {'readonly': True}, + 'additional_info': {'readonly': True}, + } + _attribute_map = { 'code': {'key': 'code', 'type': 'str'}, 'message': {'key': 'message', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'str'}, + 'details': {'key': 'details', 'type': '[ErrorDetail]'}, + 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(ErrorDetail, self).__init__(**kwargs) + self.code = None + self.message = None + self.target = None + self.details = None + self.additional_info = None + + +class ErrorResponse(msrest.serialization.Model): + """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). + + :ivar error: The error object. + :vartype error: ~azure.mgmt.relay.models.ErrorDetail + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorDetail'}, } def __init__( self, *, - code: Optional[str] = None, - message: Optional[str] = None, + error: Optional["ErrorDetail"] = None, **kwargs ): + """ + :keyword error: The error object. + :paramtype error: ~azure.mgmt.relay.models.ErrorDetail + """ super(ErrorResponse, self).__init__(**kwargs) - self.code = code - self.message = message + self.error = error -class HybridConnection(Resource): +class HybridConnection(ProxyResource): """Description of hybrid connection resource. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type. + :ivar type: The type of the resource. E.g. "Microsoft.EventHub/Namespaces" or + "Microsoft.EventHub/Namespaces/EventHubs". :vartype type: str + :ivar location: The geo-location where the resource lives. + :vartype location: str + :ivar system_data: The system meta data relating to this resource. + :vartype system_data: ~azure.mgmt.relay.models.SystemData :ivar created_at: The time the hybrid connection was created. :vartype created_at: ~datetime.datetime :ivar updated_at: The time the namespace was updated. @@ -274,20 +452,22 @@ class HybridConnection(Resource): :ivar listener_count: The number of listeners for this hybrid connection. Note that min : 1 and max:25 are supported. :vartype listener_count: int - :param requires_client_authorization: Returns true if client authorization is needed for this + :ivar requires_client_authorization: Returns true if client authorization is needed for this hybrid connection; otherwise, false. - :type requires_client_authorization: bool - :param user_metadata: The usermetadata is a placeholder to store user-defined string data for + :vartype requires_client_authorization: bool + :ivar user_metadata: The usermetadata is a placeholder to store user-defined string data for the hybrid connection endpoint. For example, it can be used to store descriptive data, such as a list of teams and their contact information. Also, user-defined configuration settings can be stored. - :type user_metadata: str + :vartype user_metadata: str """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, + 'location': {'readonly': True}, + 'system_data': {'readonly': True}, 'created_at': {'readonly': True}, 'updated_at': {'readonly': True}, 'listener_count': {'readonly': True, 'maximum': 25, 'minimum': 0}, @@ -297,6 +477,8 @@ class HybridConnection(Resource): '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'}, 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, 'listener_count': {'key': 'properties.listenerCount', 'type': 'int'}, @@ -311,7 +493,18 @@ def __init__( user_metadata: Optional[str] = None, **kwargs ): + """ + :keyword requires_client_authorization: Returns true if client authorization is needed for this + hybrid connection; otherwise, false. + :paramtype requires_client_authorization: bool + :keyword user_metadata: The usermetadata is a placeholder to store user-defined string data for + the hybrid connection endpoint. For example, it can be used to store descriptive data, such as + a list of teams and their contact information. Also, user-defined configuration settings can be + stored. + :paramtype user_metadata: str + """ super(HybridConnection, self).__init__(**kwargs) + self.system_data = None self.created_at = None self.updated_at = None self.listener_count = None @@ -322,11 +515,11 @@ def __init__( class HybridConnectionListResult(msrest.serialization.Model): """The response of the list hybrid connection operation. - :param value: Result of the list hybrid connections. - :type value: list[~azure.mgmt.relay.models.HybridConnection] - :param next_link: Link to the next set of results. Not empty if value contains incomplete list + :ivar value: Result of the list hybrid connections. + :vartype value: list[~azure.mgmt.relay.models.HybridConnection] + :ivar next_link: Link to the next set of results. Not empty if value contains incomplete list hybrid connection operation. - :type next_link: str + :vartype next_link: str """ _attribute_map = { @@ -341,11 +534,143 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Result of the list hybrid connections. + :paramtype value: list[~azure.mgmt.relay.models.HybridConnection] + :keyword next_link: Link to the next set of results. Not empty if value contains incomplete + list hybrid connection operation. + :paramtype next_link: str + """ super(HybridConnectionListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link +class Resource(msrest.serialization.Model): + """The resource definition. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(Resource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + + +class NetworkRuleSet(Resource): + """Description of topic resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar system_data: The system meta data relating to this resource. + :vartype system_data: ~azure.mgmt.relay.models.SystemData + :ivar default_action: Default Action for Network Rule Set. Possible values include: "Allow", + "Deny". + :vartype default_action: str or ~azure.mgmt.relay.models.DefaultAction + :ivar ip_rules: List of IpRules. + :vartype ip_rules: list[~azure.mgmt.relay.models.NWRuleSetIpRules] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'default_action': {'key': 'properties.defaultAction', 'type': 'str'}, + 'ip_rules': {'key': 'properties.ipRules', 'type': '[NWRuleSetIpRules]'}, + } + + def __init__( + self, + *, + default_action: Optional[Union[str, "DefaultAction"]] = None, + ip_rules: Optional[List["NWRuleSetIpRules"]] = None, + **kwargs + ): + """ + :keyword default_action: Default Action for Network Rule Set. Possible values include: "Allow", + "Deny". + :paramtype default_action: str or ~azure.mgmt.relay.models.DefaultAction + :keyword ip_rules: List of IpRules. + :paramtype ip_rules: list[~azure.mgmt.relay.models.NWRuleSetIpRules] + """ + super(NetworkRuleSet, self).__init__(**kwargs) + self.system_data = None + self.default_action = default_action + self.ip_rules = ip_rules + + +class NWRuleSetIpRules(msrest.serialization.Model): + """The response from the List namespace operation. + + :ivar ip_mask: IP Mask. + :vartype ip_mask: str + :ivar action: The IP Filter Action. Possible values include: "Allow". + :vartype action: str or ~azure.mgmt.relay.models.NetworkRuleIPAction + """ + + _attribute_map = { + 'ip_mask': {'key': 'ipMask', 'type': 'str'}, + 'action': {'key': 'action', 'type': 'str'}, + } + + def __init__( + self, + *, + ip_mask: Optional[str] = None, + action: Optional[Union[str, "NetworkRuleIPAction"]] = None, + **kwargs + ): + """ + :keyword ip_mask: IP Mask. + :paramtype ip_mask: str + :keyword action: The IP Filter Action. Possible values include: "Allow". + :paramtype action: str or ~azure.mgmt.relay.models.NetworkRuleIPAction + """ + super(NWRuleSetIpRules, self).__init__(**kwargs) + self.ip_mask = ip_mask + self.action = action + + class Operation(msrest.serialization.Model): """A Relay REST API operation. @@ -353,63 +678,89 @@ class Operation(msrest.serialization.Model): :ivar name: Operation name: {provider}/{resource}/{operation}. :vartype name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.relay.models.OperationDisplay + :ivar is_data_action: Indicates whether the operation is a data action. + :vartype is_data_action: bool + :ivar display: Display of the operation. + :vartype display: ~azure.mgmt.relay.models.OperationDisplay + :ivar origin: Origin of the operation. + :vartype origin: str + :ivar properties: Properties of the operation. + :vartype properties: any """ _validation = { 'name': {'readonly': True}, + 'is_data_action': {'readonly': True}, + 'display': {'readonly': True}, + 'origin': {'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'}, } def __init__( self, *, - display: Optional["OperationDisplay"] = None, + properties: Optional[Any] = None, **kwargs ): + """ + :keyword properties: Properties of the operation. + :paramtype properties: any + """ super(Operation, self).__init__(**kwargs) self.name = None - self.display = display + self.is_data_action = None + self.display = None + self.origin = None + self.properties = properties class OperationDisplay(msrest.serialization.Model): - """The object that represents the operation. + """Operation display payload. Variables are only populated by the server, and will be ignored when sending a request. - :ivar provider: Service provider: Relay. + :ivar provider: Resource provider of the operation. :vartype provider: str - :ivar resource: Resource on which the operation is performed: Invoice, etc. + :ivar resource: Resource of the operation. :vartype resource: str - :ivar operation: Operation type: Read, write, delete, etc. + :ivar operation: Localized friendly name for the operation. :vartype operation: str + :ivar description: Localized friendly description for the operation. + :vartype description: str """ _validation = { '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'}, } def __init__( self, **kwargs ): + """ + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = None self.resource = None self.operation = None + self.description = None class OperationListResult(msrest.serialization.Model): @@ -417,7 +768,7 @@ class OperationListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar value: List of Relay operations supported by resource provider. + :ivar value: List of Relay operations supported by the Microsoft.EventHub resource provider. :vartype value: list[~azure.mgmt.relay.models.Operation] :ivar next_link: URL to get the next set of operation list results if there are any. :vartype next_link: str @@ -437,22 +788,242 @@ def __init__( self, **kwargs ): + """ + """ super(OperationListResult, self).__init__(**kwargs) self.value = None self.next_link = None +class PrivateEndpoint(msrest.serialization.Model): + """PrivateEndpoint information. + + :ivar id: The ARM identifier for Private Endpoint. + :vartype id: str + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + } + + def __init__( + self, + *, + id: Optional[str] = None, + **kwargs + ): + """ + :keyword id: The ARM identifier for Private Endpoint. + :paramtype id: str + """ + super(PrivateEndpoint, self).__init__(**kwargs) + self.id = id + + +class PrivateEndpointConnection(ProxyResource): + """Properties of the PrivateEndpointConnection. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.EventHub/Namespaces" or + "Microsoft.EventHub/Namespaces/EventHubs". + :vartype type: str + :ivar location: The geo-location where the resource lives. + :vartype location: str + :ivar system_data: The system meta data relating to this resource. + :vartype system_data: ~azure.mgmt.relay.models.SystemData + :ivar private_endpoint: The Private Endpoint resource for this Connection. + :vartype private_endpoint: ~azure.mgmt.relay.models.PrivateEndpoint + :ivar private_link_service_connection_state: Details about the state of the connection. + :vartype private_link_service_connection_state: ~azure.mgmt.relay.models.ConnectionState + :ivar provisioning_state: Provisioning state of the Private Endpoint Connection. Possible + values include: "Creating", "Updating", "Deleting", "Succeeded", "Canceled", "Failed". + :vartype provisioning_state: str or ~azure.mgmt.relay.models.EndPointProvisioningState + """ + + _validation = { + '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'}, + } + + def __init__( + self, + *, + private_endpoint: Optional["PrivateEndpoint"] = None, + private_link_service_connection_state: Optional["ConnectionState"] = None, + provisioning_state: Optional[Union[str, "EndPointProvisioningState"]] = None, + **kwargs + ): + """ + :keyword private_endpoint: The Private Endpoint resource for this Connection. + :paramtype private_endpoint: ~azure.mgmt.relay.models.PrivateEndpoint + :keyword private_link_service_connection_state: Details about the state of the connection. + :paramtype private_link_service_connection_state: ~azure.mgmt.relay.models.ConnectionState + :keyword provisioning_state: Provisioning state of the Private Endpoint Connection. Possible + values include: "Creating", "Updating", "Deleting", "Succeeded", "Canceled", "Failed". + :paramtype provisioning_state: str or ~azure.mgmt.relay.models.EndPointProvisioningState + """ + super(PrivateEndpointConnection, self).__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): + """Result of the list of all private endpoint connections operation. + + :ivar value: A collection of private endpoint connection resources. + :vartype value: list[~azure.mgmt.relay.models.PrivateEndpointConnection] + :ivar next_link: A link for the next page of private endpoint connection resources. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[PrivateEndpointConnection]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["PrivateEndpointConnection"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: A collection of private endpoint connection resources. + :paramtype value: list[~azure.mgmt.relay.models.PrivateEndpointConnection] + :keyword next_link: A link for the next page of private endpoint connection resources. + :paramtype next_link: str + """ + super(PrivateEndpointConnectionListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class PrivateLinkResource(msrest.serialization.Model): + """Information of the private link resource. + + :ivar id: Fully qualified identifier of the resource. + :vartype id: str + :ivar name: Name of the resource. + :vartype name: str + :ivar type: Type of the resource. + :vartype type: str + :ivar group_id: The private link resource group id. + :vartype group_id: str + :ivar required_members: The private link resource required member names. + :vartype required_members: list[str] + :ivar required_zone_names: The private link resource Private link DNS zone name. + :vartype required_zone_names: list[str] + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'group_id': {'key': 'properties.groupId', 'type': 'str'}, + 'required_members': {'key': 'properties.requiredMembers', 'type': '[str]'}, + 'required_zone_names': {'key': 'properties.requiredZoneNames', 'type': '[str]'}, + } + + def __init__( + self, + *, + id: Optional[str] = None, + name: Optional[str] = None, + type: Optional[str] = None, + group_id: Optional[str] = None, + required_members: Optional[List[str]] = None, + required_zone_names: Optional[List[str]] = None, + **kwargs + ): + """ + :keyword id: Fully qualified identifier of the resource. + :paramtype id: str + :keyword name: Name of the resource. + :paramtype name: str + :keyword type: Type of the resource. + :paramtype type: str + :keyword group_id: The private link resource group id. + :paramtype group_id: str + :keyword required_members: The private link resource required member names. + :paramtype required_members: list[str] + :keyword required_zone_names: The private link resource Private link DNS zone name. + :paramtype required_zone_names: list[str] + """ + super(PrivateLinkResource, self).__init__(**kwargs) + self.id = id + self.name = name + self.type = type + self.group_id = group_id + self.required_members = required_members + self.required_zone_names = required_zone_names + + +class PrivateLinkResourcesListResult(msrest.serialization.Model): + """Result of the List private link resources operation. + + :ivar value: A collection of private link resources. + :vartype value: list[~azure.mgmt.relay.models.PrivateLinkResource] + :ivar next_link: A link for the next page of private link resources. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[PrivateLinkResource]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["PrivateLinkResource"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: A collection of private link resources. + :paramtype value: list[~azure.mgmt.relay.models.PrivateLinkResource] + :keyword next_link: A link for the next page of private link resources. + :paramtype next_link: str + """ + super(PrivateLinkResourcesListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + class RegenerateAccessKeyParameters(msrest.serialization.Model): - """Parameters supplied to the regenerate authorization rule operation, specifies which key neeeds to be reset. + """Parameters supplied to the regenerate authorization rule operation, specifies which key needs to be reset. All required parameters must be populated in order to send to Azure. - :param key_type: Required. The access key to regenerate. Possible values include: "PrimaryKey", + :ivar key_type: Required. The access key to regenerate. Possible values include: "PrimaryKey", "SecondaryKey". - :type key_type: str or ~azure.mgmt.relay.models.KeyType - :param key: Optional. If the key value is provided, this is set to key type, or autogenerated + :vartype key_type: str or ~azure.mgmt.relay.models.KeyType + :ivar key: Optional. If the key value is provided, this is set to key type, or autogenerated key value set for key type. - :type key: str + :vartype key: str """ _validation = { @@ -471,6 +1042,14 @@ def __init__( key: Optional[str] = None, **kwargs ): + """ + :keyword key_type: Required. The access key to regenerate. Possible values include: + "PrimaryKey", "SecondaryKey". + :paramtype key_type: str or ~azure.mgmt.relay.models.KeyType + :keyword key: Optional. If the key value is provided, this is set to key type, or autogenerated + key value set for key type. + :paramtype key: str + """ super(RegenerateAccessKeyParameters, self).__init__(**kwargs) self.key_type = key_type self.key = key @@ -489,10 +1068,10 @@ class TrackedResource(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -517,6 +1096,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(TrackedResource, self).__init__(**kwargs) self.location = location self.tags = tags @@ -535,15 +1120,18 @@ class RelayNamespace(TrackedResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param sku: SKU of the namespace. - :type sku: ~azure.mgmt.relay.models.Sku - :ivar provisioning_state: Possible values include: "Created", "Succeeded", "Deleted", - "Failed", "Updating", "Unknown". - :vartype provisioning_state: str or ~azure.mgmt.relay.models.ProvisioningStateEnum + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar sku: SKU of the namespace. + :vartype sku: ~azure.mgmt.relay.models.Sku + :ivar system_data: The system meta data relating to this resource. + :vartype system_data: ~azure.mgmt.relay.models.SystemData + :ivar provisioning_state: Provisioning state of the Namespace. + :vartype provisioning_state: str + :ivar status: Status of the Namespace. + :vartype status: str :ivar created_at: The time the namespace was created. :vartype created_at: ~datetime.datetime :ivar updated_at: The time the namespace was updated. @@ -552,6 +1140,12 @@ class RelayNamespace(TrackedResource): :vartype service_bus_endpoint: str :ivar metric_id: Identifier for Azure Insights metrics. :vartype metric_id: str + :ivar private_endpoint_connections: List of private endpoint connections. + :vartype private_endpoint_connections: list[~azure.mgmt.relay.models.PrivateEndpointConnection] + :ivar public_network_access: This determines if traffic is allowed over public network. By + default it is enabled. Possible values include: "Enabled", "Disabled", "SecuredByPerimeter". + Default value: "Enabled". + :vartype public_network_access: str or ~azure.mgmt.relay.models.PublicNetworkAccess """ _validation = { @@ -559,7 +1153,9 @@ class RelayNamespace(TrackedResource): '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}, @@ -573,11 +1169,15 @@ class RelayNamespace(TrackedResource): 'location': {'key': 'location', 'type': 'str'}, 'tags': {'key': 'tags', 'type': '{str}'}, 'sku': {'key': 'sku', 'type': 'Sku'}, + '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'}, + 'private_endpoint_connections': {'key': 'properties.privateEndpointConnections', 'type': '[PrivateEndpointConnection]'}, + 'public_network_access': {'key': 'properties.publicNetworkAccess', 'type': 'str'}, } def __init__( @@ -586,25 +1186,46 @@ def __init__( location: str, tags: Optional[Dict[str, str]] = None, sku: Optional["Sku"] = None, + private_endpoint_connections: Optional[List["PrivateEndpointConnection"]] = None, + public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = "Enabled", **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword sku: SKU of the namespace. + :paramtype sku: ~azure.mgmt.relay.models.Sku + :keyword private_endpoint_connections: List of private endpoint connections. + :paramtype private_endpoint_connections: + list[~azure.mgmt.relay.models.PrivateEndpointConnection] + :keyword public_network_access: This determines if traffic is allowed over public network. By + default it is enabled. Possible values include: "Enabled", "Disabled", "SecuredByPerimeter". + Default value: "Enabled". + :paramtype public_network_access: str or ~azure.mgmt.relay.models.PublicNetworkAccess + """ super(RelayNamespace, self).__init__(location=location, tags=tags, **kwargs) self.sku = sku + self.system_data = None self.provisioning_state = None + self.status = None self.created_at = None self.updated_at = None self.service_bus_endpoint = None self.metric_id = None + self.private_endpoint_connections = private_endpoint_connections + self.public_network_access = public_network_access class RelayNamespaceListResult(msrest.serialization.Model): """The response from the list namespace operation. - :param value: Result of the list namespace operation. - :type value: list[~azure.mgmt.relay.models.RelayNamespace] - :param next_link: Link to the next set of results. Not empty if value contains incomplete list + :ivar value: Result of the list namespace operation. + :vartype value: list[~azure.mgmt.relay.models.RelayNamespace] + :ivar next_link: Link to the next set of results. Not empty if value contains incomplete list of namespaces. - :type next_link: str + :vartype next_link: str """ _attribute_map = { @@ -619,6 +1240,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Result of the list namespace operation. + :paramtype value: list[~azure.mgmt.relay.models.RelayNamespace] + :keyword next_link: Link to the next set of results. Not empty if value contains incomplete + list of namespaces. + :paramtype next_link: str + """ super(RelayNamespaceListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -635,8 +1263,8 @@ class ResourceNamespacePatch(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -658,6 +1286,10 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(ResourceNamespacePatch, self).__init__(**kwargs) self.tags = tags @@ -673,13 +1305,14 @@ class RelayUpdateParameters(ResourceNamespacePatch): :vartype name: str :ivar type: Resource type. :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param sku: SKU of the namespace. - :type sku: ~azure.mgmt.relay.models.Sku - :ivar provisioning_state: Possible values include: "Created", "Succeeded", "Deleted", - "Failed", "Updating", "Unknown". - :vartype provisioning_state: str or ~azure.mgmt.relay.models.ProvisioningStateEnum + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar sku: SKU of the namespace. + :vartype sku: ~azure.mgmt.relay.models.Sku + :ivar provisioning_state: Provisioning state of the Namespace. + :vartype provisioning_state: str + :ivar status: Status of the Namespace. + :vartype status: str :ivar created_at: The time the namespace was created. :vartype created_at: ~datetime.datetime :ivar updated_at: The time the namespace was updated. @@ -688,6 +1321,12 @@ class RelayUpdateParameters(ResourceNamespacePatch): :vartype service_bus_endpoint: str :ivar metric_id: Identifier for Azure Insights metrics. :vartype metric_id: str + :ivar private_endpoint_connections: List of private endpoint connections. + :vartype private_endpoint_connections: list[~azure.mgmt.relay.models.PrivateEndpointConnection] + :ivar public_network_access: This determines if traffic is allowed over public network. By + default it is enabled. Possible values include: "Enabled", "Disabled", "SecuredByPerimeter". + Default value: "Enabled". + :vartype public_network_access: str or ~azure.mgmt.relay.models.PublicNetworkAccess """ _validation = { @@ -695,6 +1334,7 @@ class RelayUpdateParameters(ResourceNamespacePatch): '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}, @@ -708,10 +1348,13 @@ class RelayUpdateParameters(ResourceNamespacePatch): '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'}, 'metric_id': {'key': 'properties.metricId', 'type': 'str'}, + 'private_endpoint_connections': {'key': 'properties.privateEndpointConnections', 'type': '[PrivateEndpointConnection]'}, + 'public_network_access': {'key': 'properties.publicNetworkAccess', 'type': 'str'}, } def __init__( @@ -719,33 +1362,48 @@ def __init__( *, tags: Optional[Dict[str, str]] = None, sku: Optional["Sku"] = None, + private_endpoint_connections: Optional[List["PrivateEndpointConnection"]] = None, + public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = "Enabled", **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword sku: SKU of the namespace. + :paramtype sku: ~azure.mgmt.relay.models.Sku + :keyword private_endpoint_connections: List of private endpoint connections. + :paramtype private_endpoint_connections: + list[~azure.mgmt.relay.models.PrivateEndpointConnection] + :keyword public_network_access: This determines if traffic is allowed over public network. By + default it is enabled. Possible values include: "Enabled", "Disabled", "SecuredByPerimeter". + Default value: "Enabled". + :paramtype public_network_access: str or ~azure.mgmt.relay.models.PublicNetworkAccess + """ super(RelayUpdateParameters, self).__init__(tags=tags, **kwargs) self.sku = sku self.provisioning_state = None + self.status = None self.created_at = None self.updated_at = None self.service_bus_endpoint = None self.metric_id = None + self.private_endpoint_connections = private_endpoint_connections + self.public_network_access = public_network_access class Sku(msrest.serialization.Model): """SKU of the namespace. - 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 name: Name of this SKU. Has constant value: "Standard". - :vartype name: str - :param tier: The tier of this SKU. The only acceptable values to pass in are None and - "Standard". The default value is None. - :type tier: str + :ivar name: Required. Name of this SKU. Possible values include: "Standard". + :vartype name: str or ~azure.mgmt.relay.models.SkuName + :ivar tier: The tier of this SKU. Possible values include: "Standard". + :vartype tier: str or ~azure.mgmt.relay.models.SkuTier """ _validation = { - 'name': {'required': True, 'constant': True}, + 'name': {'required': True}, } _attribute_map = { @@ -753,29 +1411,105 @@ class Sku(msrest.serialization.Model): 'tier': {'key': 'tier', 'type': 'str'}, } - name = "Standard" - def __init__( self, *, - tier: Optional[str] = None, + name: Union[str, "SkuName"], + tier: Optional[Union[str, "SkuTier"]] = None, **kwargs ): + """ + :keyword name: Required. Name of this SKU. Possible values include: "Standard". + :paramtype name: str or ~azure.mgmt.relay.models.SkuName + :keyword tier: The tier of this SKU. Possible values include: "Standard". + :paramtype tier: str or ~azure.mgmt.relay.models.SkuTier + """ super(Sku, self).__init__(**kwargs) + self.name = name self.tier = tier -class WcfRelay(Resource): +class SystemData(msrest.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. Possible values include: + "User", "Application", "ManagedIdentity", "Key". + :vartype created_by_type: str or ~azure.mgmt.relay.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :vartype last_modified_by_type: str or ~azure.mgmt.relay.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :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'}, + } + + def __init__( + self, + *, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + **kwargs + ): + """ + :keyword created_by: The identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Possible values + include: "User", "Application", "ManagedIdentity", "Key". + :paramtype created_by_type: str or ~azure.mgmt.relay.models.CreatedByType + :keyword created_at: The timestamp of resource creation (UTC). + :paramtype created_at: ~datetime.datetime + :keyword last_modified_by: The identity that last modified the resource. + :paramtype last_modified_by: str + :keyword last_modified_by_type: The type of identity that last modified the resource. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :paramtype last_modified_by_type: str or ~azure.mgmt.relay.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + """ + super(SystemData, self).__init__(**kwargs) + self.created_by = created_by + self.created_by_type = created_by_type + self.created_at = created_at + self.last_modified_by = last_modified_by + self.last_modified_by_type = last_modified_by_type + self.last_modified_at = last_modified_at + + +class WcfRelay(ProxyResource): """Description of the WCF relay resource. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type. + :ivar type: The type of the resource. E.g. "Microsoft.EventHub/Namespaces" or + "Microsoft.EventHub/Namespaces/EventHubs". :vartype type: str + :ivar location: The geo-location where the resource lives. + :vartype location: str + :ivar system_data: The system meta data relating to this resource. + :vartype system_data: ~azure.mgmt.relay.models.SystemData :ivar is_dynamic: Returns true if the relay is dynamic; otherwise, false. :vartype is_dynamic: bool :ivar created_at: The time the WCF relay was created. @@ -785,24 +1519,26 @@ class WcfRelay(Resource): :ivar listener_count: The number of listeners for this relay. Note that min :1 and max:25 are supported. :vartype listener_count: int - :param relay_type: WCF relay type. Possible values include: "NetTcp", "Http". - :type relay_type: str or ~azure.mgmt.relay.models.Relaytype - :param requires_client_authorization: Returns true if client authorization is needed for this - relay; otherwise, false. - :type requires_client_authorization: bool - :param requires_transport_security: Returns true if transport security is needed for this + :ivar relay_type: WCF relay type. Possible values include: "NetTcp", "Http". + :vartype relay_type: str or ~azure.mgmt.relay.models.Relaytype + :ivar requires_client_authorization: Returns true if client authorization is needed for this relay; otherwise, false. - :type requires_transport_security: bool - :param user_metadata: The usermetadata is a placeholder to store user-defined string data for + :vartype requires_client_authorization: bool + :ivar requires_transport_security: Returns true if transport security is needed for this relay; + otherwise, false. + :vartype requires_transport_security: bool + :ivar user_metadata: The usermetadata is a placeholder to store user-defined string data for the WCF Relay endpoint. For example, it can be used to store descriptive data, such as list of teams and their contact information. Also, user-defined configuration settings can be stored. - :type user_metadata: str + :vartype user_metadata: str """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, + 'location': {'readonly': True}, + 'system_data': {'readonly': True}, 'is_dynamic': {'readonly': True}, 'created_at': {'readonly': True}, 'updated_at': {'readonly': True}, @@ -813,6 +1549,8 @@ class WcfRelay(Resource): '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'}, 'is_dynamic': {'key': 'properties.isDynamic', 'type': 'bool'}, 'created_at': {'key': 'properties.createdAt', 'type': 'iso-8601'}, 'updated_at': {'key': 'properties.updatedAt', 'type': 'iso-8601'}, @@ -832,7 +1570,22 @@ def __init__( user_metadata: Optional[str] = None, **kwargs ): + """ + :keyword relay_type: WCF relay type. Possible values include: "NetTcp", "Http". + :paramtype relay_type: str or ~azure.mgmt.relay.models.Relaytype + :keyword requires_client_authorization: Returns true if client authorization is needed for this + relay; otherwise, false. + :paramtype requires_client_authorization: bool + :keyword requires_transport_security: Returns true if transport security is needed for this + relay; otherwise, false. + :paramtype requires_transport_security: bool + :keyword user_metadata: The usermetadata is a placeholder to store user-defined string data for + the WCF Relay endpoint. For example, it can be used to store descriptive data, such as list of + teams and their contact information. Also, user-defined configuration settings can be stored. + :paramtype user_metadata: str + """ super(WcfRelay, self).__init__(**kwargs) + self.system_data = None self.is_dynamic = None self.created_at = None self.updated_at = None @@ -846,11 +1599,11 @@ def __init__( class WcfRelaysListResult(msrest.serialization.Model): """The response of the list WCF relay operation. - :param value: Result of the list WCF relay operation. - :type value: list[~azure.mgmt.relay.models.WcfRelay] - :param next_link: Link to the next set of results. Not empty if value contains incomplete list + :ivar value: Result of the list WCF relay operation. + :vartype value: list[~azure.mgmt.relay.models.WcfRelay] + :ivar next_link: Link to the next set of results. Not empty if value contains incomplete list of WCF relays. - :type next_link: str + :vartype next_link: str """ _attribute_map = { @@ -865,6 +1618,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Result of the list WCF relay operation. + :paramtype value: list[~azure.mgmt.relay.models.WcfRelay] + :keyword next_link: Link to the next set of results. Not empty if value contains incomplete + list of WCF relays. + :paramtype next_link: str + """ super(WcfRelaysListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link diff --git a/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/models/_relay_api_enums.py b/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/models/_relay_api_enums.py index 789bf35ba105..1b114a74d171 100644 --- a/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/models/_relay_api_enums.py +++ b/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/models/_relay_api_enums.py @@ -6,56 +6,94 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta +from enum import Enum from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class AccessRights(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessRights(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MANAGE = "Manage" SEND = "Send" LISTEN = "Listen" -class KeyType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The type of identity that created the resource. + """ + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + +class DefaultAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Default Action for Network Rule Set + """ + + ALLOW = "Allow" + DENY = "Deny" + +class EndPointProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Provisioning state of the Private Endpoint Connection. + """ + + CREATING = "Creating" + UPDATING = "Updating" + DELETING = "Deleting" + SUCCEEDED = "Succeeded" + CANCELED = "Canceled" + FAILED = "Failed" + +class KeyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The access key to regenerate. """ PRIMARY_KEY = "PrimaryKey" SECONDARY_KEY = "SecondaryKey" -class ProvisioningStateEnum(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class NetworkRuleIPAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The IP Filter Action + """ + + ALLOW = "Allow" - CREATED = "Created" - SUCCEEDED = "Succeeded" - DELETED = "Deleted" - FAILED = "Failed" - UPDATING = "Updating" - UNKNOWN = "Unknown" +class PrivateLinkConnectionStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Status of the connection. + """ + + PENDING = "Pending" + APPROVED = "Approved" + REJECTED = "Rejected" + DISCONNECTED = "Disconnected" + +class PublicNetworkAccess(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """This determines if traffic is allowed over public network. By default it is enabled. + """ -class Relaytype(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + ENABLED = "Enabled" + DISABLED = "Disabled" + SECURED_BY_PERIMETER = "SecuredByPerimeter" + +class Relaytype(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """WCF relay type. """ NET_TCP = "NetTcp" HTTP = "Http" -class UnavailableReason(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SkuName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Name of this SKU. + """ + + STANDARD = "Standard" + +class SkuTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The tier of this SKU. + """ + + STANDARD = "Standard" + +class UnavailableReason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Specifies the reason for the unavailability of the service. """ diff --git a/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/operations/__init__.py b/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/operations/__init__.py index 772eceb28d8f..53ad9f8031e5 100644 --- a/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/operations/__init__.py +++ b/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/operations/__init__.py @@ -6,14 +6,18 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._operations import Operations from ._namespaces_operations import NamespacesOperations from ._hybrid_connections_operations import HybridConnectionsOperations from ._wcf_relays_operations import WCFRelaysOperations +from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations +from ._private_link_resources_operations import PrivateLinkResourcesOperations +from ._operations import Operations __all__ = [ - 'Operations', 'NamespacesOperations', 'HybridConnectionsOperations', 'WCFRelaysOperations', + 'PrivateEndpointConnectionsOperations', + 'PrivateLinkResourcesOperations', + 'Operations', ] diff --git a/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/operations/_hybrid_connections_operations.py b/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/operations/_hybrid_connections_operations.py index 19037210fe16..7f1f61249618 100644 --- a/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/operations/_hybrid_connections_operations.py +++ b/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/operations/_hybrid_connections_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,437 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_authorization_rules_request( + resource_group_name: str, + namespace_name: str, + hybrid_connection_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/hybridConnections/{hybridConnectionName}/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), + "hybridConnectionName": _SERIALIZER.url("hybrid_connection_name", hybrid_connection_name, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_or_update_authorization_rule_request( + resource_group_name: str, + namespace_name: str, + hybrid_connection_name: str, + authorization_rule_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/hybridConnections/{hybridConnectionName}/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), + "hybridConnectionName": _SERIALIZER.url("hybrid_connection_name", hybrid_connection_name, 'str', min_length=1), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_authorization_rule_request( + resource_group_name: str, + namespace_name: str, + hybrid_connection_name: str, + authorization_rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/hybridConnections/{hybridConnectionName}/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), + "hybridConnectionName": _SERIALIZER.url("hybrid_connection_name", hybrid_connection_name, 'str', min_length=1), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_authorization_rule_request( + resource_group_name: str, + namespace_name: str, + hybrid_connection_name: str, + authorization_rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/hybridConnections/{hybridConnectionName}/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), + "hybridConnectionName": _SERIALIZER.url("hybrid_connection_name", hybrid_connection_name, 'str', min_length=1), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_keys_request( + resource_group_name: str, + namespace_name: str, + hybrid_connection_name: str, + authorization_rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/hybridConnections/{hybridConnectionName}/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), + "hybridConnectionName": _SERIALIZER.url("hybrid_connection_name", hybrid_connection_name, 'str', min_length=1), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_regenerate_keys_request( + resource_group_name: str, + namespace_name: str, + hybrid_connection_name: str, + authorization_rule_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/hybridConnections/{hybridConnectionName}/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), + "hybridConnectionName": _SERIALIZER.url("hybrid_connection_name", hybrid_connection_name, 'str', min_length=1), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_namespace_request( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/hybridConnections") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + namespace_name: str, + hybrid_connection_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/hybridConnections/{hybridConnectionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "hybridConnectionName": _SERIALIZER.url("hybrid_connection_name", hybrid_connection_name, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + namespace_name: str, + hybrid_connection_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/hybridConnections/{hybridConnectionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "hybridConnectionName": _SERIALIZER.url("hybrid_connection_name", hybrid_connection_name, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + namespace_name: str, + hybrid_connection_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/hybridConnections/{hybridConnectionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "hybridConnectionName": _SERIALIZER.url("hybrid_connection_name", hybrid_connection_name, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class HybridConnectionsOperations(object): """HybridConnectionsOperations operations. @@ -45,59 +460,66 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config - def list_by_namespace( + @distributed_trace + def list_authorization_rules( self, - resource_group_name, # type: str - namespace_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.HybridConnectionListResult"] - """Lists the hybrid connection within the namespace. + resource_group_name: str, + namespace_name: str, + hybrid_connection_name: str, + **kwargs: Any + ) -> Iterable["_models.AuthorizationRuleListResult"]: + """Authorization rules for a hybrid connection. :param resource_group_name: Name of the Resource group within the Azure subscription. :type resource_group_name: str :param namespace_name: The namespace name. :type namespace_name: str + :param hybrid_connection_name: The hybrid connection name. + :type hybrid_connection_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either HybridConnectionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.relay.models.HybridConnectionListResult] + :return: An iterator like instance of either AuthorizationRuleListResult or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.relay.models.AuthorizationRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.HybridConnectionListResult"] + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.AuthorizationRuleListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_namespace.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + hybrid_connection_name=hybrid_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_authorization_rules.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + hybrid_connection_name=hybrid_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('HybridConnectionListResult', pipeline_response) + deserialized = self._deserialize("AuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -106,31 +528,37 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_namespace.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/hybridConnections'} # type: ignore + list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/hybridConnections/{hybridConnectionName}/authorizationRules"} # type: ignore - def create_or_update( + @distributed_trace + def create_or_update_authorization_rule( self, - resource_group_name, # type: str - namespace_name, # type: str - hybrid_connection_name, # type: str - parameters, # type: "_models.HybridConnection" - **kwargs # type: Any - ): - # type: (...) -> "_models.HybridConnection" - """Creates or updates a service hybrid connection. This operation is idempotent. + resource_group_name: str, + namespace_name: str, + hybrid_connection_name: str, + authorization_rule_name: str, + parameters: "_models.AuthorizationRule", + **kwargs: Any + ) -> "_models.AuthorizationRule": + """Creates or updates an authorization rule for a hybrid connection. :param resource_group_name: Name of the Resource group within the Azure subscription. :type resource_group_name: str @@ -138,70 +566,72 @@ def create_or_update( :type namespace_name: str :param hybrid_connection_name: The hybrid connection name. :type hybrid_connection_name: str - :param parameters: Parameters supplied to create a hybrid connection. - :type parameters: ~azure.mgmt.relay.models.HybridConnection + :param authorization_rule_name: The authorization rule name. + :type authorization_rule_name: str + :param parameters: The authorization rule parameters. + :type parameters: ~azure.mgmt.relay.models.AuthorizationRule :keyword callable cls: A custom type or function that will be passed the direct response - :return: HybridConnection, or the result of cls(response) - :rtype: ~azure.mgmt.relay.models.HybridConnection + :return: AuthorizationRule, or the result of cls(response) + :rtype: ~azure.mgmt.relay.models.AuthorizationRule :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.HybridConnection"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.AuthorizationRule"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'hybridConnectionName': self._serialize.url("hybrid_connection_name", hybrid_connection_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'HybridConnection') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'AuthorizationRule') + + request = build_create_or_update_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + hybrid_connection_name=hybrid_connection_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('HybridConnection', pipeline_response) + deserialized = self._deserialize('AuthorizationRule', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/hybridConnections/{hybridConnectionName}'} # type: ignore - def delete( + create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/hybridConnections/{hybridConnectionName}/authorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace + def delete_authorization_rule( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - hybrid_connection_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """Deletes a hybrid connection. + resource_group_name: str, + namespace_name: str, + hybrid_connection_name: str, + authorization_rule_name: str, + **kwargs: Any + ) -> None: + """Deletes a hybrid connection authorization rule. :param resource_group_name: Name of the Resource group within the Azure subscription. :type resource_group_name: str @@ -209,6 +639,8 @@ def delete( :type namespace_name: str :param hybrid_connection_name: The hybrid connection name. :type hybrid_connection_name: str + :param authorization_rule_name: The authorization rule name. + :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -219,50 +651,50 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'hybridConnectionName': self._serialize.url("hybrid_connection_name", hybrid_connection_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + + + request = build_delete_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + hybrid_connection_name=hybrid_connection_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/hybridConnections/{hybridConnectionName}'} # type: ignore + delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/hybridConnections/{hybridConnectionName}/authorizationRules/{authorizationRuleName}"} # type: ignore - def get( + + @distributed_trace + def get_authorization_rule( self, - resource_group_name, # type: str - namespace_name, # type: str - hybrid_connection_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.HybridConnection" - """Returns the description for the specified hybrid connection. + resource_group_name: str, + namespace_name: str, + hybrid_connection_name: str, + authorization_rule_name: str, + **kwargs: Any + ) -> "_models.AuthorizationRule": + """Hybrid connection authorization rule for a hybrid connection by name. :param resource_group_name: Name of the Resource group within the Azure subscription. :type resource_group_name: str @@ -270,63 +702,66 @@ def get( :type namespace_name: str :param hybrid_connection_name: The hybrid connection name. :type hybrid_connection_name: str + :param authorization_rule_name: The authorization rule name. + :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: HybridConnection, or the result of cls(response) - :rtype: ~azure.mgmt.relay.models.HybridConnection + :return: AuthorizationRule, or the result of cls(response) + :rtype: ~azure.mgmt.relay.models.AuthorizationRule :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.HybridConnection"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.AuthorizationRule"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'hybridConnectionName': self._serialize.url("hybrid_connection_name", hybrid_connection_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + + + request = build_get_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + hybrid_connection_name=hybrid_connection_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('HybridConnection', pipeline_response) + deserialized = self._deserialize('AuthorizationRule', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/hybridConnections/{hybridConnectionName}'} # type: ignore - def list_authorization_rules( + get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/hybridConnections/{hybridConnectionName}/authorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace + def list_keys( self, - resource_group_name, # type: str - namespace_name, # type: str - hybrid_connection_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AuthorizationRuleListResult"] - """Authorization rules for a hybrid connection. + resource_group_name: str, + namespace_name: str, + hybrid_connection_name: str, + authorization_rule_name: str, + **kwargs: Any + ) -> "_models.AccessKeys": + """Primary and secondary connection strings to the hybrid connection. :param resource_group_name: Name of the Resource group within the Azure subscription. :type resource_group_name: str @@ -334,81 +769,67 @@ def list_authorization_rules( :type namespace_name: str :param hybrid_connection_name: The hybrid connection name. :type hybrid_connection_name: str + :param authorization_rule_name: The authorization rule name. + :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AuthorizationRuleListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.relay.models.AuthorizationRuleListResult] + :return: AccessKeys, or the result of cls(response) + :rtype: ~azure.mgmt.relay.models.AccessKeys :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AuthorizationRuleListResult"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessKeys"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + + + request = build_list_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + hybrid_connection_name=hybrid_connection_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - if not next_link: - # Construct URL - url = self.list_authorization_rules.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'hybridConnectionName': self._serialize.url("hybrid_connection_name", hybrid_connection_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response - def extract_data(pipeline_response): - deserialized = self._deserialize('AuthorizationRuleListResult', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, iter(list_of_elem) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - def get_next(next_link=None): - request = prepare_request(next_link) + deserialized = self._deserialize('AccessKeys', pipeline_response) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response + if cls: + return cls(pipeline_response, deserialized, {}) - if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + return deserialized - return pipeline_response + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/hybridConnections/{hybridConnectionName}/authorizationRules/{authorizationRuleName}/listKeys"} # type: ignore - return ItemPaged( - get_next, extract_data - ) - list_authorization_rules.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/hybridConnections/{hybridConnectionName}/authorizationRules'} # type: ignore - def create_or_update_authorization_rule( + @distributed_trace + def regenerate_keys( self, - resource_group_name, # type: str - namespace_name, # type: str - hybrid_connection_name, # type: str - authorization_rule_name, # type: str - parameters, # type: "_models.AuthorizationRule" - **kwargs # type: Any - ): - # type: (...) -> "_models.AuthorizationRule" - """Creates or updates an authorization rule for a hybrid connection. + resource_group_name: str, + namespace_name: str, + hybrid_connection_name: str, + authorization_rule_name: str, + parameters: "_models.RegenerateAccessKeyParameters", + **kwargs: Any + ) -> "_models.AccessKeys": + """Regenerates the primary or secondary connection strings to the hybrid connection. :param resource_group_name: Name of the Resource group within the Azure subscription. :type resource_group_name: str @@ -418,137 +839,153 @@ def create_or_update_authorization_rule( :type hybrid_connection_name: str :param authorization_rule_name: The authorization rule name. :type authorization_rule_name: str - :param parameters: The authorization rule parameters. - :type parameters: ~azure.mgmt.relay.models.AuthorizationRule + :param parameters: Parameters supplied to regenerate authorization rule. + :type parameters: ~azure.mgmt.relay.models.RegenerateAccessKeyParameters :keyword callable cls: A custom type or function that will be passed the direct response - :return: AuthorizationRule, or the result of cls(response) - :rtype: ~azure.mgmt.relay.models.AuthorizationRule + :return: AccessKeys, or the result of cls(response) + :rtype: ~azure.mgmt.relay.models.AccessKeys :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AuthorizationRule"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessKeys"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'hybridConnectionName': self._serialize.url("hybrid_connection_name", hybrid_connection_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'AuthorizationRule') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + + request = build_regenerate_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + hybrid_connection_name=hybrid_connection_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.regenerate_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AuthorizationRule', pipeline_response) + deserialized = self._deserialize('AccessKeys', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/hybridConnections/{hybridConnectionName}/authorizationRules/{authorizationRuleName}'} # type: ignore - def delete_authorization_rule( + regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/hybridConnections/{hybridConnectionName}/authorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore + + + @distributed_trace + def list_by_namespace( self, - resource_group_name, # type: str - namespace_name, # type: str - hybrid_connection_name, # type: str - authorization_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """Deletes a hybrid connection authorization rule. + resource_group_name: str, + namespace_name: str, + **kwargs: Any + ) -> Iterable["_models.HybridConnectionListResult"]: + """Lists the hybrid connection within the namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. :type resource_group_name: str :param namespace_name: The namespace name. :type namespace_name: str - :param hybrid_connection_name: The hybrid connection name. - :type hybrid_connection_name: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None + :return: An iterator like instance of either HybridConnectionListResult or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.relay.models.HybridConnectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.HybridConnectionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.delete_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'hybridConnectionName': self._serialize.url("hybrid_connection_name", hybrid_connection_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + def extract_data(pipeline_response): + deserialized = self._deserialize("HybridConnectionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response + def get_next(next_link=None): + request = prepare_request(next_link) - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response - if cls: - return cls(pipeline_response, None, {}) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - delete_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/hybridConnections/{hybridConnectionName}/authorizationRules/{authorizationRuleName}'} # type: ignore + return pipeline_response - def get_authorization_rule( + + return ItemPaged( + get_next, extract_data + ) + list_by_namespace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/hybridConnections"} # type: ignore + + @distributed_trace + def create_or_update( self, - resource_group_name, # type: str - namespace_name, # type: str - hybrid_connection_name, # type: str - authorization_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.AuthorizationRule" - """Hybrid connection authorization rule for a hybrid connection by name. + resource_group_name: str, + namespace_name: str, + hybrid_connection_name: str, + parameters: "_models.HybridConnection", + **kwargs: Any + ) -> "_models.HybridConnection": + """Creates or updates a service hybrid connection. This operation is idempotent. :param resource_group_name: Name of the Resource group within the Azure subscription. :type resource_group_name: str @@ -556,67 +993,68 @@ def get_authorization_rule( :type namespace_name: str :param hybrid_connection_name: The hybrid connection name. :type hybrid_connection_name: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_name: str + :param parameters: Parameters supplied to create a hybrid connection. + :type parameters: ~azure.mgmt.relay.models.HybridConnection :keyword callable cls: A custom type or function that will be passed the direct response - :return: AuthorizationRule, or the result of cls(response) - :rtype: ~azure.mgmt.relay.models.AuthorizationRule + :return: HybridConnection, or the result of cls(response) + :rtype: ~azure.mgmt.relay.models.HybridConnection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AuthorizationRule"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.HybridConnection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.get_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'hybridConnectionName': self._serialize.url("hybrid_connection_name", hybrid_connection_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'HybridConnection') - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + request = build_create_or_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + hybrid_connection_name=hybrid_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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AuthorizationRule', pipeline_response) + deserialized = self._deserialize('HybridConnection', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/hybridConnections/{hybridConnectionName}/authorizationRules/{authorizationRuleName}'} # type: ignore - def list_keys( + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/hybridConnections/{hybridConnectionName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - hybrid_connection_name, # type: str - authorization_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.AccessKeys" - """Primary and secondary connection strings to the hybrid connection. + resource_group_name: str, + namespace_name: str, + hybrid_connection_name: str, + **kwargs: Any + ) -> None: + """Deletes a hybrid connection. :param resource_group_name: Name of the Resource group within the Azure subscription. :type resource_group_name: str @@ -624,68 +1062,58 @@ def list_keys( :type namespace_name: str :param hybrid_connection_name: The hybrid connection name. :type hybrid_connection_name: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) - :rtype: ~azure.mgmt.relay.models.AccessKeys + :return: None, or the result of cls(response) + :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessKeys"] + cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'hybridConnectionName': self._serialize.url("hybrid_connection_name", hybrid_connection_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-11-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + hybrid_connection_name=hybrid_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, None, {}) - return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/hybridConnections/{hybridConnectionName}/authorizationRules/{authorizationRuleName}/listKeys'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/hybridConnections/{hybridConnectionName}"} # type: ignore - def regenerate_keys( + + @distributed_trace + def get( self, - resource_group_name, # type: str - namespace_name, # type: str - hybrid_connection_name, # type: str - authorization_rule_name, # type: str - parameters, # type: "_models.RegenerateAccessKeyParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.AccessKeys" - """Regenerates the primary or secondary connection strings to the hybrid connection. + resource_group_name: str, + namespace_name: str, + hybrid_connection_name: str, + **kwargs: Any + ) -> "_models.HybridConnection": + """Returns the description for the specified hybrid connection. :param resource_group_name: Name of the Resource group within the Azure subscription. :type resource_group_name: str @@ -693,60 +1121,49 @@ def regenerate_keys( :type namespace_name: str :param hybrid_connection_name: The hybrid connection name. :type hybrid_connection_name: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate authorization rule. - :type parameters: ~azure.mgmt.relay.models.RegenerateAccessKeyParameters :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) - :rtype: ~azure.mgmt.relay.models.AccessKeys + :return: HybridConnection, or the result of cls(response) + :rtype: ~azure.mgmt.relay.models.HybridConnection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessKeys"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.HybridConnection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.regenerate_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'hybridConnectionName': self._serialize.url("hybrid_connection_name", hybrid_connection_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + hybrid_connection_name=hybrid_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = self._deserialize('HybridConnection', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/hybridConnections/{hybridConnectionName}/authorizationRules/{authorizationRuleName}/regenerateKeys'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/hybridConnections/{hybridConnectionName}"} # type: ignore + diff --git a/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/operations/_namespaces_operations.py b/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/operations/_namespaces_operations.py index 5da271a25902..7f3705e5a03b 100644 --- a/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/operations/_namespaces_operations.py +++ b/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/operations/_namespaces_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,25 +6,615 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_authorization_rules_request( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/authorizationRules") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_or_update_authorization_rule_request( + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/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', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_authorization_rule_request( + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/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', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_authorization_rule_request( + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/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', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_keys_request( + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/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', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_regenerate_keys_request( + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/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', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_check_name_availability_request( + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Relay/checkNameAvailability") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Relay/namespaces") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + resource_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_update_request( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_create_or_update_network_rule_set_request( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/networkRuleSets/default") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_get_network_rule_set_request( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/networkRuleSets/default") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class NamespacesOperations(object): """NamespacesOperations operations. @@ -47,12 +638,420 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace + def list_authorization_rules( + self, + resource_group_name: str, + namespace_name: str, + **kwargs: Any + ) -> Iterable["_models.AuthorizationRuleListResult"]: + """Authorization rules for a namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. + :type resource_group_name: str + :param namespace_name: The namespace name. + :type namespace_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AuthorizationRuleListResult or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.relay.models.AuthorizationRuleListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.AuthorizationRuleListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("AuthorizationRuleListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + 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 + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/authorizationRules"} # type: ignore + + @distributed_trace + def create_or_update_authorization_rule( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: "_models.AuthorizationRule", + **kwargs: Any + ) -> "_models.AuthorizationRule": + """Creates or updates an authorization rule for a namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. + :type resource_group_name: str + :param namespace_name: The namespace name. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. + :type authorization_rule_name: str + :param parameters: The authorization rule parameters. + :type parameters: ~azure.mgmt.relay.models.AuthorizationRule + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AuthorizationRule, or the result of cls(response) + :rtype: ~azure.mgmt.relay.models.AuthorizationRule + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AuthorizationRule"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'AuthorizationRule') + + request = build_create_or_update_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('AuthorizationRule', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/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 + ) -> None: + """Deletes a namespace authorization rule. + + :param resource_group_name: Name of the Resource group within the Azure subscription. + :type resource_group_name: str + :param namespace_name: The namespace name. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. + :type authorization_rule_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + + + request = build_delete_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/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 + ) -> "_models.AuthorizationRule": + """Authorization rule for a namespace by name. + + :param resource_group_name: Name of the Resource group within the Azure subscription. + :type resource_group_name: str + :param namespace_name: The namespace name. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. + :type authorization_rule_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AuthorizationRule, or the result of cls(response) + :rtype: ~azure.mgmt.relay.models.AuthorizationRule + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AuthorizationRule"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + + + request = build_get_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('AuthorizationRule', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/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 + ) -> "_models.AccessKeys": + """Primary and secondary connection strings to the namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. + :type resource_group_name: str + :param namespace_name: The namespace name. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. + :type authorization_rule_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AccessKeys, or the result of cls(response) + :rtype: ~azure.mgmt.relay.models.AccessKeys + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessKeys"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + + + request = build_list_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + 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.Relay/namespaces/{namespaceName}/authorizationRules/{authorizationRuleName}/listKeys"} # type: ignore + + + @distributed_trace + def regenerate_keys( + self, + resource_group_name: str, + namespace_name: str, + authorization_rule_name: str, + parameters: "_models.RegenerateAccessKeyParameters", + **kwargs: Any + ) -> "_models.AccessKeys": + """Regenerates the primary or secondary connection strings to the namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. + :type resource_group_name: str + :param namespace_name: The namespace name. + :type namespace_name: str + :param authorization_rule_name: The authorization rule name. + :type authorization_rule_name: str + :param parameters: Parameters supplied to regenerate authorization rule. + :type parameters: ~azure.mgmt.relay.models.RegenerateAccessKeyParameters + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AccessKeys, or the result of cls(response) + :rtype: ~azure.mgmt.relay.models.AccessKeys + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessKeys"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + + request = build_regenerate_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.regenerate_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('AccessKeys', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/authorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore + + + @distributed_trace def check_name_availability( self, - parameters, # type: "_models.CheckNameAvailability" - **kwargs # type: Any - ): - # type: (...) -> "_models.CheckNameAvailabilityResult" + parameters: "_models.CheckNameAvailability", + **kwargs: Any + ) -> "_models.CheckNameAvailabilityResult": """Check the specified namespace name availability. :param parameters: Parameters to check availability of the specified namespace name. @@ -67,36 +1066,32 @@ def check_name_availability( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_name_availability.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'CheckNameAvailability') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'CheckNameAvailability') + + request = build_check_name_availability_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.check_name_availability.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) @@ -105,53 +1100,55 @@ def check_name_availability( return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Relay/checkNameAvailability'} # type: ignore + check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Relay/checkNameAvailability"} # type: ignore + + + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RelayNamespaceListResult"] + **kwargs: Any + ) -> Iterable["_models.RelayNamespaceListResult"]: """Lists all the available namespaces within the subscription regardless of the resourceGroups. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RelayNamespaceListResult or the result of cls(response) + :return: An iterator like instance of either RelayNamespaceListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.relay.models.RelayNamespaceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RelayNamespaceListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RelayNamespaceListResult', pipeline_response) + deserialized = self._deserialize("RelayNamespaceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -160,70 +1157,76 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Relay/namespaces'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Relay/namespaces"} # type: ignore + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RelayNamespaceListResult"] + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.RelayNamespaceListResult"]: """Lists all the available namespaces within the ResourceGroup. :param resource_group_name: Name of the Resource group within the Azure subscription. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RelayNamespaceListResult or the result of cls(response) + :return: An iterator like instance of either RelayNamespaceListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.relay.models.RelayNamespaceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RelayNamespaceListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RelayNamespaceListResult', pipeline_response) + deserialized = self._deserialize("RelayNamespaceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -232,67 +1235,66 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces"} # type: ignore def _create_or_update_initial( self, - resource_group_name, # type: str - namespace_name, # type: str - parameters, # type: "_models.RelayNamespace" - **kwargs # type: Any - ): - # type: (...) -> "_models.RelayNamespace" + resource_group_name: str, + namespace_name: str, + parameters: "_models.RelayNamespace", + **kwargs: Any + ) -> "_models.RelayNamespace": cls = kwargs.pop('cls', None) # type: ClsType["_models.RelayNamespace"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RelayNamespace') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RelayNamespace') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('RelayNamespace', pipeline_response) @@ -304,16 +1306,18 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}'} # type: ignore + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}"} # type: ignore + + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - namespace_name, # type: str - parameters, # type: "_models.RelayNamespace" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.RelayNamespace"] + resource_group_name: str, + namespace_name: str, + parameters: "_models.RelayNamespace", + **kwargs: Any + ) -> LROPoller["_models.RelayNamespace"]: """Create Azure Relay namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -324,14 +1328,19 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.relay.models.RelayNamespace :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either RelayNamespace or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either RelayNamespace or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.relay.models.RelayNamespace] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.RelayNamespace"] lro_delay = kwargs.pop( @@ -344,27 +1353,22 @@ def begin_create_or_update( resource_group_name=resource_group_name, namespace_name=namespace_name, parameters=parameters, + api_version=api_version, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('RelayNamespace', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -374,63 +1378,59 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}"} # type: ignore - def _delete_initial( + def _delete_initial( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + namespace_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-11-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}'} # type: ignore + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}"} # type: ignore - def begin_delete( + + @distributed_trace + def begin_delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + namespace_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Deletes an existing namespace. This operation also removes all associated resources under the namespace. @@ -440,14 +1440,17 @@ def begin_delete( :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-11-01") # type: str polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( @@ -459,24 +1462,18 @@ def begin_delete( raw_result = self._delete_initial( resource_group_name=resource_group_name, namespace_name=namespace_name, + api_version=api_version, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -486,17 +1483,17 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}"} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - namespace_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RelayNamespace" + resource_group_name: str, + namespace_name: str, + **kwargs: Any + ) -> "_models.RelayNamespace": """Returns the description for the specified namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. @@ -513,33 +1510,30 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-11-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RelayNamespace', pipeline_response) @@ -548,16 +1542,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}"} # type: ignore + + + @distributed_trace def update( self, - resource_group_name, # type: str - namespace_name, # type: str - parameters, # type: "_models.RelayUpdateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.RelayNamespace" + resource_group_name: str, + namespace_name: str, + parameters: "_models.RelayUpdateParameters", + **kwargs: Any + ) -> "_models.RelayNamespace": """Creates or updates a namespace. Once created, this namespace's resource manifest is immutable. This operation is idempotent. @@ -577,38 +1573,34 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RelayUpdateParameters') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RelayUpdateParameters') + + request = build_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -621,413 +1613,131 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}'} # type: ignore - def list_authorization_rules( + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}"} # type: ignore + + + @distributed_trace + def create_or_update_network_rule_set( self, - resource_group_name, # type: str - namespace_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AuthorizationRuleListResult"] - """Authorization rules for a namespace. + resource_group_name: str, + namespace_name: str, + parameters: "_models.NetworkRuleSet", + **kwargs: Any + ) -> "_models.NetworkRuleSet": + """Create or update NetworkRuleSet for a Namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. :type resource_group_name: str :param namespace_name: The namespace name. :type namespace_name: str + :param parameters: The Namespace IpFilterRule. + :type parameters: ~azure.mgmt.relay.models.NetworkRuleSet :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AuthorizationRuleListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.relay.models.AuthorizationRuleListResult] + :return: NetworkRuleSet, or the result of cls(response) + :rtype: ~azure.mgmt.relay.models.NetworkRuleSet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AuthorizationRuleListResult"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.NetworkRuleSet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_authorization_rules.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize('AuthorizationRuleListResult', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, iter(list_of_elem) - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + _json = self._serialize.body(parameters, 'NetworkRuleSet') - return pipeline_response - - return ItemPaged( - get_next, extract_data + request = build_create_or_update_network_rule_set_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update_network_rule_set.metadata['url'], ) - list_authorization_rules.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/authorizationRules'} # type: ignore - - def create_or_update_authorization_rule( - self, - resource_group_name, # type: str - namespace_name, # type: str - authorization_rule_name, # type: str - parameters, # type: "_models.AuthorizationRule" - **kwargs # type: Any - ): - # type: (...) -> "_models.AuthorizationRule" - """Creates or updates an authorization rule for a namespace. + request = _convert_request(request) + request.url = self._client.format_url(request.url) - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_name: str - :param parameters: The authorization rule parameters. - :type parameters: ~azure.mgmt.relay.models.AuthorizationRule - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AuthorizationRule, or the result of cls(response) - :rtype: ~azure.mgmt.relay.models.AuthorizationRule - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AuthorizationRule"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'AuthorizationRule') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AuthorizationRule', pipeline_response) + deserialized = self._deserialize('NetworkRuleSet', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/authorizationRules/{authorizationRuleName}'} # type: ignore - - def delete_authorization_rule( - self, - resource_group_name, # type: str - namespace_name, # type: str - authorization_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """Deletes a namespace authorization rule. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.delete_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if cls: - return cls(pipeline_response, None, {}) + create_or_update_network_rule_set.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/networkRuleSets/default"} # type: ignore - delete_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/authorizationRules/{authorizationRuleName}'} # type: ignore - def get_authorization_rule( + @distributed_trace + def get_network_rule_set( self, - resource_group_name, # type: str - namespace_name, # type: str - authorization_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.AuthorizationRule" - """Authorization rule for a namespace by name. + 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. :type resource_group_name: str :param namespace_name: The namespace name. :type namespace_name: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AuthorizationRule, or the result of cls(response) - :rtype: ~azure.mgmt.relay.models.AuthorizationRule + :return: NetworkRuleSet, or the result of cls(response) + :rtype: ~azure.mgmt.relay.models.NetworkRuleSet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AuthorizationRule"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.NetworkRuleSet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.get_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-11-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('AuthorizationRule', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/authorizationRules/{authorizationRuleName}'} # type: ignore - - def list_keys( - self, - resource_group_name, # type: str - namespace_name, # type: str - authorization_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.AccessKeys" - """Primary and secondary connection strings to the namespace. - - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) - :rtype: ~azure.mgmt.relay.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessKeys"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_network_rule_set_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_network_rule_set.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = self._deserialize('NetworkRuleSet', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/authorizationRules/{authorizationRuleName}/listKeys'} # type: ignore - def regenerate_keys( - self, - resource_group_name, # type: str - namespace_name, # type: str - authorization_rule_name, # type: str - parameters, # type: "_models.RegenerateAccessKeyParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.AccessKeys" - """Regenerates the primary or secondary connection strings to the namespace. + get_network_rule_set.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/networkRuleSets/default"} # type: ignore - :param resource_group_name: Name of the Resource group within the Azure subscription. - :type resource_group_name: str - :param namespace_name: The namespace name. - :type namespace_name: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate authorization rule. - :type parameters: ~azure.mgmt.relay.models.RegenerateAccessKeyParameters - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) - :rtype: ~azure.mgmt.relay.models.AccessKeys - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessKeys"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.regenerate_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - 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.Relay/namespaces/{namespaceName}/authorizationRules/{authorizationRuleName}/regenerateKeys'} # type: ignore diff --git a/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/operations/_operations.py b/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/operations/_operations.py index 62feb3749fb8..0a7b60e35ad5 100644 --- a/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/operations/_operations.py +++ b/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,50 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Relay/operations") + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class Operations(object): """Operations operations. @@ -45,11 +73,11 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OperationListResult"] + **kwargs: Any + ) -> Iterable["_models.OperationListResult"]: """Lists all available Relay REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -57,35 +85,36 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.relay.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.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', {})) - api_version = "2017-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -94,17 +123,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Relay/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Relay/operations"} # type: ignore diff --git a/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/operations/_private_endpoint_connections_operations.py b/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/operations/_private_endpoint_connections_operations.py new file mode 100644 index 000000000000..4755aa16fa59 --- /dev/null +++ b/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/operations/_private_endpoint_connections_operations.py @@ -0,0 +1,545 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/privateEndpointConnections") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + subscription_id: str, + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + private_endpoint_connection_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + +class PrivateEndpointConnectionsOperations(object): + """PrivateEndpointConnectionsOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.relay.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list( + self, + resource_group_name: str, + namespace_name: str, + **kwargs: Any + ) -> Iterable["_models.PrivateEndpointConnectionListResult"]: + """Gets the available PrivateEndpointConnections within a namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. + :type resource_group_name: str + :param namespace_name: The namespace name. + :type namespace_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.relay.models.PrivateEndpointConnectionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.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', {})) + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + 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 + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/privateEndpointConnections"} # type: ignore + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + parameters: "_models.PrivateEndpointConnection", + **kwargs: Any + ) -> "_models.PrivateEndpointConnection": + """Creates or updates PrivateEndpointConnections of service namespace. + + :param resource_group_name: Name of the Resource group within the Azure subscription. + :type resource_group_name: str + :param namespace_name: The namespace name. + :type namespace_name: str + :param private_endpoint_connection_name: The PrivateEndpointConnection name. + :type private_endpoint_connection_name: str + :param parameters: Parameters supplied to update Status of PrivateEndPoint Connection to + namespace resource. + :type parameters: ~azure.mgmt.relay.models.PrivateEndpointConnection + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PrivateEndpointConnection, or the result of cls(response) + :rtype: ~azure.mgmt.relay.models.PrivateEndpointConnection + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'PrivateEndpointConnection') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + namespace_name=namespace_name, + private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + + if response.status_code == 202: + 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.Relay/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 + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/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 + ) -> 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. + :type resource_group_name: str + :param namespace_name: The namespace name. + :type namespace_name: str + :param private_endpoint_connection_name: The PrivateEndpointConnection name. + :type private_endpoint_connection_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: 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 None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = 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 + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/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 + ) -> "_models.PrivateEndpointConnection": + """Gets a description for the specified Private Endpoint Connection name. + + :param resource_group_name: Name of the Resource group within the Azure subscription. + :type resource_group_name: str + :param namespace_name: The namespace name. + :type namespace_name: str + :param private_endpoint_connection_name: The PrivateEndpointConnection name. + :type private_endpoint_connection_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PrivateEndpointConnection, or the result of cls(response) + :rtype: ~azure.mgmt.relay.models.PrivateEndpointConnection + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + diff --git a/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/operations/_private_link_resources_operations.py b/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/operations/_private_link_resources_operations.py new file mode 100644 index 000000000000..5f3fbb9efca3 --- /dev/null +++ b/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/operations/_private_link_resources_operations.py @@ -0,0 +1,243 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + namespace_name: str, + private_link_resource_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/privateLinkResources/{privateLinkResourceName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "privateLinkResourceName": _SERIALIZER.url("private_link_resource_name", private_link_resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_request( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/privateLinkResources") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + +class PrivateLinkResourcesOperations(object): + """PrivateLinkResourcesOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.relay.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def get( + self, + resource_group_name: str, + namespace_name: str, + private_link_resource_name: str, + **kwargs: Any + ) -> "_models.PrivateLinkResource": + """Gets a description for the specified Private Endpoint Connection name. + + :param resource_group_name: Name of the Resource group within the Azure subscription. + :type resource_group_name: str + :param namespace_name: The namespace name. + :type namespace_name: str + :param private_link_resource_name: The PrivateLinkResource name. + :type private_link_resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PrivateLinkResource, or the result of cls(response) + :rtype: ~azure.mgmt.relay.models.PrivateLinkResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResource"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + private_link_resource_name=private_link_resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PrivateLinkResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/privateLinkResources/{privateLinkResourceName}"} # type: ignore + + + @distributed_trace + def list( + 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. + :type resource_group_name: str + :param namespace_name: The namespace name. + :type namespace_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PrivateLinkResourcesListResult, or the result of cls(response) + :rtype: ~azure.mgmt.relay.models.PrivateLinkResourcesListResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResourcesListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + + + request = build_list_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PrivateLinkResourcesListResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/privateLinkResources"} # type: ignore + diff --git a/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/operations/_wcf_relays_operations.py b/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/operations/_wcf_relays_operations.py index b3f42d45e81d..40eee7eb8523 100644 --- a/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/operations/_wcf_relays_operations.py +++ b/sdk/relay/azure-mgmt-relay/azure/mgmt/relay/operations/_wcf_relays_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,437 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_authorization_rules_request( + resource_group_name: str, + namespace_name: str, + relay_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/wcfRelays/{relayName}/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), + "relayName": _SERIALIZER.url("relay_name", relay_name, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_or_update_authorization_rule_request( + resource_group_name: str, + namespace_name: str, + relay_name: str, + authorization_rule_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/wcfRelays/{relayName}/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), + "relayName": _SERIALIZER.url("relay_name", relay_name, 'str', min_length=1), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_authorization_rule_request( + resource_group_name: str, + namespace_name: str, + relay_name: str, + authorization_rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/wcfRelays/{relayName}/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), + "relayName": _SERIALIZER.url("relay_name", relay_name, 'str', min_length=1), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_authorization_rule_request( + resource_group_name: str, + namespace_name: str, + relay_name: str, + authorization_rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/wcfRelays/{relayName}/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), + "relayName": _SERIALIZER.url("relay_name", relay_name, 'str', min_length=1), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_keys_request( + resource_group_name: str, + namespace_name: str, + relay_name: str, + authorization_rule_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/wcfRelays/{relayName}/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), + "relayName": _SERIALIZER.url("relay_name", relay_name, 'str', min_length=1), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_regenerate_keys_request( + resource_group_name: str, + namespace_name: str, + relay_name: str, + authorization_rule_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/wcfRelays/{relayName}/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), + "relayName": _SERIALIZER.url("relay_name", relay_name, 'str', min_length=1), + "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_namespace_request( + resource_group_name: str, + namespace_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/wcfRelays") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + namespace_name: str, + relay_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/wcfRelays/{relayName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "relayName": _SERIALIZER.url("relay_name", relay_name, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + namespace_name: str, + relay_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/wcfRelays/{relayName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "relayName": _SERIALIZER.url("relay_name", relay_name, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + namespace_name: str, + relay_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/wcfRelays/{relayName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), + "relayName": _SERIALIZER.url("relay_name", relay_name, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class WCFRelaysOperations(object): """WCFRelaysOperations operations. @@ -45,59 +460,66 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config - def list_by_namespace( + @distributed_trace + def list_authorization_rules( self, - resource_group_name, # type: str - namespace_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.WcfRelaysListResult"] - """Lists the WCF relays within the namespace. + resource_group_name: str, + namespace_name: str, + relay_name: str, + **kwargs: Any + ) -> Iterable["_models.AuthorizationRuleListResult"]: + """Authorization rules for a WCF relay. :param resource_group_name: Name of the Resource group within the Azure subscription. :type resource_group_name: str :param namespace_name: The namespace name. :type namespace_name: str + :param relay_name: The relay name. + :type relay_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either WcfRelaysListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.relay.models.WcfRelaysListResult] + :return: An iterator like instance of either AuthorizationRuleListResult or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.relay.models.AuthorizationRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WcfRelaysListResult"] + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.AuthorizationRuleListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_namespace.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + relay_name=relay_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_authorization_rules.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_authorization_rules_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + relay_name=relay_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('WcfRelaysListResult', pipeline_response) + deserialized = self._deserialize("AuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -106,31 +528,36 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_namespace.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/wcfRelays'} # type: ignore + list_authorization_rules.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/wcfRelays/{relayName}/authorizationRules"} # type: ignore - def create_or_update( + @distributed_trace + def create_or_update_authorization_rule( self, - resource_group_name, # type: str - namespace_name, # type: str - relay_name, # type: str - parameters, # type: "_models.WcfRelay" - **kwargs # type: Any - ): - # type: (...) -> "_models.WcfRelay" - """Creates or updates a WCF relay. This operation is idempotent. + resource_group_name: str, + namespace_name: str, + relay_name: str, + authorization_rule_name: str, + parameters: "_models.AuthorizationRule", + **kwargs: Any + ) -> "_models.AuthorizationRule": + """Creates or updates an authorization rule for a WCF relay. :param resource_group_name: Name of the Resource group within the Azure subscription. :type resource_group_name: str @@ -138,70 +565,72 @@ def create_or_update( :type namespace_name: str :param relay_name: The relay name. :type relay_name: str - :param parameters: Parameters supplied to create a WCF relay. - :type parameters: ~azure.mgmt.relay.models.WcfRelay + :param authorization_rule_name: The authorization rule name. + :type authorization_rule_name: str + :param parameters: The authorization rule parameters. + :type parameters: ~azure.mgmt.relay.models.AuthorizationRule :keyword callable cls: A custom type or function that will be passed the direct response - :return: WcfRelay, or the result of cls(response) - :rtype: ~azure.mgmt.relay.models.WcfRelay + :return: AuthorizationRule, or the result of cls(response) + :rtype: ~azure.mgmt.relay.models.AuthorizationRule :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WcfRelay"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.AuthorizationRule"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'relayName': self._serialize.url("relay_name", relay_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'WcfRelay') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'AuthorizationRule') + + request = build_create_or_update_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + relay_name=relay_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('WcfRelay', pipeline_response) + deserialized = self._deserialize('AuthorizationRule', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/wcfRelays/{relayName}'} # type: ignore - def delete( + create_or_update_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/wcfRelays/{relayName}/authorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace + def delete_authorization_rule( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - relay_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """Deletes a WCF relay. + resource_group_name: str, + namespace_name: str, + relay_name: str, + authorization_rule_name: str, + **kwargs: Any + ) -> None: + """Deletes a WCF relay authorization rule. :param resource_group_name: Name of the Resource group within the Azure subscription. :type resource_group_name: str @@ -209,6 +638,8 @@ def delete( :type namespace_name: str :param relay_name: The relay name. :type relay_name: str + :param authorization_rule_name: The authorization rule name. + :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -219,50 +650,50 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'relayName': self._serialize.url("relay_name", relay_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + + + request = build_delete_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + relay_name=relay_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/wcfRelays/{relayName}'} # type: ignore + delete_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/wcfRelays/{relayName}/authorizationRules/{authorizationRuleName}"} # type: ignore - def get( + + @distributed_trace + def get_authorization_rule( self, - resource_group_name, # type: str - namespace_name, # type: str - relay_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.WcfRelay"] - """Returns the description for the specified WCF relay. + resource_group_name: str, + namespace_name: str, + relay_name: str, + authorization_rule_name: str, + **kwargs: Any + ) -> "_models.AuthorizationRule": + """Get authorizationRule for a WCF relay by name. :param resource_group_name: Name of the Resource group within the Azure subscription. :type resource_group_name: str @@ -270,65 +701,66 @@ def get( :type namespace_name: str :param relay_name: The relay name. :type relay_name: str + :param authorization_rule_name: The authorization rule name. + :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: WcfRelay, or the result of cls(response) - :rtype: ~azure.mgmt.relay.models.WcfRelay or None + :return: AuthorizationRule, or the result of cls(response) + :rtype: ~azure.mgmt.relay.models.AuthorizationRule :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WcfRelay"]] + cls = kwargs.pop('cls', None) # type: ClsType["_models.AuthorizationRule"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'relayName': self._serialize.url("relay_name", relay_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + + + request = build_get_authorization_rule_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + relay_name=relay_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_authorization_rule.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response - if response.status_code not in [200, 204]: + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('WcfRelay', pipeline_response) + deserialized = self._deserialize('AuthorizationRule', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/wcfRelays/{relayName}'} # type: ignore - def list_authorization_rules( + get_authorization_rule.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/wcfRelays/{relayName}/authorizationRules/{authorizationRuleName}"} # type: ignore + + + @distributed_trace + def list_keys( self, - resource_group_name, # type: str - namespace_name, # type: str - relay_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AuthorizationRuleListResult"] - """Authorization rules for a WCF relay. + resource_group_name: str, + namespace_name: str, + relay_name: str, + authorization_rule_name: str, + **kwargs: Any + ) -> "_models.AccessKeys": + """Primary and secondary connection strings to the WCF relay. :param resource_group_name: Name of the Resource group within the Azure subscription. :type resource_group_name: str @@ -336,80 +768,67 @@ def list_authorization_rules( :type namespace_name: str :param relay_name: The relay name. :type relay_name: str + :param authorization_rule_name: The authorization rule name. + :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AuthorizationRuleListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.relay.models.AuthorizationRuleListResult] + :return: AccessKeys, or the result of cls(response) + :rtype: ~azure.mgmt.relay.models.AccessKeys :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AuthorizationRuleListResult"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessKeys"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + + + request = build_list_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + relay_name=relay_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - if not next_link: - # Construct URL - url = self.list_authorization_rules.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'relayName': self._serialize.url("relay_name", relay_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response - def extract_data(pipeline_response): - deserialized = self._deserialize('AuthorizationRuleListResult', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, iter(list_of_elem) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - def get_next(next_link=None): - request = prepare_request(next_link) + deserialized = self._deserialize('AccessKeys', pipeline_response) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response + if cls: + return cls(pipeline_response, deserialized, {}) - 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) + return deserialized - return pipeline_response + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/wcfRelays/{relayName}/authorizationRules/{authorizationRuleName}/listKeys"} # type: ignore - return ItemPaged( - get_next, extract_data - ) - list_authorization_rules.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/wcfRelays/{relayName}/authorizationRules'} # type: ignore - def create_or_update_authorization_rule( + @distributed_trace + def regenerate_keys( self, - resource_group_name, # type: str - namespace_name, # type: str - relay_name, # type: str - authorization_rule_name, # type: str - parameters, # type: "_models.AuthorizationRule" - **kwargs # type: Any - ): - # type: (...) -> "_models.AuthorizationRule" - """Creates or updates an authorization rule for a WCF relay. + resource_group_name: str, + namespace_name: str, + relay_name: str, + authorization_rule_name: str, + parameters: "_models.RegenerateAccessKeyParameters", + **kwargs: Any + ) -> "_models.AccessKeys": + """Regenerates the primary or secondary connection strings to the WCF relay. :param resource_group_name: Name of the Resource group within the Azure subscription. :type resource_group_name: str @@ -419,137 +838,152 @@ def create_or_update_authorization_rule( :type relay_name: str :param authorization_rule_name: The authorization rule name. :type authorization_rule_name: str - :param parameters: The authorization rule parameters. - :type parameters: ~azure.mgmt.relay.models.AuthorizationRule + :param parameters: Parameters supplied to regenerate authorization rule. + :type parameters: ~azure.mgmt.relay.models.RegenerateAccessKeyParameters :keyword callable cls: A custom type or function that will be passed the direct response - :return: AuthorizationRule, or the result of cls(response) - :rtype: ~azure.mgmt.relay.models.AuthorizationRule + :return: AccessKeys, or the result of cls(response) + :rtype: ~azure.mgmt.relay.models.AccessKeys :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AuthorizationRule"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessKeys"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'relayName': self._serialize.url("relay_name", relay_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'AuthorizationRule') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') + + request = build_regenerate_keys_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + relay_name=relay_name, + authorization_rule_name=authorization_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.regenerate_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AuthorizationRule', pipeline_response) + deserialized = self._deserialize('AccessKeys', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/wcfRelays/{relayName}/authorizationRules/{authorizationRuleName}'} # type: ignore - def delete_authorization_rule( + regenerate_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/wcfRelays/{relayName}/authorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore + + + @distributed_trace + def list_by_namespace( self, - resource_group_name, # type: str - namespace_name, # type: str - relay_name, # type: str - authorization_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """Deletes a WCF relay authorization rule. + resource_group_name: str, + namespace_name: str, + **kwargs: Any + ) -> Iterable["_models.WcfRelaysListResult"]: + """Lists the WCF relays within the namespace. :param resource_group_name: Name of the Resource group within the Azure subscription. :type resource_group_name: str :param namespace_name: The namespace name. :type namespace_name: str - :param relay_name: The relay name. - :type relay_name: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None + :return: An iterator like instance of either WcfRelaysListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.relay.models.WcfRelaysListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.WcfRelaysListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.delete_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'relayName': self._serialize.url("relay_name", relay_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + def extract_data(pipeline_response): + deserialized = self._deserialize("WcfRelaysListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + def get_next(next_link=None): + request = prepare_request(next_link) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if cls: - return cls(pipeline_response, None, {}) + return pipeline_response - delete_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/wcfRelays/{relayName}/authorizationRules/{authorizationRuleName}'} # type: ignore - def get_authorization_rule( + return ItemPaged( + get_next, extract_data + ) + list_by_namespace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/wcfRelays"} # type: ignore + + @distributed_trace + def create_or_update( self, - resource_group_name, # type: str - namespace_name, # type: str - relay_name, # type: str - authorization_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.AuthorizationRule" - """Get authorizationRule for a WCF relay by name. + resource_group_name: str, + namespace_name: str, + relay_name: str, + parameters: "_models.WcfRelay", + **kwargs: Any + ) -> "_models.WcfRelay": + """Creates or updates a WCF relay. This operation is idempotent. :param resource_group_name: Name of the Resource group within the Azure subscription. :type resource_group_name: str @@ -557,67 +991,68 @@ def get_authorization_rule( :type namespace_name: str :param relay_name: The relay name. :type relay_name: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_name: str + :param parameters: Parameters supplied to create a WCF relay. + :type parameters: ~azure.mgmt.relay.models.WcfRelay :keyword callable cls: A custom type or function that will be passed the direct response - :return: AuthorizationRule, or the result of cls(response) - :rtype: ~azure.mgmt.relay.models.AuthorizationRule + :return: WcfRelay, or the result of cls(response) + :rtype: ~azure.mgmt.relay.models.WcfRelay :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AuthorizationRule"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.WcfRelay"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.get_authorization_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'relayName': self._serialize.url("relay_name", relay_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'WcfRelay') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + relay_name=relay_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AuthorizationRule', pipeline_response) + deserialized = self._deserialize('WcfRelay', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_authorization_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/wcfRelays/{relayName}/authorizationRules/{authorizationRuleName}'} # type: ignore - def list_keys( + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/wcfRelays/{relayName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - namespace_name, # type: str - relay_name, # type: str - authorization_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.AccessKeys" - """Primary and secondary connection strings to the WCF relay. + resource_group_name: str, + namespace_name: str, + relay_name: str, + **kwargs: Any + ) -> None: + """Deletes a WCF relay. :param resource_group_name: Name of the Resource group within the Azure subscription. :type resource_group_name: str @@ -625,68 +1060,58 @@ def list_keys( :type namespace_name: str :param relay_name: The relay name. :type relay_name: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) - :rtype: ~azure.mgmt.relay.models.AccessKeys + :return: None, or the result of cls(response) + :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessKeys"] + cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'relayName': self._serialize.url("relay_name", relay_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-11-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + relay_name=relay_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, None, {}) - return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/wcfRelays/{relayName}/authorizationRules/{authorizationRuleName}/listKeys'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/wcfRelays/{relayName}"} # type: ignore - def regenerate_keys( + + @distributed_trace + def get( self, - resource_group_name, # type: str - namespace_name, # type: str - relay_name, # type: str - authorization_rule_name, # type: str - parameters, # type: "_models.RegenerateAccessKeyParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.AccessKeys" - """Regenerates the primary or secondary connection strings to the WCF relay. + resource_group_name: str, + namespace_name: str, + relay_name: str, + **kwargs: Any + ) -> Optional["_models.WcfRelay"]: + """Returns the description for the specified WCF relay. :param resource_group_name: Name of the Resource group within the Azure subscription. :type resource_group_name: str @@ -694,60 +1119,51 @@ def regenerate_keys( :type namespace_name: str :param relay_name: The relay name. :type relay_name: str - :param authorization_rule_name: The authorization rule name. - :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate authorization rule. - :type parameters: ~azure.mgmt.relay.models.RegenerateAccessKeyParameters :keyword callable cls: A custom type or function that will be passed the direct response - :return: AccessKeys, or the result of cls(response) - :rtype: ~azure.mgmt.relay.models.AccessKeys + :return: WcfRelay, or the result of cls(response) + :rtype: ~azure.mgmt.relay.models.WcfRelay or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessKeys"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WcfRelay"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.regenerate_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'namespaceName': self._serialize.url("namespace_name", namespace_name, 'str', max_length=50, min_length=6), - 'relayName': self._serialize.url("relay_name", relay_name, 'str', min_length=1), - 'authorizationRuleName': self._serialize.url("authorization_rule_name", authorization_rule_name, 'str', min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RegenerateAccessKeyParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2021-11-01") # type: str + + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + relay_name=relay_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AccessKeys', pipeline_response) + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('WcfRelay', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/wcfRelays/{relayName}/authorizationRules/{authorizationRuleName}/regenerateKeys'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Relay/namespaces/{namespaceName}/wcfRelays/{relayName}"} # type: ignore +