diff --git a/sdk/customproviders/azure-mgmt-customproviders/_meta.json b/sdk/customproviders/azure-mgmt-customproviders/_meta.json index b505b6117c0a..b17ec7d0bc0a 100644 --- a/sdk/customproviders/azure-mgmt-customproviders/_meta.json +++ b/sdk/customproviders/azure-mgmt-customproviders/_meta.json @@ -1,8 +1,11 @@ { - "autorest": "3.0.6369", - "use": "@autorest/python@5.6.2", - "commit": "63a5f68654047b16c9039c799f1a6370f628fb20", + "autorest": "3.7.2", + "use": [ + "@autorest/python@5.12.0", + "@autorest/modelerfour@4.19.3" + ], + "commit": "a1a226aeedd94d0ca8ebb263af5b99e3ba77166c", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/customproviders/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.6.2 --version=3.0.6369", + "autorest_command": "autorest specification/customproviders/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --python3-only --track2 --use=@autorest/python@5.12.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", "readme": "specification/customproviders/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/__init__.py b/sdk/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/__init__.py index f84b69800675..592705179c1e 100644 --- a/sdk/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/__init__.py +++ b/sdk/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['Customproviders'] -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/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/_configuration.py b/sdk/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/_configuration.py index e3ca0e53b370..1f0eeaf7f141 100644 --- a/sdk/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/_configuration.py +++ b/sdk/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/_configuration.py @@ -6,18 +6,16 @@ # 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 @@ -35,16 +33,15 @@ class CustomprovidersConfiguration(Configuration): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(CustomprovidersConfiguration, self).__init__(**kwargs) 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(CustomprovidersConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +65,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/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/_customproviders.py b/sdk/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/_customproviders.py index 6e1f54199efa..94e60d2b0583 100644 --- a/sdk/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/_customproviders.py +++ b/sdk/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/_customproviders.py @@ -6,65 +6,86 @@ # 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, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import CustomprovidersConfiguration +from .operations import AssociationsOperations, CustomResourceProviderOperations, Operations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - from azure.core.credentials import TokenCredential -from ._configuration import CustomprovidersConfiguration -from .operations import Operations -from .operations import CustomResourceProviderOperations -from .operations import AssociationsOperations -from . import models - - -class Customproviders(object): +class Customproviders: """Allows extension of ARM control plane with custom resource providers. :ivar operations: Operations operations :vartype operations: azure.mgmt.customproviders.operations.Operations :ivar custom_resource_provider: CustomResourceProviderOperations operations - :vartype custom_resource_provider: azure.mgmt.customproviders.operations.CustomResourceProviderOperations + :vartype custom_resource_provider: + azure.mgmt.customproviders.operations.CustomResourceProviderOperations :ivar associations: AssociationsOperations operations :vartype associations: azure.mgmt.customproviders.operations.AssociationsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). + :param subscription_id: The Azure subscription ID. This is a GUID-formatted string (e.g. + 00000000-0000-0000-0000-000000000000). :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 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 = CustomprovidersConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = CustomprovidersConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.custom_resource_provider = CustomResourceProviderOperations(self._client, self._config, self._serialize, self._deserialize) + self.associations = AssociationsOperations(self._client, self._config, self._serialize, self._deserialize) + + + def _send_request( + self, + request, # type: HttpRequest + **kwargs: Any + ) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/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.rest.HttpResponse + """ - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.custom_resource_provider = CustomResourceProviderOperations( - self._client, self._config, self._serialize, self._deserialize) - self.associations = AssociationsOperations( - self._client, self._config, self._serialize, self._deserialize) + 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/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/_metadata.json b/sdk/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/_metadata.json index 6610be0d5d23..57102080ca9b 100644 --- a/sdk/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/_metadata.json +++ b/sdk/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/_metadata.json @@ -5,13 +5,13 @@ "name": "Customproviders", "filename": "_customproviders", "description": "Allows extension of ARM control plane with custom resource providers.", - "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\": [\"CustomprovidersConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "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\": [\"CustomprovidersConfiguration\"]}}, \"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\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"CustomprovidersConfiguration\"]}}, \"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,21 +91,14 @@ "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", "custom_resource_provider": "CustomResourceProviderOperations", "associations": "AssociationsOperations" - }, - "operation_mixins": { - "sync_imports": "None", - "async_imports": "None", - "operations": { - } } } \ No newline at end of file diff --git a/sdk/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/_patch.py b/sdk/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/_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/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/_vendor.py b/sdk/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/_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/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/_version.py b/sdk/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/_version.py index c47f66669f1b..e5754a47ce68 100644 --- a/sdk/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/_version.py +++ b/sdk/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/aio/__init__.py b/sdk/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/aio/__init__.py index 158a0fe1249e..7d0cb20c0916 100644 --- a/sdk/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/aio/__init__.py +++ b/sdk/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/aio/__init__.py @@ -8,3 +8,8 @@ from ._customproviders import Customproviders __all__ = ['Customproviders'] + +# `._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/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/aio/_configuration.py b/sdk/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/aio/_configuration.py index ff711016d8da..ba89c466283d 100644 --- a/sdk/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/aio/_configuration.py +++ b/sdk/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/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 @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(CustomprovidersConfiguration, self).__init__(**kwargs) 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(CustomprovidersConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,4 +64,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/aio/_customproviders.py b/sdk/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/aio/_customproviders.py index 72d807d98c07..61d18ebb8319 100644 --- a/sdk/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/aio/_customproviders.py +++ b/sdk/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/aio/_customproviders.py @@ -6,62 +6,86 @@ # 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, Optional, TYPE_CHECKING +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import CustomprovidersConfiguration +from .operations import AssociationsOperations, CustomResourceProviderOperations, Operations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import CustomprovidersConfiguration -from .operations import Operations -from .operations import CustomResourceProviderOperations -from .operations import AssociationsOperations -from .. import models - - -class Customproviders(object): +class Customproviders: """Allows extension of ARM control plane with custom resource providers. :ivar operations: Operations operations :vartype operations: azure.mgmt.customproviders.aio.operations.Operations :ivar custom_resource_provider: CustomResourceProviderOperations operations - :vartype custom_resource_provider: azure.mgmt.customproviders.aio.operations.CustomResourceProviderOperations + :vartype custom_resource_provider: + azure.mgmt.customproviders.aio.operations.CustomResourceProviderOperations :ivar associations: AssociationsOperations operations :vartype associations: azure.mgmt.customproviders.aio.operations.AssociationsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). + :param subscription_id: The Azure subscription ID. This is a GUID-formatted string (e.g. + 00000000-0000-0000-0000-000000000000). :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 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 = CustomprovidersConfiguration(credential, subscription_id, **kwargs) + self._config = CustomprovidersConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.custom_resource_provider = CustomResourceProviderOperations(self._client, self._config, self._serialize, self._deserialize) + self.associations = AssociationsOperations(self._client, self._config, self._serialize, self._deserialize) + + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/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.rest.AsyncHttpResponse + """ - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.custom_resource_provider = CustomResourceProviderOperations( - self._client, self._config, self._serialize, self._deserialize) - self.associations = AssociationsOperations( - self._client, self._config, self._serialize, self._deserialize) + 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/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/aio/_patch.py b/sdk/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/aio/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/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/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/aio/operations/_associations_operations.py b/sdk/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/aio/operations/_associations_operations.py index 6287af8c5f75..50722f345b48 100644 --- a/sdk/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/aio/operations/_associations_operations.py +++ b/sdk/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/aio/operations/_associations_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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._associations_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_all_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -48,45 +53,34 @@ async def _create_or_update_initial( scope: str, association_name: str, association: "_models.Association", - **kwargs + **kwargs: Any ) -> "_models.Association": cls = kwargs.pop('cls', None) # type: ClsType["_models.Association"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'associationName': self._serialize.url("association_name", association_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(association, 'Association') + + request = build_create_or_update_request_initial( + scope=scope, + association_name=association_name, + 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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(association, 'Association') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.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('Association', pipeline_response) @@ -98,20 +92,24 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/{scope}/providers/Microsoft.CustomProviders/associations/{associationName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, scope: str, association_name: str, association: "_models.Association", - **kwargs + **kwargs: Any ) -> AsyncLROPoller["_models.Association"]: """Create or update an association. :param scope: The scope of the association. The scope can be any valid REST resource instance. - For example, use '/subscriptions/{subscription-id}/resourceGroups/{resource-group- - name}/providers/Microsoft.Compute/virtualMachines/{vm-name}' for a virtual machine resource. + For example, use + '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Compute/virtualMachines/{vm-name}' + for a virtual machine resource. :type scope: str :param association_name: The name of the association. :type association_name: str @@ -119,15 +117,19 @@ async def begin_create_or_update( :type association: ~azure.mgmt.customproviders.models.Association :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: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or 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 Association 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 Association or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.customproviders.models.Association] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.Association"] lro_delay = kwargs.pop( 'polling_interval', @@ -139,26 +141,21 @@ async def begin_create_or_update( scope=scope, association_name=association_name, association=association, + 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('Association', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'associationName': self._serialize.url("association_name", association_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -170,57 +167,49 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/{scope}/providers/Microsoft.CustomProviders/associations/{associationName}'} # type: ignore async def _delete_initial( self, scope: str, association_name: str, - **kwargs + **kwargs: Any ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'associationName': self._serialize.url("association_name", association_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + scope=scope, + association_name=association_name, + 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) 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': '/{scope}/providers/Microsoft.CustomProviders/associations/{associationName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, scope: str, association_name: str, - **kwargs + **kwargs: Any ) -> AsyncLROPoller[None]: """Delete an association. @@ -230,15 +219,17 @@ async def begin_delete( :type association_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: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or 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 """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -252,20 +243,14 @@ async def begin_delete( 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 = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'associationName': self._serialize.url("association_name", association_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -277,13 +262,15 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/{scope}/providers/Microsoft.CustomProviders/associations/{associationName}'} # type: ignore + @distributed_trace_async async def get( self, scope: str, association_name: str, - **kwargs + **kwargs: Any ) -> "_models.Association": """Get an association. @@ -301,32 +288,22 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'associationName': self._serialize.url("association_name", association_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + scope=scope, + association_name=association_name, + 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) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Association', pipeline_response) @@ -335,12 +312,15 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.CustomProviders/associations/{associationName}'} # type: ignore + + @distributed_trace def list_all( self, scope: str, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.AssociationsList"]: """Gets all association for the given scope. @@ -348,7 +328,8 @@ def list_all( :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AssociationsList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.customproviders.models.AssociationsList] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.customproviders.models.AssociationsList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.AssociationsList"] @@ -356,34 +337,29 @@ def list_all( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_all.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_all_request( + scope=scope, + template_url=self.list_all.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_all_request( + scope=scope, + 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('AssociationsList', pipeline_response) + deserialized = self._deserialize("AssociationsList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -396,12 +372,13 @@ async def get_next(next_link=None): 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 ) diff --git a/sdk/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/aio/operations/_custom_resource_provider_operations.py b/sdk/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/aio/operations/_custom_resource_provider_operations.py index f07c25847794..6c467282e4a4 100644 --- a/sdk/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/aio/operations/_custom_resource_provider_operations.py +++ b/sdk/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/aio/operations/_custom_resource_provider_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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._custom_resource_provider_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -48,46 +53,35 @@ async def _create_or_update_initial( resource_group_name: str, resource_provider_name: str, resource_provider: "_models.CustomRPManifest", - **kwargs + **kwargs: Any ) -> "_models.CustomRPManifest": cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomRPManifest"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceProviderName': self._serialize.url("resource_provider_name", resource_provider_name, 'str', max_length=64, min_length=3), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(resource_provider, 'CustomRPManifest') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_provider_name=resource_provider_name, + 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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(resource_provider, 'CustomRPManifest') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.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('CustomRPManifest', pipeline_response) @@ -99,14 +93,17 @@ 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.CustomProviders/resourceProviders/{resourceProviderName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, resource_provider_name: str, resource_provider: "_models.CustomRPManifest", - **kwargs + **kwargs: Any ) -> AsyncLROPoller["_models.CustomRPManifest"]: """Creates or updates the custom resource provider. @@ -119,15 +116,19 @@ async def begin_create_or_update( :type resource_provider: ~azure.mgmt.customproviders.models.CustomRPManifest :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: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or 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 CustomRPManifest 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 CustomRPManifest or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.customproviders.models.CustomRPManifest] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomRPManifest"] lro_delay = kwargs.pop( 'polling_interval', @@ -139,27 +140,21 @@ async def begin_create_or_update( resource_group_name=resource_group_name, resource_provider_name=resource_provider_name, resource_provider=resource_provider, + 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('CustomRPManifest', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceProviderName': self._serialize.url("resource_provider_name", resource_provider_name, 'str', max_length=64, min_length=3), - } - 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: @@ -171,58 +166,50 @@ def get_long_running_output(pipeline_response): ) 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.CustomProviders/resourceProviders/{resourceProviderName}'} # type: ignore async def _delete_initial( self, resource_group_name: str, resource_provider_name: str, - **kwargs + **kwargs: Any ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceProviderName': self._serialize.url("resource_provider_name", resource_provider_name, 'str', max_length=64, min_length=3), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[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_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_provider_name=resource_provider_name, + 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) 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.CustomProviders/resourceProviders/{resourceProviderName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, resource_provider_name: str, - **kwargs + **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the custom resource provider. @@ -232,15 +219,17 @@ async def begin_delete( :type resource_provider_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: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or 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 """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -254,21 +243,14 @@ async def begin_delete( 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 = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceProviderName': self._serialize.url("resource_provider_name", resource_provider_name, 'str', max_length=64, min_length=3), - } - 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: @@ -280,13 +262,15 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, resource_provider_name: str, - **kwargs + **kwargs: Any ) -> "_models.CustomRPManifest": """Gets the custom resource provider manifest. @@ -304,33 +288,23 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceProviderName': self._serialize.url("resource_provider_name", resource_provider_name, 'str', max_length=64, min_length=3), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[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_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_provider_name=resource_provider_name, + 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) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CustomRPManifest', pipeline_response) @@ -339,14 +313,17 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, resource_provider_name: str, patchable_resource: "_models.ResourceProvidersUpdate", - **kwargs + **kwargs: Any ) -> "_models.CustomRPManifest": """Updates an existing custom resource provider. The only value that can be updated via PATCH currently is the tags. @@ -367,38 +344,28 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceProviderName': self._serialize.url("resource_provider_name", resource_provider_name, 'str', max_length=64, min_length=3), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(patchable_resource, 'ResourceProvidersUpdate') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_provider_name=resource_provider_name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(patchable_resource, 'ResourceProvidersUpdate') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CustomRPManifest', pipeline_response) @@ -407,20 +374,25 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}'} # type: ignore + + @distributed_trace def list_by_resource_group( self, resource_group_name: str, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.ListByCustomRPManifest"]: """Gets all the custom resource providers within a resource group. :param resource_group_name: The name of the resource group. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ListByCustomRPManifest or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.customproviders.models.ListByCustomRPManifest] + :return: An iterator like instance of either ListByCustomRPManifest or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.customproviders.models.ListByCustomRPManifest] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ListByCustomRPManifest"] @@ -428,35 +400,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + 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( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + 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('ListByCustomRPManifest', pipeline_response) + deserialized = self._deserialize("ListByCustomRPManifest", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -469,26 +437,30 @@ async def get_next(next_link=None): 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.CustomProviders/resourceProviders'} # type: ignore + @distributed_trace def list_by_subscription( self, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.ListByCustomRPManifest"]: """Gets all the custom resource providers within a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ListByCustomRPManifest or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.customproviders.models.ListByCustomRPManifest] + :return: An iterator like instance of either ListByCustomRPManifest or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.customproviders.models.ListByCustomRPManifest] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ListByCustomRPManifest"] @@ -496,34 +468,29 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + 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('ListByCustomRPManifest', pipeline_response) + deserialized = self._deserialize("ListByCustomRPManifest", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -536,12 +503,13 @@ async def get_next(next_link=None): 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 ) diff --git a/sdk/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/aio/operations/_operations.py b/sdk/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/aio/operations/_operations.py index 3af9e30e4589..9d38618b3a51 100644 --- a/sdk/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/aio/operations/_operations.py +++ b/sdk/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/aio/operations/_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.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._operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,15 +46,18 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.ResourceProviderOperationList"]: """The list of operations provided by Microsoft CustomProviders. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceProviderOperationList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.customproviders.models.ResourceProviderOperationList] + :return: An iterator like instance of either ResourceProviderOperationList or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.customproviders.models.ResourceProviderOperationList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceProviderOperationList"] @@ -57,30 +65,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + 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( + 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('ResourceProviderOperationList', pipeline_response) + deserialized = self._deserialize("ResourceProviderOperationList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -93,12 +98,13 @@ async def get_next(next_link=None): 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 ) diff --git a/sdk/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/models/__init__.py b/sdk/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/models/__init__.py index a196b22c81ad..25dd5a60a06f 100644 --- a/sdk/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/models/__init__.py +++ b/sdk/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/models/__init__.py @@ -6,38 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import Association - from ._models_py3 import AssociationsList - from ._models_py3 import CustomRPActionRouteDefinition - from ._models_py3 import CustomRPManifest - from ._models_py3 import CustomRPResourceTypeRouteDefinition - from ._models_py3 import CustomRPRouteDefinition - from ._models_py3 import CustomRPValidations - from ._models_py3 import ErrorDefinition - from ._models_py3 import ErrorResponse - from ._models_py3 import ListByCustomRPManifest - from ._models_py3 import Resource - from ._models_py3 import ResourceProviderOperation - from ._models_py3 import ResourceProviderOperationDisplay - from ._models_py3 import ResourceProviderOperationList - from ._models_py3 import ResourceProvidersUpdate -except (SyntaxError, ImportError): - from ._models import Association # type: ignore - from ._models import AssociationsList # type: ignore - from ._models import CustomRPActionRouteDefinition # type: ignore - from ._models import CustomRPManifest # type: ignore - from ._models import CustomRPResourceTypeRouteDefinition # type: ignore - from ._models import CustomRPRouteDefinition # type: ignore - from ._models import CustomRPValidations # type: ignore - from ._models import ErrorDefinition # type: ignore - from ._models import ErrorResponse # type: ignore - from ._models import ListByCustomRPManifest # type: ignore - from ._models import Resource # type: ignore - from ._models import ResourceProviderOperation # type: ignore - from ._models import ResourceProviderOperationDisplay # type: ignore - from ._models import ResourceProviderOperationList # type: ignore - from ._models import ResourceProvidersUpdate # type: ignore +from ._models_py3 import Association +from ._models_py3 import AssociationsList +from ._models_py3 import CustomRPActionRouteDefinition +from ._models_py3 import CustomRPManifest +from ._models_py3 import CustomRPResourceTypeRouteDefinition +from ._models_py3 import CustomRPRouteDefinition +from ._models_py3 import CustomRPValidations +from ._models_py3 import ErrorDefinition +from ._models_py3 import ErrorResponse +from ._models_py3 import ListByCustomRPManifest +from ._models_py3 import Resource +from ._models_py3 import ResourceProviderOperation +from ._models_py3 import ResourceProviderOperationDisplay +from ._models_py3 import ResourceProviderOperationList +from ._models_py3 import ResourceProvidersUpdate + from ._customproviders_enums import ( ActionRouting, diff --git a/sdk/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/models/_customproviders_enums.py b/sdk/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/models/_customproviders_enums.py index 25436b9160cf..9be3dc70db26 100644 --- a/sdk/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/models/_customproviders_enums.py +++ b/sdk/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/models/_customproviders_enums.py @@ -6,33 +6,18 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta +from enum import Enum from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class ActionRouting(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ActionRouting(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The routing types that are supported for action requests. """ PROXY = "Proxy" -class ProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The provisioning state of the resource provider. """ @@ -42,14 +27,14 @@ class ProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): SUCCEEDED = "Succeeded" FAILED = "Failed" -class ResourceTypeRouting(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ResourceTypeRouting(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The routing types that are supported for resource requests. """ PROXY = "Proxy" PROXY_CACHE = "Proxy,Cache" -class ValidationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ValidationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of validation to run against a matching request. """ diff --git a/sdk/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/models/_models.py b/sdk/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/models/_models.py deleted file mode 100644 index 40602c5e5304..000000000000 --- a/sdk/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/models/_models.py +++ /dev/null @@ -1,497 +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 Association(msrest.serialization.Model): - """The resource definition of this association. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The association id. - :vartype id: str - :ivar name: The association name. - :vartype name: str - :ivar type: The association type. - :vartype type: str - :param target_resource_id: The REST resource instance of the target resource for this - association. - :type target_resource_id: str - :ivar provisioning_state: The provisioning state of the association. Possible values include: - "Accepted", "Deleting", "Running", "Succeeded", "Failed". - :vartype provisioning_state: str or ~azure.mgmt.customproviders.models.ProvisioningState - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'target_resource_id': {'key': 'properties.targetResourceId', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Association, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.target_resource_id = kwargs.get('target_resource_id', None) - self.provisioning_state = None - - -class AssociationsList(msrest.serialization.Model): - """List of associations. - - :param value: The array of associations. - :type value: list[~azure.mgmt.customproviders.models.Association] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Association]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AssociationsList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class CustomRPRouteDefinition(msrest.serialization.Model): - """A route definition that defines an action or resource that can be interacted with through the custom resource provider. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. The name of the route definition. This becomes the name for the ARM - extension (e.g. - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}/{name}'). - :type name: str - :param endpoint: Required. The route definition endpoint URI that the custom resource provider - will proxy requests to. This can be in the form of a flat URI (e.g. 'https://testendpoint/') or - can specify to route via a path (e.g. 'https://testendpoint/{requestPath}'). - :type endpoint: str - """ - - _validation = { - 'name': {'required': True}, - 'endpoint': {'required': True, 'pattern': r'^https://.+'}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'endpoint': {'key': 'endpoint', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CustomRPRouteDefinition, self).__init__(**kwargs) - self.name = kwargs['name'] - self.endpoint = kwargs['endpoint'] - - -class CustomRPActionRouteDefinition(CustomRPRouteDefinition): - """The route definition for an action implemented by the custom resource provider. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. The name of the route definition. This becomes the name for the ARM - extension (e.g. - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}/{name}'). - :type name: str - :param endpoint: Required. The route definition endpoint URI that the custom resource provider - will proxy requests to. This can be in the form of a flat URI (e.g. 'https://testendpoint/') or - can specify to route via a path (e.g. 'https://testendpoint/{requestPath}'). - :type endpoint: str - :param routing_type: The routing types that are supported for action requests. Possible values - include: "Proxy". - :type routing_type: str or ~azure.mgmt.customproviders.models.ActionRouting - """ - - _validation = { - 'name': {'required': True}, - 'endpoint': {'required': True, 'pattern': r'^https://.+'}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'endpoint': {'key': 'endpoint', 'type': 'str'}, - 'routing_type': {'key': 'routingType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CustomRPActionRouteDefinition, self).__init__(**kwargs) - self.routing_type = kwargs.get('routing_type', None) - - -class Resource(msrest.serialization.Model): - """The resource definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param location: Required. 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(Resource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = kwargs['location'] - self.tags = kwargs.get('tags', None) - - -class CustomRPManifest(Resource): - """A manifest file that defines the custom resource provider resources. - - 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 actions: A list of actions that the custom resource provider implements. - :type actions: list[~azure.mgmt.customproviders.models.CustomRPActionRouteDefinition] - :param resource_types: A list of resource types that the custom resource provider implements. - :type resource_types: - list[~azure.mgmt.customproviders.models.CustomRPResourceTypeRouteDefinition] - :param validations: A list of validations to run on the custom resource provider's requests. - :type validations: list[~azure.mgmt.customproviders.models.CustomRPValidations] - :ivar provisioning_state: The provisioning state of the resource provider. Possible values - include: "Accepted", "Deleting", "Running", "Succeeded", "Failed". - :vartype provisioning_state: str or ~azure.mgmt.customproviders.models.ProvisioningState - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'actions': {'key': 'properties.actions', 'type': '[CustomRPActionRouteDefinition]'}, - 'resource_types': {'key': 'properties.resourceTypes', 'type': '[CustomRPResourceTypeRouteDefinition]'}, - 'validations': {'key': 'properties.validations', 'type': '[CustomRPValidations]'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CustomRPManifest, self).__init__(**kwargs) - self.actions = kwargs.get('actions', None) - self.resource_types = kwargs.get('resource_types', None) - self.validations = kwargs.get('validations', None) - self.provisioning_state = None - - -class CustomRPResourceTypeRouteDefinition(CustomRPRouteDefinition): - """The route definition for a resource implemented by the custom resource provider. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. The name of the route definition. This becomes the name for the ARM - extension (e.g. - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}/{name}'). - :type name: str - :param endpoint: Required. The route definition endpoint URI that the custom resource provider - will proxy requests to. This can be in the form of a flat URI (e.g. 'https://testendpoint/') or - can specify to route via a path (e.g. 'https://testendpoint/{requestPath}'). - :type endpoint: str - :param routing_type: The routing types that are supported for resource requests. Possible - values include: "Proxy", "Proxy,Cache". - :type routing_type: str or ~azure.mgmt.customproviders.models.ResourceTypeRouting - """ - - _validation = { - 'name': {'required': True}, - 'endpoint': {'required': True, 'pattern': r'^https://.+'}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'endpoint': {'key': 'endpoint', 'type': 'str'}, - 'routing_type': {'key': 'routingType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CustomRPResourceTypeRouteDefinition, self).__init__(**kwargs) - self.routing_type = kwargs.get('routing_type', None) - - -class CustomRPValidations(msrest.serialization.Model): - """A validation to apply on custom resource provider requests. - - All required parameters must be populated in order to send to Azure. - - :param validation_type: The type of validation to run against a matching request. Possible - values include: "Swagger". - :type validation_type: str or ~azure.mgmt.customproviders.models.ValidationType - :param specification: Required. A link to the validation specification. The specification must - be hosted on raw.githubusercontent.com. - :type specification: str - """ - - _validation = { - 'specification': {'required': True, 'pattern': r'^https://raw.githubusercontent.com/.+'}, - } - - _attribute_map = { - 'validation_type': {'key': 'validationType', 'type': 'str'}, - 'specification': {'key': 'specification', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CustomRPValidations, self).__init__(**kwargs) - self.validation_type = kwargs.get('validation_type', None) - self.specification = kwargs['specification'] - - -class ErrorDefinition(msrest.serialization.Model): - """Error definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: Service specific error code which serves as the substatus for the HTTP error code. - :vartype code: str - :ivar message: Description of the error. - :vartype message: str - :ivar details: Internal error details. - :vartype details: list[~azure.mgmt.customproviders.models.ErrorDefinition] - """ - - _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'details': {'readonly': True}, - } - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorDefinition]'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorDefinition, self).__init__(**kwargs) - self.code = None - self.message = None - self.details = None - - -class ErrorResponse(msrest.serialization.Model): - """Error response. - - :param error: The error details. - :type error: ~azure.mgmt.customproviders.models.ErrorDefinition - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDefinition'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -class ListByCustomRPManifest(msrest.serialization.Model): - """List of custom resource providers. - - :param value: The array of custom resource provider manifests. - :type value: list[~azure.mgmt.customproviders.models.CustomRPManifest] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[CustomRPManifest]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ListByCustomRPManifest, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class ResourceProviderOperation(msrest.serialization.Model): - """Supported operations of this resource provider. - - :param name: Operation name, in format of {provider}/{resource}/{operation}. - :type name: str - :param display: Display metadata associated with the operation. - :type display: ~azure.mgmt.customproviders.models.ResourceProviderOperationDisplay - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'ResourceProviderOperationDisplay'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceProviderOperation, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.display = kwargs.get('display', None) - - -class ResourceProviderOperationDisplay(msrest.serialization.Model): - """Display metadata associated with the operation. - - :param provider: Resource provider: Microsoft Custom Providers. - :type provider: str - :param resource: Resource on which the operation is performed. - :type resource: str - :param operation: Type of operation: get, read, delete, etc. - :type operation: str - :param description: Description of this operation. - :type description: str - """ - - _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(ResourceProviderOperationDisplay, self).__init__(**kwargs) - self.provider = kwargs.get('provider', None) - self.resource = kwargs.get('resource', None) - self.operation = kwargs.get('operation', None) - self.description = kwargs.get('description', None) - - -class ResourceProviderOperationList(msrest.serialization.Model): - """Results of the request to list operations. - - :param value: List of operations supported by this resource provider. - :type value: list[~azure.mgmt.customproviders.models.ResourceProviderOperation] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ResourceProviderOperation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceProviderOperationList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class ResourceProvidersUpdate(msrest.serialization.Model): - """custom resource provider update information. - - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceProvidersUpdate, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) diff --git a/sdk/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/models/_models_py3.py b/sdk/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/models/_models_py3.py index 638244eb3348..93210180abbf 100644 --- a/sdk/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/models/_models_py3.py +++ b/sdk/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/models/_models_py3.py @@ -25,9 +25,9 @@ class Association(msrest.serialization.Model): :vartype name: str :ivar type: The association type. :vartype type: str - :param target_resource_id: The REST resource instance of the target resource for this + :ivar target_resource_id: The REST resource instance of the target resource for this association. - :type target_resource_id: str + :vartype target_resource_id: str :ivar provisioning_state: The provisioning state of the association. Possible values include: "Accepted", "Deleting", "Running", "Succeeded", "Failed". :vartype provisioning_state: str or ~azure.mgmt.customproviders.models.ProvisioningState @@ -54,6 +54,11 @@ def __init__( target_resource_id: Optional[str] = None, **kwargs ): + """ + :keyword target_resource_id: The REST resource instance of the target resource for this + association. + :paramtype target_resource_id: str + """ super(Association, self).__init__(**kwargs) self.id = None self.name = None @@ -65,10 +70,10 @@ def __init__( class AssociationsList(msrest.serialization.Model): """List of associations. - :param value: The array of associations. - :type value: list[~azure.mgmt.customproviders.models.Association] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: The array of associations. + :vartype value: list[~azure.mgmt.customproviders.models.Association] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -83,6 +88,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: The array of associations. + :paramtype value: list[~azure.mgmt.customproviders.models.Association] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(AssociationsList, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -93,14 +104,14 @@ class CustomRPRouteDefinition(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the route definition. This becomes the name for the ARM + :ivar name: Required. The name of the route definition. This becomes the name for the ARM extension (e.g. '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}/{name}'). - :type name: str - :param endpoint: Required. The route definition endpoint URI that the custom resource provider + :vartype name: str + :ivar endpoint: Required. The route definition endpoint URI that the custom resource provider will proxy requests to. This can be in the form of a flat URI (e.g. 'https://testendpoint/') or can specify to route via a path (e.g. 'https://testendpoint/{requestPath}'). - :type endpoint: str + :vartype endpoint: str """ _validation = { @@ -120,6 +131,17 @@ def __init__( endpoint: str, **kwargs ): + """ + :keyword name: Required. The name of the route definition. This becomes the name for the ARM + extension (e.g. + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}/{name}'). + :paramtype name: str + :keyword endpoint: Required. The route definition endpoint URI that the custom resource + provider will proxy requests to. This can be in the form of a flat URI (e.g. + 'https://testendpoint/') or can specify to route via a path (e.g. + 'https://testendpoint/{requestPath}'). + :paramtype endpoint: str + """ super(CustomRPRouteDefinition, self).__init__(**kwargs) self.name = name self.endpoint = endpoint @@ -130,17 +152,17 @@ class CustomRPActionRouteDefinition(CustomRPRouteDefinition): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the route definition. This becomes the name for the ARM + :ivar name: Required. The name of the route definition. This becomes the name for the ARM extension (e.g. '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}/{name}'). - :type name: str - :param endpoint: Required. The route definition endpoint URI that the custom resource provider + :vartype name: str + :ivar endpoint: Required. The route definition endpoint URI that the custom resource provider will proxy requests to. This can be in the form of a flat URI (e.g. 'https://testendpoint/') or can specify to route via a path (e.g. 'https://testendpoint/{requestPath}'). - :type endpoint: str - :param routing_type: The routing types that are supported for action requests. Possible values + :vartype endpoint: str + :ivar routing_type: The routing types that are supported for action requests. Possible values include: "Proxy". - :type routing_type: str or ~azure.mgmt.customproviders.models.ActionRouting + :vartype routing_type: str or ~azure.mgmt.customproviders.models.ActionRouting """ _validation = { @@ -162,6 +184,20 @@ def __init__( routing_type: Optional[Union[str, "ActionRouting"]] = None, **kwargs ): + """ + :keyword name: Required. The name of the route definition. This becomes the name for the ARM + extension (e.g. + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}/{name}'). + :paramtype name: str + :keyword endpoint: Required. The route definition endpoint URI that the custom resource + provider will proxy requests to. This can be in the form of a flat URI (e.g. + 'https://testendpoint/') or can specify to route via a path (e.g. + 'https://testendpoint/{requestPath}'). + :paramtype endpoint: str + :keyword routing_type: The routing types that are supported for action requests. Possible + values include: "Proxy". + :paramtype routing_type: str or ~azure.mgmt.customproviders.models.ActionRouting + """ super(CustomRPActionRouteDefinition, self).__init__(name=name, endpoint=endpoint, **kwargs) self.routing_type = routing_type @@ -179,10 +215,10 @@ class Resource(msrest.serialization.Model): :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 = { @@ -207,6 +243,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(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -228,17 +270,17 @@ class CustomRPManifest(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] - :param actions: A list of actions that the custom resource provider implements. - :type actions: list[~azure.mgmt.customproviders.models.CustomRPActionRouteDefinition] - :param resource_types: A list of resource types that the custom resource provider implements. - :type resource_types: + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar actions: A list of actions that the custom resource provider implements. + :vartype actions: list[~azure.mgmt.customproviders.models.CustomRPActionRouteDefinition] + :ivar resource_types: A list of resource types that the custom resource provider implements. + :vartype resource_types: list[~azure.mgmt.customproviders.models.CustomRPResourceTypeRouteDefinition] - :param validations: A list of validations to run on the custom resource provider's requests. - :type validations: list[~azure.mgmt.customproviders.models.CustomRPValidations] + :ivar validations: A list of validations to run on the custom resource provider's requests. + :vartype validations: list[~azure.mgmt.customproviders.models.CustomRPValidations] :ivar provisioning_state: The provisioning state of the resource provider. Possible values include: "Accepted", "Deleting", "Running", "Succeeded", "Failed". :vartype provisioning_state: str or ~azure.mgmt.customproviders.models.ProvisioningState @@ -274,6 +316,19 @@ def __init__( validations: Optional[List["CustomRPValidations"]] = None, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword actions: A list of actions that the custom resource provider implements. + :paramtype actions: list[~azure.mgmt.customproviders.models.CustomRPActionRouteDefinition] + :keyword resource_types: A list of resource types that the custom resource provider implements. + :paramtype resource_types: + list[~azure.mgmt.customproviders.models.CustomRPResourceTypeRouteDefinition] + :keyword validations: A list of validations to run on the custom resource provider's requests. + :paramtype validations: list[~azure.mgmt.customproviders.models.CustomRPValidations] + """ super(CustomRPManifest, self).__init__(location=location, tags=tags, **kwargs) self.actions = actions self.resource_types = resource_types @@ -286,17 +341,17 @@ class CustomRPResourceTypeRouteDefinition(CustomRPRouteDefinition): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the route definition. This becomes the name for the ARM + :ivar name: Required. The name of the route definition. This becomes the name for the ARM extension (e.g. '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}/{name}'). - :type name: str - :param endpoint: Required. The route definition endpoint URI that the custom resource provider + :vartype name: str + :ivar endpoint: Required. The route definition endpoint URI that the custom resource provider will proxy requests to. This can be in the form of a flat URI (e.g. 'https://testendpoint/') or can specify to route via a path (e.g. 'https://testendpoint/{requestPath}'). - :type endpoint: str - :param routing_type: The routing types that are supported for resource requests. Possible - values include: "Proxy", "Proxy,Cache". - :type routing_type: str or ~azure.mgmt.customproviders.models.ResourceTypeRouting + :vartype endpoint: str + :ivar routing_type: The routing types that are supported for resource requests. Possible values + include: "Proxy", "Proxy,Cache". + :vartype routing_type: str or ~azure.mgmt.customproviders.models.ResourceTypeRouting """ _validation = { @@ -318,6 +373,20 @@ def __init__( routing_type: Optional[Union[str, "ResourceTypeRouting"]] = None, **kwargs ): + """ + :keyword name: Required. The name of the route definition. This becomes the name for the ARM + extension (e.g. + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}/{name}'). + :paramtype name: str + :keyword endpoint: Required. The route definition endpoint URI that the custom resource + provider will proxy requests to. This can be in the form of a flat URI (e.g. + 'https://testendpoint/') or can specify to route via a path (e.g. + 'https://testendpoint/{requestPath}'). + :paramtype endpoint: str + :keyword routing_type: The routing types that are supported for resource requests. Possible + values include: "Proxy", "Proxy,Cache". + :paramtype routing_type: str or ~azure.mgmt.customproviders.models.ResourceTypeRouting + """ super(CustomRPResourceTypeRouteDefinition, self).__init__(name=name, endpoint=endpoint, **kwargs) self.routing_type = routing_type @@ -327,12 +396,12 @@ class CustomRPValidations(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param validation_type: The type of validation to run against a matching request. Possible + :ivar validation_type: The type of validation to run against a matching request. Possible values include: "Swagger". - :type validation_type: str or ~azure.mgmt.customproviders.models.ValidationType - :param specification: Required. A link to the validation specification. The specification must + :vartype validation_type: str or ~azure.mgmt.customproviders.models.ValidationType + :ivar specification: Required. A link to the validation specification. The specification must be hosted on raw.githubusercontent.com. - :type specification: str + :vartype specification: str """ _validation = { @@ -351,6 +420,14 @@ def __init__( validation_type: Optional[Union[str, "ValidationType"]] = None, **kwargs ): + """ + :keyword validation_type: The type of validation to run against a matching request. Possible + values include: "Swagger". + :paramtype validation_type: str or ~azure.mgmt.customproviders.models.ValidationType + :keyword specification: Required. A link to the validation specification. The specification + must be hosted on raw.githubusercontent.com. + :paramtype specification: str + """ super(CustomRPValidations, self).__init__(**kwargs) self.validation_type = validation_type self.specification = specification @@ -385,6 +462,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorDefinition, self).__init__(**kwargs) self.code = None self.message = None @@ -394,8 +473,8 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """Error response. - :param error: The error details. - :type error: ~azure.mgmt.customproviders.models.ErrorDefinition + :ivar error: The error details. + :vartype error: ~azure.mgmt.customproviders.models.ErrorDefinition """ _attribute_map = { @@ -408,6 +487,10 @@ def __init__( error: Optional["ErrorDefinition"] = None, **kwargs ): + """ + :keyword error: The error details. + :paramtype error: ~azure.mgmt.customproviders.models.ErrorDefinition + """ super(ErrorResponse, self).__init__(**kwargs) self.error = error @@ -415,10 +498,10 @@ def __init__( class ListByCustomRPManifest(msrest.serialization.Model): """List of custom resource providers. - :param value: The array of custom resource provider manifests. - :type value: list[~azure.mgmt.customproviders.models.CustomRPManifest] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: The array of custom resource provider manifests. + :vartype value: list[~azure.mgmt.customproviders.models.CustomRPManifest] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -433,6 +516,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: The array of custom resource provider manifests. + :paramtype value: list[~azure.mgmt.customproviders.models.CustomRPManifest] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(ListByCustomRPManifest, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -441,10 +530,10 @@ def __init__( class ResourceProviderOperation(msrest.serialization.Model): """Supported operations of this resource provider. - :param name: Operation name, in format of {provider}/{resource}/{operation}. - :type name: str - :param display: Display metadata associated with the operation. - :type display: ~azure.mgmt.customproviders.models.ResourceProviderOperationDisplay + :ivar name: Operation name, in format of {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: Display metadata associated with the operation. + :vartype display: ~azure.mgmt.customproviders.models.ResourceProviderOperationDisplay """ _attribute_map = { @@ -459,6 +548,12 @@ def __init__( display: Optional["ResourceProviderOperationDisplay"] = None, **kwargs ): + """ + :keyword name: Operation name, in format of {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: Display metadata associated with the operation. + :paramtype display: ~azure.mgmt.customproviders.models.ResourceProviderOperationDisplay + """ super(ResourceProviderOperation, self).__init__(**kwargs) self.name = name self.display = display @@ -467,14 +562,14 @@ def __init__( class ResourceProviderOperationDisplay(msrest.serialization.Model): """Display metadata associated with the operation. - :param provider: Resource provider: Microsoft Custom Providers. - :type provider: str - :param resource: Resource on which the operation is performed. - :type resource: str - :param operation: Type of operation: get, read, delete, etc. - :type operation: str - :param description: Description of this operation. - :type description: str + :ivar provider: Resource provider: Microsoft Custom Providers. + :vartype provider: str + :ivar resource: Resource on which the operation is performed. + :vartype resource: str + :ivar operation: Type of operation: get, read, delete, etc. + :vartype operation: str + :ivar description: Description of this operation. + :vartype description: str """ _attribute_map = { @@ -493,6 +588,16 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword provider: Resource provider: Microsoft Custom Providers. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed. + :paramtype resource: str + :keyword operation: Type of operation: get, read, delete, etc. + :paramtype operation: str + :keyword description: Description of this operation. + :paramtype description: str + """ super(ResourceProviderOperationDisplay, self).__init__(**kwargs) self.provider = provider self.resource = resource @@ -503,10 +608,10 @@ def __init__( class ResourceProviderOperationList(msrest.serialization.Model): """Results of the request to list operations. - :param value: List of operations supported by this resource provider. - :type value: list[~azure.mgmt.customproviders.models.ResourceProviderOperation] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: List of operations supported by this resource provider. + :vartype value: list[~azure.mgmt.customproviders.models.ResourceProviderOperation] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -521,6 +626,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: List of operations supported by this resource provider. + :paramtype value: list[~azure.mgmt.customproviders.models.ResourceProviderOperation] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(ResourceProviderOperationList, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -529,8 +640,8 @@ def __init__( class ResourceProvidersUpdate(msrest.serialization.Model): """custom resource provider update information. - :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] """ _attribute_map = { @@ -543,5 +654,9 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(ResourceProvidersUpdate, self).__init__(**kwargs) self.tags = tags diff --git a/sdk/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/operations/_associations_operations.py b/sdk/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/operations/_associations_operations.py index 296c8aa8afce..4a09f5604d92 100644 --- a/sdk/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/operations/_associations_operations.py +++ b/sdk/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/operations/_associations_operations.py @@ -5,25 +5,167 @@ # 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings 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 msrest import Serializer 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_create_or_update_request_initial( + scope: str, + association_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-09-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.CustomProviders/associations/{associationName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "associationName": _SERIALIZER.url("association_name", association_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( + scope: str, + association_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.CustomProviders/associations/{associationName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "associationName": _SERIALIZER.url("association_name", association_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( + scope: str, + association_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.CustomProviders/associations/{associationName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "associationName": _SERIALIZER.url("association_name", association_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="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_all_request( + scope: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.CustomProviders/associations') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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 AssociationsOperations(object): """AssociationsOperations operations. @@ -49,49 +191,37 @@ def __init__(self, client, config, serializer, deserializer): def _create_or_update_initial( self, - scope, # type: str - association_name, # type: str - association, # type: "_models.Association" - **kwargs # type: Any - ): - # type: (...) -> "_models.Association" + scope: str, + association_name: str, + association: "_models.Association", + **kwargs: Any + ) -> "_models.Association": cls = kwargs.pop('cls', None) # type: ClsType["_models.Association"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'associationName': self._serialize.url("association_name", association_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(association, 'Association') - # 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') + request = build_create_or_update_request_initial( + scope=scope, + association_name=association_name, + 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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(association, 'Association') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.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('Association', pipeline_response) @@ -103,21 +233,24 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/{scope}/providers/Microsoft.CustomProviders/associations/{associationName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - scope, # type: str - association_name, # type: str - association, # type: "_models.Association" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Association"] + scope: str, + association_name: str, + association: "_models.Association", + **kwargs: Any + ) -> LROPoller["_models.Association"]: """Create or update an association. :param scope: The scope of the association. The scope can be any valid REST resource instance. - For example, use '/subscriptions/{subscription-id}/resourceGroups/{resource-group- - name}/providers/Microsoft.Compute/virtualMachines/{vm-name}' for a virtual machine resource. + For example, use + '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Compute/virtualMachines/{vm-name}' + for a virtual machine resource. :type scope: str :param association_name: The name of the association. :type association_name: str @@ -125,15 +258,19 @@ def begin_create_or_update( :type association: ~azure.mgmt.customproviders.models.Association :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: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or 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 Association 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 Association or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.customproviders.models.Association] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.Association"] lro_delay = kwargs.pop( 'polling_interval', @@ -145,26 +282,21 @@ def begin_create_or_update( scope=scope, association_name=association_name, association=association, + 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('Association', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'associationName': self._serialize.url("association_name", association_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -176,60 +308,50 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/{scope}/providers/Microsoft.CustomProviders/associations/{associationName}'} # type: ignore def _delete_initial( self, - scope, # type: str - association_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + scope: str, + association_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'associationName': self._serialize.url("association_name", association_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + scope=scope, + association_name=association_name, + 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) 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': '/{scope}/providers/Microsoft.CustomProviders/associations/{associationName}'} # type: ignore + + @distributed_trace def begin_delete( self, - scope, # type: str - association_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + scope: str, + association_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Delete an association. :param scope: The scope of the association. @@ -238,15 +360,17 @@ def begin_delete( :type association_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: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or 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 """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -260,20 +384,14 @@ def begin_delete( 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 = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'associationName': self._serialize.url("association_name", association_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -285,15 +403,16 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/{scope}/providers/Microsoft.CustomProviders/associations/{associationName}'} # type: ignore + @distributed_trace def get( self, - scope, # type: str - association_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Association" + scope: str, + association_name: str, + **kwargs: Any + ) -> "_models.Association": """Get an association. :param scope: The scope of the association. @@ -310,32 +429,22 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'associationName': self._serialize.url("association_name", association_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + scope=scope, + association_name=association_name, + 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) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Association', pipeline_response) @@ -344,14 +453,16 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.CustomProviders/associations/{associationName}'} # type: ignore + + @distributed_trace def list_all( self, - scope, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AssociationsList"] + scope: str, + **kwargs: Any + ) -> Iterable["_models.AssociationsList"]: """Gets all association for the given scope. :param scope: The scope of the association. @@ -366,34 +477,29 @@ def list_all( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_all.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_all_request( + scope=scope, + template_url=self.list_all.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_all_request( + scope=scope, + 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('AssociationsList', pipeline_response) + deserialized = self._deserialize("AssociationsList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -406,12 +512,13 @@ def get_next(next_link=None): 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 ) diff --git a/sdk/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/operations/_custom_resource_provider_operations.py b/sdk/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/operations/_custom_resource_provider_operations.py index 8a4fed2ac819..7c089176536b 100644 --- a/sdk/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/operations/_custom_resource_provider_operations.py +++ b/sdk/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/operations/_custom_resource_provider_operations.py @@ -5,25 +5,250 @@ # 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings 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 msrest import Serializer 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_create_or_update_request_initial( + subscription_id: str, + resource_group_name: str, + resource_provider_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-09-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "resourceProviderName": _SERIALIZER.url("resource_provider_name", resource_provider_name, 'str', max_length=64, min_length=3), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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( + subscription_id: str, + resource_group_name: str, + resource_provider_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "resourceProviderName": _SERIALIZER.url("resource_provider_name", resource_provider_name, 'str', max_length=64, min_length=3), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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( + subscription_id: str, + resource_group_name: str, + resource_provider_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "resourceProviderName": _SERIALIZER.url("resource_provider_name", resource_provider_name, 'str', max_length=64, min_length=3), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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( + subscription_id: str, + resource_group_name: str, + resource_provider_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-09-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "resourceProviderName": _SERIALIZER.url("resource_provider_name", resource_provider_name, 'str', max_length=64, min_length=3), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_resource_group_request( + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_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="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-09-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.CustomProviders/resourceProviders') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class CustomResourceProviderOperations(object): """CustomResourceProviderOperations operations. @@ -49,50 +274,38 @@ def __init__(self, client, config, serializer, deserializer): def _create_or_update_initial( self, - resource_group_name, # type: str - resource_provider_name, # type: str - resource_provider, # type: "_models.CustomRPManifest" - **kwargs # type: Any - ): - # type: (...) -> "_models.CustomRPManifest" + resource_group_name: str, + resource_provider_name: str, + resource_provider: "_models.CustomRPManifest", + **kwargs: Any + ) -> "_models.CustomRPManifest": cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomRPManifest"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceProviderName': self._serialize.url("resource_provider_name", resource_provider_name, 'str', max_length=64, min_length=3), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(resource_provider, 'CustomRPManifest') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_provider_name=resource_provider_name, + 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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(resource_provider, 'CustomRPManifest') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.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('CustomRPManifest', pipeline_response) @@ -104,16 +317,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.CustomProviders/resourceProviders/{resourceProviderName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - resource_provider_name, # type: str - resource_provider, # type: "_models.CustomRPManifest" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.CustomRPManifest"] + resource_group_name: str, + resource_provider_name: str, + resource_provider: "_models.CustomRPManifest", + **kwargs: Any + ) -> LROPoller["_models.CustomRPManifest"]: """Creates or updates the custom resource provider. :param resource_group_name: The name of the resource group. @@ -125,15 +340,19 @@ def begin_create_or_update( :type resource_provider: ~azure.mgmt.customproviders.models.CustomRPManifest :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: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or 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 CustomRPManifest 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 CustomRPManifest or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.customproviders.models.CustomRPManifest] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomRPManifest"] lro_delay = kwargs.pop( 'polling_interval', @@ -145,27 +364,21 @@ def begin_create_or_update( resource_group_name=resource_group_name, resource_provider_name=resource_provider_name, resource_provider=resource_provider, + 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('CustomRPManifest', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceProviderName': self._serialize.url("resource_provider_name", resource_provider_name, 'str', max_length=64, min_length=3), - } - 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: @@ -177,61 +390,51 @@ def get_long_running_output(pipeline_response): ) 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.CustomProviders/resourceProviders/{resourceProviderName}'} # type: ignore def _delete_initial( self, - resource_group_name, # type: str - resource_provider_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + resource_provider_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceProviderName': self._serialize.url("resource_provider_name", resource_provider_name, 'str', max_length=64, min_length=3), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[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_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_provider_name=resource_provider_name, + 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) 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.CustomProviders/resourceProviders/{resourceProviderName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - resource_provider_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + resource_provider_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Deletes the custom resource provider. :param resource_group_name: The name of the resource group. @@ -240,15 +443,17 @@ def begin_delete( :type resource_provider_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: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or 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 """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -262,21 +467,14 @@ def begin_delete( 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 = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceProviderName': self._serialize.url("resource_provider_name", resource_provider_name, 'str', max_length=64, min_length=3), - } - 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: @@ -288,15 +486,16 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - resource_provider_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.CustomRPManifest" + resource_group_name: str, + resource_provider_name: str, + **kwargs: Any + ) -> "_models.CustomRPManifest": """Gets the custom resource provider manifest. :param resource_group_name: The name of the resource group. @@ -313,33 +512,23 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceProviderName': self._serialize.url("resource_provider_name", resource_provider_name, 'str', max_length=64, min_length=3), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[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_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_provider_name=resource_provider_name, + 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) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CustomRPManifest', pipeline_response) @@ -348,16 +537,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}'} # type: ignore + + @distributed_trace def update( self, - resource_group_name, # type: str - resource_provider_name, # type: str - patchable_resource, # type: "_models.ResourceProvidersUpdate" - **kwargs # type: Any - ): - # type: (...) -> "_models.CustomRPManifest" + resource_group_name: str, + resource_provider_name: str, + patchable_resource: "_models.ResourceProvidersUpdate", + **kwargs: Any + ) -> "_models.CustomRPManifest": """Updates an existing custom resource provider. The only value that can be updated via PATCH currently is the tags. @@ -377,38 +568,28 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceProviderName': self._serialize.url("resource_provider_name", resource_provider_name, 'str', max_length=64, min_length=3), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(patchable_resource, 'ResourceProvidersUpdate') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_provider_name=resource_provider_name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(patchable_resource, 'ResourceProvidersUpdate') - 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) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CustomRPManifest', pipeline_response) @@ -417,20 +598,23 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}'} # type: ignore + + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ListByCustomRPManifest"] + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.ListByCustomRPManifest"]: """Gets all the custom resource providers within a resource group. :param resource_group_name: The name of the resource group. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ListByCustomRPManifest or the result of cls(response) + :return: An iterator like instance of either ListByCustomRPManifest or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.customproviders.models.ListByCustomRPManifest] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -439,35 +623,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + 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( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + 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('ListByCustomRPManifest', pipeline_response) + deserialized = self._deserialize("ListByCustomRPManifest", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -480,26 +660,28 @@ def get_next(next_link=None): 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.CustomProviders/resourceProviders'} # type: ignore + @distributed_trace def list_by_subscription( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ListByCustomRPManifest"] + **kwargs: Any + ) -> Iterable["_models.ListByCustomRPManifest"]: """Gets all the custom resource providers within a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ListByCustomRPManifest or the result of cls(response) + :return: An iterator like instance of either ListByCustomRPManifest or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.customproviders.models.ListByCustomRPManifest] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -508,34 +690,29 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + 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('ListByCustomRPManifest', pipeline_response) + deserialized = self._deserialize("ListByCustomRPManifest", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -548,12 +725,13 @@ def get_next(next_link=None): 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 ) diff --git a/sdk/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/operations/_operations.py b/sdk/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/operations/_operations.py index 8442d7feb9d5..2c8aa64d7f69 100644 --- a/sdk/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/operations/_operations.py +++ b/sdk/customproviders/azure-mgmt-customproviders/azure/mgmt/customproviders/operations/_operations.py @@ -5,23 +5,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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings 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 msrest import Serializer 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 = "2018-09-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.CustomProviders/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,16 +72,18 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ResourceProviderOperationList"] + **kwargs: Any + ) -> Iterable["_models.ResourceProviderOperationList"]: """The list of operations provided by Microsoft CustomProviders. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceProviderOperationList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.customproviders.models.ResourceProviderOperationList] + :return: An iterator like instance of either ResourceProviderOperationList or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.customproviders.models.ResourceProviderOperationList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceProviderOperationList"] @@ -62,30 +91,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + 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( + 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('ResourceProviderOperationList', pipeline_response) + deserialized = self._deserialize("ResourceProviderOperationList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -98,12 +124,13 @@ def get_next(next_link=None): 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 )