diff --git a/sdk/managementpartner/azure-mgmt-managementpartner/_meta.json b/sdk/managementpartner/azure-mgmt-managementpartner/_meta.json index 0ff932a4e6b36..c7354403de3bd 100644 --- a/sdk/managementpartner/azure-mgmt-managementpartner/_meta.json +++ b/sdk/managementpartner/azure-mgmt-managementpartner/_meta.json @@ -1,11 +1,11 @@ { - "autorest": "3.4.2", + "autorest": "3.7.2", "use": [ - "@autorest/python@5.8.0", - "@autorest/modelerfour@4.19.1" + "@autorest/python@5.12.0", + "@autorest/modelerfour@4.19.3" ], - "commit": "5e5a121565cd3e17243e4dc973257d6d15ca94a8", + "commit": "e8c6db17dc13a00155936dcaeacf4da0a1fabf77", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/managementpartner/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --track2 --use=@autorest/python@5.8.0 --use=@autorest/modelerfour@4.19.1 --version=3.4.2", + "autorest_command": "autorest specification/managementpartner/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/managementpartner/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/__init__.py b/sdk/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/__init__.py index 8773016039de5..ade35cfbba7c0 100644 --- a/sdk/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/__init__.py +++ b/sdk/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['ACEProvisioningManagementPartnerAPI'] -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/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/_ace_provisioning_management_partner_api.py b/sdk/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/_ace_provisioning_management_partner_api.py index 6e249969a5ad2..53aba48862d0c 100644 --- a/sdk/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/_ace_provisioning_management_partner_api.py +++ b/sdk/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/_ace_provisioning_management_partner_api.py @@ -6,26 +6,22 @@ # 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 ACEProvisioningManagementPartnerAPIConfiguration +from .operations import OperationOperations, PartnerOperations, PartnersOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import ACEProvisioningManagementPartnerAPIConfiguration -from .operations import PartnerOperations -from .operations import OperationOperations -from .operations import PartnersOperations -from . import models - -class ACEProvisioningManagementPartnerAPI(object): +class ACEProvisioningManagementPartnerAPI: """This API describe ACE Provisioning ManagementPartner. :ivar partner: PartnerOperations operations @@ -36,47 +32,53 @@ class ACEProvisioningManagementPartnerAPI(object): :vartype partners: azure.mgmt.managementpartner.operations.PartnersOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ def __init__( self, - credential, # type: "TokenCredential" - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = ACEProvisioningManagementPartnerAPIConfiguration(credential, **kwargs) + credential: "TokenCredential", + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = ACEProvisioningManagementPartnerAPIConfiguration(credential=credential, **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.partner = PartnerOperations(self._client, self._config, self._serialize, self._deserialize) + self.operation = OperationOperations(self._client, self._config, self._serialize, self._deserialize) + self.partners = PartnersOperations(self._client, self._config, self._serialize, self._deserialize) - self.partner = PartnerOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operation = OperationOperations( - self._client, self._config, self._serialize, self._deserialize) - self.partners = PartnersOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) def close(self): # type: () -> None diff --git a/sdk/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/_configuration.py b/sdk/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/_configuration.py index 4176b5b8427f8..6190000d1f619 100644 --- a/sdk/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/_configuration.py +++ b/sdk/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/_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 @@ -33,13 +31,12 @@ class ACEProvisioningManagementPartnerAPIConfiguration(Configuration): def __init__( self, - credential, # type: "TokenCredential" - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + **kwargs: Any + ) -> None: + super(ACEProvisioningManagementPartnerAPIConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") - super(ACEProvisioningManagementPartnerAPIConfiguration, self).__init__(**kwargs) self.credential = credential self.api_version = "2018-02-01" @@ -62,4 +59,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/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/_metadata.json b/sdk/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/_metadata.json index edfffb6b7782a..f646f17edd3b1 100644 --- a/sdk/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/_metadata.json +++ b/sdk/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/_metadata.json @@ -5,13 +5,13 @@ "name": "ACEProvisioningManagementPartnerAPI", "filename": "_ace_provisioning_management_partner_api", "description": "This API describe ACE Provisioning ManagementPartner.", - "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": false, "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\": [\"ACEProvisioningManagementPartnerAPIConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ACEProvisioningManagementPartnerAPIConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ACEProvisioningManagementPartnerAPIConfiguration\"]}}, \"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\": [\"ACEProvisioningManagementPartnerAPIConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -42,7 +42,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 @@ -62,7 +62,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 @@ -79,11 +79,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "partner": "PartnerOperations", diff --git a/sdk/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/_patch.py b/sdk/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/_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/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/_vendor.py b/sdk/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/_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/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/_version.py b/sdk/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/_version.py index c47f66669f1bf..e5754a47ce68f 100644 --- a/sdk/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/_version.py +++ b/sdk/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/_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/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/aio/__init__.py b/sdk/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/aio/__init__.py index bac84c7cf672d..513cd91a3890e 100644 --- a/sdk/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/aio/__init__.py +++ b/sdk/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/aio/__init__.py @@ -8,3 +8,8 @@ from ._ace_provisioning_management_partner_api import ACEProvisioningManagementPartnerAPI __all__ = ['ACEProvisioningManagementPartnerAPI'] + +# `._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/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/aio/_ace_provisioning_management_partner_api.py b/sdk/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/aio/_ace_provisioning_management_partner_api.py index 860f6a4968cd3..fba193e0e1b60 100644 --- a/sdk/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/aio/_ace_provisioning_management_partner_api.py +++ b/sdk/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/aio/_ace_provisioning_management_partner_api.py @@ -6,24 +6,22 @@ # 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.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import ACEProvisioningManagementPartnerAPIConfiguration +from .operations import OperationOperations, PartnerOperations, PartnersOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import ACEProvisioningManagementPartnerAPIConfiguration -from .operations import PartnerOperations -from .operations import OperationOperations -from .operations import PartnersOperations -from .. import models - - -class ACEProvisioningManagementPartnerAPI(object): +class ACEProvisioningManagementPartnerAPI: """This API describe ACE Provisioning ManagementPartner. :ivar partner: PartnerOperations operations @@ -34,45 +32,53 @@ class ACEProvisioningManagementPartnerAPI(object): :vartype partners: azure.mgmt.managementpartner.aio.operations.PartnersOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ def __init__( self, credential: "AsyncTokenCredential", - 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 = ACEProvisioningManagementPartnerAPIConfiguration(credential, **kwargs) + self._config = ACEProvisioningManagementPartnerAPIConfiguration(credential=credential, **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.partner = PartnerOperations(self._client, self._config, self._serialize, self._deserialize) + self.operation = OperationOperations(self._client, self._config, self._serialize, self._deserialize) + self.partners = PartnersOperations(self._client, self._config, self._serialize, self._deserialize) - self.partner = PartnerOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operation = OperationOperations( - self._client, self._config, self._serialize, self._deserialize) - self.partners = PartnersOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() diff --git a/sdk/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/aio/_configuration.py b/sdk/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/aio/_configuration.py index 7d7a8b9371c84..91a5f05a15fe9 100644 --- a/sdk/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/aio/_configuration.py +++ b/sdk/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/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 @@ -34,9 +34,9 @@ def __init__( credential: "AsyncTokenCredential", **kwargs: Any ) -> None: + super(ACEProvisioningManagementPartnerAPIConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") - super(ACEProvisioningManagementPartnerAPIConfiguration, self).__init__(**kwargs) self.credential = credential self.api_version = "2018-02-01" @@ -58,4 +58,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/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/aio/_patch.py b/sdk/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/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/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/aio/operations/_operation_operations.py b/sdk/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/aio/operations/_operation_operations.py index 9699d616b823a..032d37311471f 100644 --- a/sdk/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/aio/operations/_operation_operations.py +++ b/sdk/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/aio/operations/_operation_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._operation_operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -51,7 +57,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OperationList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managementpartner.models.OperationList] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managementpartner.models.OperationList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationList"] @@ -59,30 +66,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-02-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + 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('OperationList', pipeline_response) + deserialized = self._deserialize("OperationList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -95,12 +99,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.Error, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/aio/operations/_partner_operations.py b/sdk/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/aio/operations/_partner_operations.py index 357cd65eabef9..cfbffb1b6f524 100644 --- a/sdk/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/aio/operations/_partner_operations.py +++ b/sdk/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/aio/operations/_partner_operations.py @@ -5,16 +5,20 @@ # 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, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._partner_operations import build_create_request, build_delete_request, build_get_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, partner_id: str, @@ -61,31 +66,21 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-02-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'partnerId': self._serialize.url("partner_id", partner_id, 'str'), - } - url = self._client.format_url(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 = build_get_request( + partner_id=partner_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) + error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PartnerResponse', pipeline_response) @@ -94,8 +89,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/providers/Microsoft.ManagementPartner/partners/{partnerId}'} # type: ignore + + @distributed_trace_async async def create( self, partner_id: str, @@ -117,31 +115,21 @@ async def create( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-02-01" - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'partnerId': self._serialize.url("partner_id", partner_id, 'str'), - } - url = self._client.format_url(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 = build_create_request( + partner_id=partner_id, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.put(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.Error, response) + error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PartnerResponse', pipeline_response) @@ -150,8 +138,11 @@ async def create( return cls(pipeline_response, deserialized, {}) return deserialized + create.metadata = {'url': '/providers/Microsoft.ManagementPartner/partners/{partnerId}'} # type: ignore + + @distributed_trace_async async def update( self, partner_id: str, @@ -173,31 +164,21 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-02-01" - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'partnerId': self._serialize.url("partner_id", partner_id, 'str'), - } - url = self._client.format_url(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 = build_update_request( + partner_id=partner_id, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.patch(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.Error, response) + error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PartnerResponse', pipeline_response) @@ -206,8 +187,11 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/providers/Microsoft.ManagementPartner/partners/{partnerId}'} # type: ignore + + @distributed_trace_async async def delete( self, partner_id: str, @@ -229,34 +213,25 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-02-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'partnerId': self._serialize.url("partner_id", partner_id, 'str'), - } - url = self._client.format_url(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 = build_delete_request( + partner_id=partner_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) + error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) delete.metadata = {'url': '/providers/Microsoft.ManagementPartner/partners/{partnerId}'} # type: ignore + diff --git a/sdk/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/aio/operations/_partners_operations.py b/sdk/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/aio/operations/_partners_operations.py index 88b04e502f555..ad7fc46944193 100644 --- a/sdk/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/aio/operations/_partners_operations.py +++ b/sdk/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/aio/operations/_partners_operations.py @@ -5,16 +5,20 @@ # 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, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._partners_operations import build_get_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, **kwargs: Any @@ -58,27 +63,20 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-02-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[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( + 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.Error, response) + error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PartnerResponse', pipeline_response) @@ -87,4 +85,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/providers/Microsoft.ManagementPartner/partners'} # type: ignore + diff --git a/sdk/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/models/__init__.py b/sdk/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/models/__init__.py index 0814acc0d319f..6fc1a6e09f2c7 100644 --- a/sdk/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/models/__init__.py +++ b/sdk/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/models/__init__.py @@ -6,20 +6,13 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import Error - from ._models_py3 import ExtendedErrorInfo - from ._models_py3 import OperationDisplay - from ._models_py3 import OperationList - from ._models_py3 import OperationResponse - from ._models_py3 import PartnerResponse -except (SyntaxError, ImportError): - from ._models import Error # type: ignore - from ._models import ExtendedErrorInfo # type: ignore - from ._models import OperationDisplay # type: ignore - from ._models import OperationList # type: ignore - from ._models import OperationResponse # type: ignore - from ._models import PartnerResponse # type: ignore +from ._models_py3 import Error +from ._models_py3 import ExtendedErrorInfo +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationList +from ._models_py3 import OperationResponse +from ._models_py3 import PartnerResponse + from ._ace_provisioning_management_partner_api_enums import ( ErrorResponseCode, diff --git a/sdk/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/models/_ace_provisioning_management_partner_api_enums.py b/sdk/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/models/_ace_provisioning_management_partner_api_enums.py index 17bb66911b893..f68b8488f3f0b 100644 --- a/sdk/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/models/_ace_provisioning_management_partner_api_enums.py +++ b/sdk/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/models/_ace_provisioning_management_partner_api_enums.py @@ -6,27 +6,12 @@ # 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 ErrorResponseCode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ErrorResponseCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """this is the error response code that management partner operations may return """ @@ -34,7 +19,7 @@ class ErrorResponseCode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): CONFLICT = "Conflict" BAD_REQUEST = "BadRequest" -class ManagementPartnerState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ManagementPartnerState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """this is the management partner state: Active or Deleted """ diff --git a/sdk/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/models/_models.py b/sdk/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/models/_models.py deleted file mode 100644 index 594d9c85a426c..0000000000000 --- a/sdk/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/models/_models.py +++ /dev/null @@ -1,205 +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 Error(msrest.serialization.Model): - """this is the management partner operations error. - - :param error: this is the ExtendedErrorInfo property. - :type error: ~azure.mgmt.managementpartner.models.ExtendedErrorInfo - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ExtendedErrorInfo'}, - } - - def __init__( - self, - **kwargs - ): - super(Error, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -class ExtendedErrorInfo(msrest.serialization.Model): - """this is the extended error info. - - :param code: this is the error response code. Possible values include: "NotFound", "Conflict", - "BadRequest". - :type code: str or ~azure.mgmt.managementpartner.models.ErrorResponseCode - :param message: this is the extended error info message. - :type message: str - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ExtendedErrorInfo, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - - -class OperationDisplay(msrest.serialization.Model): - """this is the management partner operation. - - :param provider: the is management partner provider. - :type provider: str - :param resource: the is management partner resource. - :type resource: str - :param operation: the is management partner operation. - :type operation: str - :param description: the is management partner operation description. - :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(OperationDisplay, 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 OperationList(msrest.serialization.Model): - """this is the management partner operations list. - - :param value: this is the operation response list. - :type value: list[~azure.mgmt.managementpartner.models.OperationResponse] - :param next_link: Url to get the next page of items. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[OperationResponse]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class OperationResponse(msrest.serialization.Model): - """this is the management partner operations response. - - :param name: this is the operation response name. - :type name: str - :param display: this is the operation display. - :type display: ~azure.mgmt.managementpartner.models.OperationDisplay - :param origin: the is operation response origin information. - :type origin: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - 'origin': {'key': 'origin', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationResponse, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.display = kwargs.get('display', None) - self.origin = kwargs.get('origin', None) - - -class PartnerResponse(msrest.serialization.Model): - """this is the management partner operations response. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param etag: Type of the partner. - :type etag: int - :ivar id: Identifier of the partner. - :vartype id: str - :ivar name: Name of the partner. - :vartype name: str - :ivar type: Type of resource. "Microsoft.ManagementPartner/partners". - :vartype type: str - :param partner_id: This is the partner id. - :type partner_id: str - :param partner_name: This is the partner name. - :type partner_name: str - :param tenant_id: This is the tenant id. - :type tenant_id: str - :param object_id: This is the object id. - :type object_id: str - :param version: This is the version. - :type version: int - :param updated_time: This is the DateTime when the partner was updated. - :type updated_time: ~datetime.datetime - :param created_time: This is the DateTime when the partner was created. - :type created_time: ~datetime.datetime - :param state: This is the partner state. Possible values include: "Active", "Deleted". - :type state: str or ~azure.mgmt.managementpartner.models.ManagementPartnerState - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'etag': {'key': 'etag', 'type': 'int'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'partner_id': {'key': 'properties.partnerId', 'type': 'str'}, - 'partner_name': {'key': 'properties.partnerName', 'type': 'str'}, - 'tenant_id': {'key': 'properties.tenantId', 'type': 'str'}, - 'object_id': {'key': 'properties.objectId', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'int'}, - 'updated_time': {'key': 'properties.updatedTime', 'type': 'iso-8601'}, - 'created_time': {'key': 'properties.createdTime', 'type': 'iso-8601'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PartnerResponse, self).__init__(**kwargs) - self.etag = kwargs.get('etag', None) - self.id = None - self.name = None - self.type = None - self.partner_id = kwargs.get('partner_id', None) - self.partner_name = kwargs.get('partner_name', None) - self.tenant_id = kwargs.get('tenant_id', None) - self.object_id = kwargs.get('object_id', None) - self.version = kwargs.get('version', None) - self.updated_time = kwargs.get('updated_time', None) - self.created_time = kwargs.get('created_time', None) - self.state = kwargs.get('state', None) diff --git a/sdk/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/models/_models_py3.py b/sdk/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/models/_models_py3.py index 0307c54da7e84..5cbcfd90d6cb7 100644 --- a/sdk/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/models/_models_py3.py +++ b/sdk/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/models/_models_py3.py @@ -18,8 +18,8 @@ class Error(msrest.serialization.Model): """this is the management partner operations error. - :param error: this is the ExtendedErrorInfo property. - :type error: ~azure.mgmt.managementpartner.models.ExtendedErrorInfo + :ivar error: this is the ExtendedErrorInfo property. + :vartype error: ~azure.mgmt.managementpartner.models.ExtendedErrorInfo """ _attribute_map = { @@ -32,6 +32,10 @@ def __init__( error: Optional["ExtendedErrorInfo"] = None, **kwargs ): + """ + :keyword error: this is the ExtendedErrorInfo property. + :paramtype error: ~azure.mgmt.managementpartner.models.ExtendedErrorInfo + """ super(Error, self).__init__(**kwargs) self.error = error @@ -39,11 +43,11 @@ def __init__( class ExtendedErrorInfo(msrest.serialization.Model): """this is the extended error info. - :param code: this is the error response code. Possible values include: "NotFound", "Conflict", + :ivar code: this is the error response code. Possible values include: "NotFound", "Conflict", "BadRequest". - :type code: str or ~azure.mgmt.managementpartner.models.ErrorResponseCode - :param message: this is the extended error info message. - :type message: str + :vartype code: str or ~azure.mgmt.managementpartner.models.ErrorResponseCode + :ivar message: this is the extended error info message. + :vartype message: str """ _attribute_map = { @@ -58,6 +62,13 @@ def __init__( message: Optional[str] = None, **kwargs ): + """ + :keyword code: this is the error response code. Possible values include: "NotFound", + "Conflict", "BadRequest". + :paramtype code: str or ~azure.mgmt.managementpartner.models.ErrorResponseCode + :keyword message: this is the extended error info message. + :paramtype message: str + """ super(ExtendedErrorInfo, self).__init__(**kwargs) self.code = code self.message = message @@ -66,14 +77,14 @@ def __init__( class OperationDisplay(msrest.serialization.Model): """this is the management partner operation. - :param provider: the is management partner provider. - :type provider: str - :param resource: the is management partner resource. - :type resource: str - :param operation: the is management partner operation. - :type operation: str - :param description: the is management partner operation description. - :type description: str + :ivar provider: the is management partner provider. + :vartype provider: str + :ivar resource: the is management partner resource. + :vartype resource: str + :ivar operation: the is management partner operation. + :vartype operation: str + :ivar description: the is management partner operation description. + :vartype description: str """ _attribute_map = { @@ -92,6 +103,16 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword provider: the is management partner provider. + :paramtype provider: str + :keyword resource: the is management partner resource. + :paramtype resource: str + :keyword operation: the is management partner operation. + :paramtype operation: str + :keyword description: the is management partner operation description. + :paramtype description: str + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = provider self.resource = resource @@ -102,10 +123,10 @@ def __init__( class OperationList(msrest.serialization.Model): """this is the management partner operations list. - :param value: this is the operation response list. - :type value: list[~azure.mgmt.managementpartner.models.OperationResponse] - :param next_link: Url to get the next page of items. - :type next_link: str + :ivar value: this is the operation response list. + :vartype value: list[~azure.mgmt.managementpartner.models.OperationResponse] + :ivar next_link: Url to get the next page of items. + :vartype next_link: str """ _attribute_map = { @@ -120,6 +141,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: this is the operation response list. + :paramtype value: list[~azure.mgmt.managementpartner.models.OperationResponse] + :keyword next_link: Url to get the next page of items. + :paramtype next_link: str + """ super(OperationList, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -128,12 +155,12 @@ def __init__( class OperationResponse(msrest.serialization.Model): """this is the management partner operations response. - :param name: this is the operation response name. - :type name: str - :param display: this is the operation display. - :type display: ~azure.mgmt.managementpartner.models.OperationDisplay - :param origin: the is operation response origin information. - :type origin: str + :ivar name: this is the operation response name. + :vartype name: str + :ivar display: this is the operation display. + :vartype display: ~azure.mgmt.managementpartner.models.OperationDisplay + :ivar origin: the is operation response origin information. + :vartype origin: str """ _attribute_map = { @@ -150,6 +177,14 @@ def __init__( origin: Optional[str] = None, **kwargs ): + """ + :keyword name: this is the operation response name. + :paramtype name: str + :keyword display: this is the operation display. + :paramtype display: ~azure.mgmt.managementpartner.models.OperationDisplay + :keyword origin: the is operation response origin information. + :paramtype origin: str + """ super(OperationResponse, self).__init__(**kwargs) self.name = name self.display = display @@ -161,30 +196,30 @@ class PartnerResponse(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param etag: Type of the partner. - :type etag: int + :ivar etag: Type of the partner. + :vartype etag: int :ivar id: Identifier of the partner. :vartype id: str :ivar name: Name of the partner. :vartype name: str :ivar type: Type of resource. "Microsoft.ManagementPartner/partners". :vartype type: str - :param partner_id: This is the partner id. - :type partner_id: str - :param partner_name: This is the partner name. - :type partner_name: str - :param tenant_id: This is the tenant id. - :type tenant_id: str - :param object_id: This is the object id. - :type object_id: str - :param version: This is the version. - :type version: int - :param updated_time: This is the DateTime when the partner was updated. - :type updated_time: ~datetime.datetime - :param created_time: This is the DateTime when the partner was created. - :type created_time: ~datetime.datetime - :param state: This is the partner state. Possible values include: "Active", "Deleted". - :type state: str or ~azure.mgmt.managementpartner.models.ManagementPartnerState + :ivar partner_id: This is the partner id. + :vartype partner_id: str + :ivar partner_name: This is the partner name. + :vartype partner_name: str + :ivar tenant_id: This is the tenant id. + :vartype tenant_id: str + :ivar object_id: This is the object id. + :vartype object_id: str + :ivar version: This is the version. + :vartype version: int + :ivar updated_time: This is the DateTime when the partner was updated. + :vartype updated_time: ~datetime.datetime + :ivar created_time: This is the DateTime when the partner was created. + :vartype created_time: ~datetime.datetime + :ivar state: This is the partner state. Possible values include: "Active", "Deleted". + :vartype state: str or ~azure.mgmt.managementpartner.models.ManagementPartnerState """ _validation = { @@ -222,6 +257,26 @@ def __init__( state: Optional[Union[str, "ManagementPartnerState"]] = None, **kwargs ): + """ + :keyword etag: Type of the partner. + :paramtype etag: int + :keyword partner_id: This is the partner id. + :paramtype partner_id: str + :keyword partner_name: This is the partner name. + :paramtype partner_name: str + :keyword tenant_id: This is the tenant id. + :paramtype tenant_id: str + :keyword object_id: This is the object id. + :paramtype object_id: str + :keyword version: This is the version. + :paramtype version: int + :keyword updated_time: This is the DateTime when the partner was updated. + :paramtype updated_time: ~datetime.datetime + :keyword created_time: This is the DateTime when the partner was created. + :paramtype created_time: ~datetime.datetime + :keyword state: This is the partner state. Possible values include: "Active", "Deleted". + :paramtype state: str or ~azure.mgmt.managementpartner.models.ManagementPartnerState + """ super(PartnerResponse, self).__init__(**kwargs) self.etag = etag self.id = None diff --git a/sdk/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/operations/_operation_operations.py b/sdk/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/operations/_operation_operations.py index abc2eca7374c8..f5a7528d57831 100644 --- a/sdk/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/operations/_operation_operations.py +++ b/sdk/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/operations/_operation_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-02-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.ManagementPartner/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 OperationOperations(object): """OperationOperations operations. @@ -45,11 +72,11 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OperationList"] + **kwargs: Any + ) -> Iterable["_models.OperationList"]: """Get operations. List all the operations. @@ -64,30 +91,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-02-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + 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('OperationList', pipeline_response) + deserialized = self._deserialize("OperationList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -100,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.Error, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/operations/_partner_operations.py b/sdk/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/operations/_partner_operations.py index 0af8f12ccf524..2fa22c531b4af 100644 --- a/sdk/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/operations/_partner_operations.py +++ b/sdk/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/operations/_partner_operations.py @@ -5,22 +5,148 @@ # 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, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import 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, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + partner_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-02-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.ManagementPartner/partners/{partnerId}') + path_format_arguments = { + "partnerId": _SERIALIZER.url("partner_id", partner_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_request( + partner_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-02-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.ManagementPartner/partners/{partnerId}') + path_format_arguments = { + "partnerId": _SERIALIZER.url("partner_id", partner_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_update_request( + partner_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-02-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.ManagementPartner/partners/{partnerId}') + path_format_arguments = { + "partnerId": _SERIALIZER.url("partner_id", partner_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request( + partner_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-02-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.ManagementPartner/partners/{partnerId}') + path_format_arguments = { + "partnerId": _SERIALIZER.url("partner_id", partner_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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 + ) class PartnerOperations(object): """PartnerOperations operations. @@ -44,12 +170,12 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - partner_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.PartnerResponse" + partner_id: str, + **kwargs: Any + ) -> "_models.PartnerResponse": """Get a specific ``Partner``. Get the management partner using the partnerId, objectId and tenantId. @@ -66,31 +192,21 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-02-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'partnerId': self._serialize.url("partner_id", partner_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[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( + partner_id=partner_id, + 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.Error, response) + error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PartnerResponse', pipeline_response) @@ -99,14 +215,16 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/providers/Microsoft.ManagementPartner/partners/{partnerId}'} # type: ignore + + @distributed_trace def create( self, - partner_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.PartnerResponse" + partner_id: str, + **kwargs: Any + ) -> "_models.PartnerResponse": """Create a specific ``Partner``. Create a management partner for the objectId and tenantId. @@ -123,31 +241,21 @@ def create( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-02-01" - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'partnerId': self._serialize.url("partner_id", partner_id, 'str'), - } - url = self._client.format_url(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 = build_create_request( + partner_id=partner_id, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.put(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.Error, response) + error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PartnerResponse', pipeline_response) @@ -156,14 +264,16 @@ def create( return cls(pipeline_response, deserialized, {}) return deserialized + create.metadata = {'url': '/providers/Microsoft.ManagementPartner/partners/{partnerId}'} # type: ignore + + @distributed_trace def update( self, - partner_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.PartnerResponse" + partner_id: str, + **kwargs: Any + ) -> "_models.PartnerResponse": """Update a specific ``Partner``. Update the management partner for the objectId and tenantId. @@ -180,31 +290,21 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-02-01" - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'partnerId': self._serialize.url("partner_id", partner_id, 'str'), - } - url = self._client.format_url(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 = build_update_request( + partner_id=partner_id, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.patch(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.Error, response) + error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PartnerResponse', pipeline_response) @@ -213,14 +313,16 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/providers/Microsoft.ManagementPartner/partners/{partnerId}'} # type: ignore + + @distributed_trace def delete( self, - partner_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + partner_id: str, + **kwargs: Any + ) -> None: """Delete a specific ``Partner``. Delete the management partner for the objectId and tenantId. @@ -237,34 +339,25 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-02-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'partnerId': self._serialize.url("partner_id", partner_id, 'str'), - } - url = self._client.format_url(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 = build_delete_request( + partner_id=partner_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) + error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) delete.metadata = {'url': '/providers/Microsoft.ManagementPartner/partners/{partnerId}'} # type: ignore + diff --git a/sdk/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/operations/_partners_operations.py b/sdk/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/operations/_partners_operations.py index 34b3865d30cf1..3d3e8adf20c56 100644 --- a/sdk/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/operations/_partners_operations.py +++ b/sdk/managementpartner/azure-mgmt-managementpartner/azure/mgmt/managementpartner/operations/_partners_operations.py @@ -5,22 +5,49 @@ # 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, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import 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, 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_get_request( + **kwargs: Any +) -> HttpRequest: + api_version = "2018-02-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.ManagementPartner/partners') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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 PartnersOperations(object): """PartnersOperations operations. @@ -44,11 +71,11 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - **kwargs # type: Any - ): - # type: (...) -> "_models.PartnerResponse" + **kwargs: Any + ) -> "_models.PartnerResponse": """Get a specific ``Partner``. Get the management partner using the objectId and tenantId. @@ -63,27 +90,20 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-02-01" - accept = "application/json" - - # Construct URL - url = self.get.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_get_request( + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.Error, response) + error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PartnerResponse', pipeline_response) @@ -92,4 +112,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/providers/Microsoft.ManagementPartner/partners'} # type: ignore +