diff --git a/sdk/sql/azure-mgmt-sqlvirtualmachine/_meta.json b/sdk/sql/azure-mgmt-sqlvirtualmachine/_meta.json index 7bb4978883e9..02ad1885b2c7 100644 --- a/sdk/sql/azure-mgmt-sqlvirtualmachine/_meta.json +++ b/sdk/sql/azure-mgmt-sqlvirtualmachine/_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": "3fb60b76412e88b9b4dceec9723a7d68eba513b4", + "commit": "6ba37b7279bbd0d69042743246780cc3af9257b9", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/sqlvirtualmachine/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/sqlvirtualmachine/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/sqlvirtualmachine/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/__init__.py b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/__init__.py index a04832314d83..a056e3f0c70b 100644 --- a/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/__init__.py +++ b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['SqlVirtualMachineManagementClient'] -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/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/_configuration.py b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/_configuration.py index 6787072b571c..caa5257b4960 100644 --- a/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/_configuration.py +++ b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/_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 SqlVirtualMachineManagementClientConfiguration(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(SqlVirtualMachineManagementClientConfiguration, 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(SqlVirtualMachineManagementClientConfiguration, 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/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/_metadata.json b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/_metadata.json index ee77bb53de2a..daf345238610 100644 --- a/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/_metadata.json +++ b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/_metadata.json @@ -5,13 +5,13 @@ "name": "SqlVirtualMachineManagementClient", "filename": "_sql_virtual_machine_management_client", "description": "The SQL virtual machine management API provides a RESTful set of web APIs that interact with Azure Compute, Network \u0026 Storage services to manage your SQL Server virtual machine. The API enables users to create, delete and retrieve a SQL virtual machine, SQL virtual machine group or availability group listener.", - "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\": [\"SqlVirtualMachineManagementClientConfiguration\"]}}, \"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\": [\"SqlVirtualMachineManagementClientConfiguration\"]}}, \"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\": [\"SqlVirtualMachineManagementClientConfiguration\"]}}, \"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\": [\"SqlVirtualMachineManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "availability_group_listeners": "AvailabilityGroupListenersOperations", diff --git a/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/_patch.py b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/_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/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/_sql_virtual_machine_management_client.py b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/_sql_virtual_machine_management_client.py index b79a8fcdadfa..911972cb032a 100644 --- a/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/_sql_virtual_machine_management_client.py +++ b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/_sql_virtual_machine_management_client.py @@ -6,89 +6,90 @@ # 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 SqlVirtualMachineManagementClientConfiguration +from .operations import AvailabilityGroupListenersOperations, Operations, SqlVirtualMachineGroupsOperations, SqlVirtualMachinesOperations + 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 SqlVirtualMachineManagementClientConfiguration -from .operations import AvailabilityGroupListenersOperations -from .operations import Operations -from .operations import SqlVirtualMachineGroupsOperations -from .operations import SqlVirtualMachinesOperations -from . import models - -class SqlVirtualMachineManagementClient(object): +class SqlVirtualMachineManagementClient: """The SQL virtual machine management API provides a RESTful set of web APIs that interact with Azure Compute, Network & Storage services to manage your SQL Server virtual machine. The API enables users to create, delete and retrieve a SQL virtual machine, SQL virtual machine group or availability group listener. :ivar availability_group_listeners: AvailabilityGroupListenersOperations operations - :vartype availability_group_listeners: azure.mgmt.sqlvirtualmachine.operations.AvailabilityGroupListenersOperations + :vartype availability_group_listeners: + azure.mgmt.sqlvirtualmachine.operations.AvailabilityGroupListenersOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.sqlvirtualmachine.operations.Operations :ivar sql_virtual_machine_groups: SqlVirtualMachineGroupsOperations operations - :vartype sql_virtual_machine_groups: azure.mgmt.sqlvirtualmachine.operations.SqlVirtualMachineGroupsOperations + :vartype sql_virtual_machine_groups: + azure.mgmt.sqlvirtualmachine.operations.SqlVirtualMachineGroupsOperations :ivar sql_virtual_machines: SqlVirtualMachinesOperations operations - :vartype sql_virtual_machines: azure.mgmt.sqlvirtualmachine.operations.SqlVirtualMachinesOperations + :vartype sql_virtual_machines: + azure.mgmt.sqlvirtualmachine.operations.SqlVirtualMachinesOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: Subscription ID that identifies an Azure subscription. :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 = SqlVirtualMachineManagementClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = SqlVirtualMachineManagementClientConfiguration(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.availability_group_listeners = AvailabilityGroupListenersOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.sql_virtual_machine_groups = SqlVirtualMachineGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.sql_virtual_machines = SqlVirtualMachinesOperations(self._client, self._config, self._serialize, self._deserialize) - self.availability_group_listeners = AvailabilityGroupListenersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.sql_virtual_machine_groups = SqlVirtualMachineGroupsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.sql_virtual_machines = SqlVirtualMachinesOperations( - 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 """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) def close(self): # type: () -> None diff --git a/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/_vendor.py b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/_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/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/aio/__init__.py b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/aio/__init__.py index 966ad89f9404..44ab4c13e048 100644 --- a/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/aio/__init__.py +++ b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/aio/__init__.py @@ -8,3 +8,8 @@ from ._sql_virtual_machine_management_client import SqlVirtualMachineManagementClient __all__ = ['SqlVirtualMachineManagementClient'] + +# `._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/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/aio/_configuration.py b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/aio/_configuration.py index 706a78ff51fe..8d3ddfcf2a34 100644 --- a/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/aio/_configuration.py +++ b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/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(SqlVirtualMachineManagementClientConfiguration, 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(SqlVirtualMachineManagementClientConfiguration, 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/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/aio/_patch.py b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/aio/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/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/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/aio/_sql_virtual_machine_management_client.py b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/aio/_sql_virtual_machine_management_client.py index dbec59145552..7e6837af3d8d 100644 --- a/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/aio/_sql_virtual_machine_management_client.py +++ b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/aio/_sql_virtual_machine_management_client.py @@ -6,85 +6,90 @@ # 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 SqlVirtualMachineManagementClientConfiguration +from .operations import AvailabilityGroupListenersOperations, Operations, SqlVirtualMachineGroupsOperations, SqlVirtualMachinesOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import SqlVirtualMachineManagementClientConfiguration -from .operations import AvailabilityGroupListenersOperations -from .operations import Operations -from .operations import SqlVirtualMachineGroupsOperations -from .operations import SqlVirtualMachinesOperations -from .. import models - - -class SqlVirtualMachineManagementClient(object): +class SqlVirtualMachineManagementClient: """The SQL virtual machine management API provides a RESTful set of web APIs that interact with Azure Compute, Network & Storage services to manage your SQL Server virtual machine. The API enables users to create, delete and retrieve a SQL virtual machine, SQL virtual machine group or availability group listener. :ivar availability_group_listeners: AvailabilityGroupListenersOperations operations - :vartype availability_group_listeners: azure.mgmt.sqlvirtualmachine.aio.operations.AvailabilityGroupListenersOperations + :vartype availability_group_listeners: + azure.mgmt.sqlvirtualmachine.aio.operations.AvailabilityGroupListenersOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.sqlvirtualmachine.aio.operations.Operations :ivar sql_virtual_machine_groups: SqlVirtualMachineGroupsOperations operations - :vartype sql_virtual_machine_groups: azure.mgmt.sqlvirtualmachine.aio.operations.SqlVirtualMachineGroupsOperations + :vartype sql_virtual_machine_groups: + azure.mgmt.sqlvirtualmachine.aio.operations.SqlVirtualMachineGroupsOperations :ivar sql_virtual_machines: SqlVirtualMachinesOperations operations - :vartype sql_virtual_machines: azure.mgmt.sqlvirtualmachine.aio.operations.SqlVirtualMachinesOperations + :vartype sql_virtual_machines: + azure.mgmt.sqlvirtualmachine.aio.operations.SqlVirtualMachinesOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: Subscription ID that identifies an Azure subscription. :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 = SqlVirtualMachineManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = SqlVirtualMachineManagementClientConfiguration(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.availability_group_listeners = AvailabilityGroupListenersOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.sql_virtual_machine_groups = SqlVirtualMachineGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.sql_virtual_machines = SqlVirtualMachinesOperations(self._client, self._config, self._serialize, self._deserialize) - self.availability_group_listeners = AvailabilityGroupListenersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.sql_virtual_machine_groups = SqlVirtualMachineGroupsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.sql_virtual_machines = SqlVirtualMachinesOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() diff --git a/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/aio/operations/_availability_group_listeners_operations.py b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/aio/operations/_availability_group_listeners_operations.py index 96143dcc113f..c28c15790a83 100644 --- a/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/aio/operations/_availability_group_listeners_operations.py +++ b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/aio/operations/_availability_group_listeners_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._availability_group_listeners_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_group_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -69,28 +75,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-03-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'sqlVirtualMachineGroupName': self._serialize.url("sql_virtual_machine_group_name", sql_virtual_machine_group_name, 'str'), - 'availabilityGroupListenerName': self._serialize.url("availability_group_listener_name", availability_group_listener_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + sql_virtual_machine_group_name=sql_virtual_machine_group_name, + availability_group_listener_name=availability_group_listener_name, + subscription_id=self._config.subscription_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 = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -104,8 +100,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/{sqlVirtualMachineGroupName}/availabilityGroupListeners/{availabilityGroupListenerName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -119,33 +117,23 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-03-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'sqlVirtualMachineGroupName': self._serialize.url("sql_virtual_machine_group_name", sql_virtual_machine_group_name, 'str'), - 'availabilityGroupListenerName': self._serialize.url("availability_group_listener_name", availability_group_listener_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + 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(parameters, 'AvailabilityGroupListener') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + sql_virtual_machine_group_name=sql_virtual_machine_group_name, + availability_group_listener_name=availability_group_listener_name, + subscription_id=self._config.subscription_id, + 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(parameters, 'AvailabilityGroupListener') - 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 @@ -163,8 +151,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/{sqlVirtualMachineGroupName}/availabilityGroupListeners/{availabilityGroupListenerName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -186,15 +177,20 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.sqlvirtualmachine.models.AvailabilityGroupListener :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either AvailabilityGroupListener or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sqlvirtualmachine.models.AvailabilityGroupListener] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AvailabilityGroupListener or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sqlvirtualmachine.models.AvailabilityGroupListener] + :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.AvailabilityGroupListener"] lro_delay = kwargs.pop( 'polling_interval', @@ -207,28 +203,21 @@ async def begin_create_or_update( sql_virtual_machine_group_name=sql_virtual_machine_group_name, availability_group_listener_name=availability_group_listener_name, parameters=parameters, + 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('AvailabilityGroupListener', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'sqlVirtualMachineGroupName': self._serialize.url("sql_virtual_machine_group_name", sql_virtual_machine_group_name, 'str'), - 'availabilityGroupListenerName': self._serialize.url("availability_group_listener_name", availability_group_listener_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -240,6 +229,7 @@ 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.SqlVirtualMachine/sqlVirtualMachineGroups/{sqlVirtualMachineGroupName}/availabilityGroupListeners/{availabilityGroupListenerName}'} # type: ignore async def _delete_initial( @@ -254,26 +244,18 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-03-01-preview" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'sqlVirtualMachineGroupName': self._serialize.url("sql_virtual_machine_group_name", sql_virtual_machine_group_name, 'str'), - 'availabilityGroupListenerName': self._serialize.url("availability_group_listener_name", availability_group_listener_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + sql_virtual_machine_group_name=sql_virtual_machine_group_name, + availability_group_listener_name=availability_group_listener_name, + subscription_id=self._config.subscription_id, + 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 @@ -286,6 +268,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/{sqlVirtualMachineGroupName}/availabilityGroupListeners/{availabilityGroupListenerName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -304,15 +288,17 @@ async def begin_delete( :type availability_group_listener_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - 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', @@ -327,22 +313,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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'sqlVirtualMachineGroupName': self._serialize.url("sql_virtual_machine_group_name", sql_virtual_machine_group_name, 'str'), - 'availabilityGroupListenerName': self._serialize.url("availability_group_listener_name", availability_group_listener_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -354,8 +332,10 @@ 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.SqlVirtualMachine/sqlVirtualMachineGroups/{sqlVirtualMachineGroupName}/availabilityGroupListeners/{availabilityGroupListenerName}'} # type: ignore + @distributed_trace def list_by_group( self, resource_group_name: str, @@ -370,8 +350,10 @@ def list_by_group( :param sql_virtual_machine_group_name: Name of the SQL virtual machine group. :type sql_virtual_machine_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 AvailabilityGroupListenerListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sqlvirtualmachine.models.AvailabilityGroupListenerListResult] + :return: An iterator like instance of either AvailabilityGroupListenerListResult or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sqlvirtualmachine.models.AvailabilityGroupListenerListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilityGroupListenerListResult"] @@ -379,36 +361,33 @@ def list_by_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-03-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_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'sqlVirtualMachineGroupName': self._serialize.url("sql_virtual_machine_group_name", sql_virtual_machine_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_group_request( + resource_group_name=resource_group_name, + sql_virtual_machine_group_name=sql_virtual_machine_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_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_group_request( + resource_group_name=resource_group_name, + sql_virtual_machine_group_name=sql_virtual_machine_group_name, + 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('AvailabilityGroupListenerListResult', pipeline_response) + deserialized = self._deserialize("AvailabilityGroupListenerListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -426,6 +405,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/aio/operations/_operations.py b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/aio/operations/_operations.py index a18990c79cd5..6ec29f3b1cc6 100644 --- a/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/aio/operations/_operations.py +++ b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/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,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -49,7 +55,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 OperationListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sqlvirtualmachine.models.OperationListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sqlvirtualmachine.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] @@ -57,30 +64,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-03-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('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -98,6 +102,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/aio/operations/_sql_virtual_machine_groups_operations.py b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/aio/operations/_sql_virtual_machine_groups_operations.py index 57a7dd718ece..9aa790a4103b 100644 --- a/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/aio/operations/_sql_virtual_machine_groups_operations.py +++ b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/aio/operations/_sql_virtual_machine_groups_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._sql_virtual_machine_groups_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_request, build_update_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -66,27 +72,17 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-03-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'sqlVirtualMachineGroupName': self._serialize.url("sql_virtual_machine_group_name", sql_virtual_machine_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + sql_virtual_machine_group_name=sql_virtual_machine_group_name, + subscription_id=self._config.subscription_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 = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -100,8 +96,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/{sqlVirtualMachineGroupName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -114,32 +112,22 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-03-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'sqlVirtualMachineGroupName': self._serialize.url("sql_virtual_machine_group_name", sql_virtual_machine_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SqlVirtualMachineGroup') - # 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( + resource_group_name=resource_group_name, + sql_virtual_machine_group_name=sql_virtual_machine_group_name, + subscription_id=self._config.subscription_id, + 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(parameters, 'SqlVirtualMachineGroup') - 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 @@ -157,8 +145,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/{sqlVirtualMachineGroupName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -177,15 +168,20 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.sqlvirtualmachine.models.SqlVirtualMachineGroup :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either SqlVirtualMachineGroup or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sqlvirtualmachine.models.SqlVirtualMachineGroup] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either SqlVirtualMachineGroup or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sqlvirtualmachine.models.SqlVirtualMachineGroup] + :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.SqlVirtualMachineGroup"] lro_delay = kwargs.pop( 'polling_interval', @@ -197,27 +193,21 @@ async def begin_create_or_update( resource_group_name=resource_group_name, sql_virtual_machine_group_name=sql_virtual_machine_group_name, parameters=parameters, + 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('SqlVirtualMachineGroup', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'sqlVirtualMachineGroupName': self._serialize.url("sql_virtual_machine_group_name", sql_virtual_machine_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -229,6 +219,7 @@ 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.SqlVirtualMachine/sqlVirtualMachineGroups/{sqlVirtualMachineGroupName}'} # type: ignore async def _delete_initial( @@ -242,25 +233,17 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-03-01-preview" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'sqlVirtualMachineGroupName': self._serialize.url("sql_virtual_machine_group_name", sql_virtual_machine_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + sql_virtual_machine_group_name=sql_virtual_machine_group_name, + subscription_id=self._config.subscription_id, + 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 @@ -273,6 +256,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/{sqlVirtualMachineGroupName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -288,15 +273,17 @@ async def begin_delete( :type sql_virtual_machine_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - 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', @@ -310,21 +297,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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'sqlVirtualMachineGroupName': self._serialize.url("sql_virtual_machine_group_name", sql_virtual_machine_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -336,6 +316,7 @@ 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.SqlVirtualMachine/sqlVirtualMachineGroups/{sqlVirtualMachineGroupName}'} # type: ignore async def _update_initial( @@ -350,32 +331,22 @@ async def _update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-03-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'sqlVirtualMachineGroupName': self._serialize.url("sql_virtual_machine_group_name", sql_virtual_machine_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SqlVirtualMachineGroupUpdate') - # 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_update_request_initial( + resource_group_name=resource_group_name, + sql_virtual_machine_group_name=sql_virtual_machine_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._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(parameters, 'SqlVirtualMachineGroupUpdate') - 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 @@ -389,8 +360,11 @@ async def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/{sqlVirtualMachineGroupName}'} # type: ignore + + @distributed_trace_async async def begin_update( self, resource_group_name: str, @@ -409,15 +383,20 @@ async def begin_update( :type parameters: ~azure.mgmt.sqlvirtualmachine.models.SqlVirtualMachineGroupUpdate :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either SqlVirtualMachineGroup or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sqlvirtualmachine.models.SqlVirtualMachineGroup] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either SqlVirtualMachineGroup or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sqlvirtualmachine.models.SqlVirtualMachineGroup] + :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.SqlVirtualMachineGroup"] lro_delay = kwargs.pop( 'polling_interval', @@ -429,27 +408,21 @@ async def begin_update( resource_group_name=resource_group_name, sql_virtual_machine_group_name=sql_virtual_machine_group_name, parameters=parameters, + 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('SqlVirtualMachineGroup', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'sqlVirtualMachineGroupName': self._serialize.url("sql_virtual_machine_group_name", sql_virtual_machine_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -461,8 +434,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/{sqlVirtualMachineGroupName}'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -474,8 +449,10 @@ def list_by_resource_group( obtain this value from the Azure Resource Manager API or the portal. :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 SqlVirtualMachineGroupListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sqlvirtualmachine.models.SqlVirtualMachineGroupListResult] + :return: An iterator like instance of either SqlVirtualMachineGroupListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sqlvirtualmachine.models.SqlVirtualMachineGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlVirtualMachineGroupListResult"] @@ -483,35 +460,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-03-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + 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('SqlVirtualMachineGroupListResult', pipeline_response) + deserialized = self._deserialize("SqlVirtualMachineGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -529,11 +502,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups'} # type: ignore + @distributed_trace def list( self, **kwargs: Any @@ -541,8 +516,10 @@ def list( """Gets all SQL virtual machine groups in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SqlVirtualMachineGroupListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sqlvirtualmachine.models.SqlVirtualMachineGroupListResult] + :return: An iterator like instance of either SqlVirtualMachineGroupListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sqlvirtualmachine.models.SqlVirtualMachineGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlVirtualMachineGroupListResult"] @@ -550,34 +527,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-03-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + 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('SqlVirtualMachineGroupListResult', pipeline_response) + deserialized = self._deserialize("SqlVirtualMachineGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -595,6 +567,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/aio/operations/_sql_virtual_machines_operations.py b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/aio/operations/_sql_virtual_machines_operations.py index fb49f353b1e9..5826f6cda12c 100644 --- a/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/aio/operations/_sql_virtual_machines_operations.py +++ b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/aio/operations/_sql_virtual_machines_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._sql_virtual_machines_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_by_sql_vm_group_request, build_list_request, build_update_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_sql_vm_group( self, resource_group_name: str, @@ -57,8 +63,10 @@ def list_by_sql_vm_group( :param sql_virtual_machine_group_name: Name of the SQL virtual machine group. :type sql_virtual_machine_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 SqlVirtualMachineListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sqlvirtualmachine.models.SqlVirtualMachineListResult] + :return: An iterator like instance of either SqlVirtualMachineListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sqlvirtualmachine.models.SqlVirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlVirtualMachineListResult"] @@ -66,36 +74,33 @@ def list_by_sql_vm_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-03-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_sql_vm_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'sqlVirtualMachineGroupName': self._serialize.url("sql_virtual_machine_group_name", sql_virtual_machine_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_sql_vm_group_request( + resource_group_name=resource_group_name, + sql_virtual_machine_group_name=sql_virtual_machine_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_sql_vm_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_sql_vm_group_request( + resource_group_name=resource_group_name, + sql_virtual_machine_group_name=sql_virtual_machine_group_name, + 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('SqlVirtualMachineListResult', pipeline_response) + deserialized = self._deserialize("SqlVirtualMachineListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -113,11 +118,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_sql_vm_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/{sqlVirtualMachineGroupName}/sqlVirtualMachines'} # type: ignore + @distributed_trace def list( self, **kwargs: Any @@ -125,8 +132,10 @@ def list( """Gets all SQL virtual machines in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SqlVirtualMachineListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sqlvirtualmachine.models.SqlVirtualMachineListResult] + :return: An iterator like instance of either SqlVirtualMachineListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sqlvirtualmachine.models.SqlVirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlVirtualMachineListResult"] @@ -134,34 +143,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-03-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + 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('SqlVirtualMachineListResult', pipeline_response) + deserialized = self._deserialize("SqlVirtualMachineListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -179,11 +183,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -210,29 +216,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-03-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'sqlVirtualMachineName': self._serialize.url("sql_virtual_machine_name", sql_virtual_machine_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - 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( + resource_group_name=resource_group_name, + sql_virtual_machine_name=sql_virtual_machine_name, + subscription_id=self._config.subscription_id, + expand=expand, + 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 @@ -246,8 +241,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines/{sqlVirtualMachineName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -260,32 +257,22 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-03-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'sqlVirtualMachineName': self._serialize.url("sql_virtual_machine_name", sql_virtual_machine_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + 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(parameters, 'SqlVirtualMachine') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + sql_virtual_machine_name=sql_virtual_machine_name, + subscription_id=self._config.subscription_id, + 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(parameters, 'SqlVirtualMachine') - 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 @@ -303,8 +290,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines/{sqlVirtualMachineName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -323,15 +313,20 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.sqlvirtualmachine.models.SqlVirtualMachine :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either SqlVirtualMachine or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sqlvirtualmachine.models.SqlVirtualMachine] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either SqlVirtualMachine or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sqlvirtualmachine.models.SqlVirtualMachine] + :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.SqlVirtualMachine"] lro_delay = kwargs.pop( 'polling_interval', @@ -343,27 +338,21 @@ async def begin_create_or_update( resource_group_name=resource_group_name, sql_virtual_machine_name=sql_virtual_machine_name, parameters=parameters, + 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('SqlVirtualMachine', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'sqlVirtualMachineName': self._serialize.url("sql_virtual_machine_name", sql_virtual_machine_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -375,6 +364,7 @@ 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.SqlVirtualMachine/sqlVirtualMachines/{sqlVirtualMachineName}'} # type: ignore async def _delete_initial( @@ -388,25 +378,17 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-03-01-preview" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'sqlVirtualMachineName': self._serialize.url("sql_virtual_machine_name", sql_virtual_machine_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + sql_virtual_machine_name=sql_virtual_machine_name, + subscription_id=self._config.subscription_id, + 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 @@ -419,6 +401,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines/{sqlVirtualMachineName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -434,15 +418,17 @@ async def begin_delete( :type sql_virtual_machine_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - 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', @@ -456,21 +442,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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'sqlVirtualMachineName': self._serialize.url("sql_virtual_machine_name", sql_virtual_machine_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -482,6 +461,7 @@ 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.SqlVirtualMachine/sqlVirtualMachines/{sqlVirtualMachineName}'} # type: ignore async def _update_initial( @@ -496,32 +476,22 @@ async def _update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-03-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'sqlVirtualMachineName': self._serialize.url("sql_virtual_machine_name", sql_virtual_machine_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SqlVirtualMachineUpdate') - # 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_update_request_initial( + resource_group_name=resource_group_name, + sql_virtual_machine_name=sql_virtual_machine_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._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(parameters, 'SqlVirtualMachineUpdate') - 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 @@ -535,8 +505,11 @@ async def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines/{sqlVirtualMachineName}'} # type: ignore + + @distributed_trace_async async def begin_update( self, resource_group_name: str, @@ -555,15 +528,20 @@ async def begin_update( :type parameters: ~azure.mgmt.sqlvirtualmachine.models.SqlVirtualMachineUpdate :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either SqlVirtualMachine or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sqlvirtualmachine.models.SqlVirtualMachine] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either SqlVirtualMachine or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sqlvirtualmachine.models.SqlVirtualMachine] + :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.SqlVirtualMachine"] lro_delay = kwargs.pop( 'polling_interval', @@ -575,27 +553,21 @@ async def begin_update( resource_group_name=resource_group_name, sql_virtual_machine_name=sql_virtual_machine_name, parameters=parameters, + 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('SqlVirtualMachine', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'sqlVirtualMachineName': self._serialize.url("sql_virtual_machine_name", sql_virtual_machine_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -607,8 +579,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines/{sqlVirtualMachineName}'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -620,8 +594,10 @@ def list_by_resource_group( obtain this value from the Azure Resource Manager API or the portal. :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 SqlVirtualMachineListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sqlvirtualmachine.models.SqlVirtualMachineListResult] + :return: An iterator like instance of either SqlVirtualMachineListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sqlvirtualmachine.models.SqlVirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlVirtualMachineListResult"] @@ -629,35 +605,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-03-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + 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('SqlVirtualMachineListResult', pipeline_response) + deserialized = self._deserialize("SqlVirtualMachineListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -675,6 +647,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/models/__init__.py b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/models/__init__.py index 782a8b58942e..241143760543 100644 --- a/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/models/__init__.py +++ b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/models/__init__.py @@ -6,66 +6,36 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import AdditionalFeaturesServerConfigurations - from ._models_py3 import AutoBackupSettings - from ._models_py3 import AutoPatchingSettings - from ._models_py3 import AvailabilityGroupListener - from ._models_py3 import AvailabilityGroupListenerListResult - from ._models_py3 import KeyVaultCredentialSettings - from ._models_py3 import LoadBalancerConfiguration - from ._models_py3 import Operation - from ._models_py3 import OperationDisplay - from ._models_py3 import OperationListResult - from ._models_py3 import PrivateIPAddress - from ._models_py3 import ProxyResource - from ._models_py3 import Resource - from ._models_py3 import ResourceIdentity - from ._models_py3 import SQLStorageSettings - from ._models_py3 import ServerConfigurationsManagementSettings - from ._models_py3 import SqlConnectivityUpdateSettings - from ._models_py3 import SqlStorageUpdateSettings - from ._models_py3 import SqlVirtualMachine - from ._models_py3 import SqlVirtualMachineGroup - from ._models_py3 import SqlVirtualMachineGroupListResult - from ._models_py3 import SqlVirtualMachineGroupUpdate - from ._models_py3 import SqlVirtualMachineListResult - from ._models_py3 import SqlVirtualMachineUpdate - from ._models_py3 import SqlWorkloadTypeUpdateSettings - from ._models_py3 import StorageConfigurationSettings - from ._models_py3 import TrackedResource - from ._models_py3 import WsfcDomainCredentials - from ._models_py3 import WsfcDomainProfile -except (SyntaxError, ImportError): - from ._models import AdditionalFeaturesServerConfigurations # type: ignore - from ._models import AutoBackupSettings # type: ignore - from ._models import AutoPatchingSettings # type: ignore - from ._models import AvailabilityGroupListener # type: ignore - from ._models import AvailabilityGroupListenerListResult # type: ignore - from ._models import KeyVaultCredentialSettings # type: ignore - from ._models import LoadBalancerConfiguration # type: ignore - from ._models import Operation # type: ignore - from ._models import OperationDisplay # type: ignore - from ._models import OperationListResult # type: ignore - from ._models import PrivateIPAddress # type: ignore - from ._models import ProxyResource # type: ignore - from ._models import Resource # type: ignore - from ._models import ResourceIdentity # type: ignore - from ._models import SQLStorageSettings # type: ignore - from ._models import ServerConfigurationsManagementSettings # type: ignore - from ._models import SqlConnectivityUpdateSettings # type: ignore - from ._models import SqlStorageUpdateSettings # type: ignore - from ._models import SqlVirtualMachine # type: ignore - from ._models import SqlVirtualMachineGroup # type: ignore - from ._models import SqlVirtualMachineGroupListResult # type: ignore - from ._models import SqlVirtualMachineGroupUpdate # type: ignore - from ._models import SqlVirtualMachineListResult # type: ignore - from ._models import SqlVirtualMachineUpdate # type: ignore - from ._models import SqlWorkloadTypeUpdateSettings # type: ignore - from ._models import StorageConfigurationSettings # type: ignore - from ._models import TrackedResource # type: ignore - from ._models import WsfcDomainCredentials # type: ignore - from ._models import WsfcDomainProfile # type: ignore +from ._models_py3 import AdditionalFeaturesServerConfigurations +from ._models_py3 import AutoBackupSettings +from ._models_py3 import AutoPatchingSettings +from ._models_py3 import AvailabilityGroupListener +from ._models_py3 import AvailabilityGroupListenerListResult +from ._models_py3 import KeyVaultCredentialSettings +from ._models_py3 import LoadBalancerConfiguration +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationListResult +from ._models_py3 import PrivateIPAddress +from ._models_py3 import ProxyResource +from ._models_py3 import Resource +from ._models_py3 import ResourceIdentity +from ._models_py3 import SQLStorageSettings +from ._models_py3 import ServerConfigurationsManagementSettings +from ._models_py3 import SqlConnectivityUpdateSettings +from ._models_py3 import SqlStorageUpdateSettings +from ._models_py3 import SqlVirtualMachine +from ._models_py3 import SqlVirtualMachineGroup +from ._models_py3 import SqlVirtualMachineGroupListResult +from ._models_py3 import SqlVirtualMachineGroupUpdate +from ._models_py3 import SqlVirtualMachineListResult +from ._models_py3 import SqlVirtualMachineUpdate +from ._models_py3 import SqlWorkloadTypeUpdateSettings +from ._models_py3 import StorageConfigurationSettings +from ._models_py3 import TrackedResource +from ._models_py3 import WsfcDomainCredentials +from ._models_py3 import WsfcDomainProfile + from ._sql_virtual_machine_management_client_enums import ( BackupScheduleType, diff --git a/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/models/_models.py b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/models/_models.py deleted file mode 100644 index 37bde921ea99..000000000000 --- a/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/models/_models.py +++ /dev/null @@ -1,1102 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -import msrest.serialization - - -class AdditionalFeaturesServerConfigurations(msrest.serialization.Model): - """Additional SQL Server feature settings. - - :param is_r_services_enabled: Enable or disable R services (SQL 2016 onwards). - :type is_r_services_enabled: bool - """ - - _attribute_map = { - 'is_r_services_enabled': {'key': 'isRServicesEnabled', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(AdditionalFeaturesServerConfigurations, self).__init__(**kwargs) - self.is_r_services_enabled = kwargs.get('is_r_services_enabled', None) - - -class AutoBackupSettings(msrest.serialization.Model): - """Configure backups for databases in your SQL virtual machine. - - :param enable: Enable or disable autobackup on SQL virtual machine. - :type enable: bool - :param enable_encryption: Enable or disable encryption for backup on SQL virtual machine. - :type enable_encryption: bool - :param retention_period: Retention period of backup: 1-30 days. - :type retention_period: int - :param storage_account_url: Storage account url where backup will be taken to. - :type storage_account_url: str - :param storage_access_key: Storage account key where backup will be taken to. - :type storage_access_key: str - :param password: Password for encryption on backup. - :type password: str - :param backup_system_dbs: Include or exclude system databases from auto backup. - :type backup_system_dbs: bool - :param backup_schedule_type: Backup schedule type. Possible values include: "Manual", - "Automated". - :type backup_schedule_type: str or ~azure.mgmt.sqlvirtualmachine.models.BackupScheduleType - :param full_backup_frequency: Frequency of full backups. In both cases, full backups begin - during the next scheduled time window. Possible values include: "Daily", "Weekly". - :type full_backup_frequency: str or - ~azure.mgmt.sqlvirtualmachine.models.FullBackupFrequencyType - :param full_backup_start_time: Start time of a given day during which full backups can take - place. 0-23 hours. - :type full_backup_start_time: int - :param full_backup_window_hours: Duration of the time window of a given day during which full - backups can take place. 1-23 hours. - :type full_backup_window_hours: int - :param log_backup_frequency: Frequency of log backups. 5-60 minutes. - :type log_backup_frequency: int - """ - - _attribute_map = { - 'enable': {'key': 'enable', 'type': 'bool'}, - 'enable_encryption': {'key': 'enableEncryption', 'type': 'bool'}, - 'retention_period': {'key': 'retentionPeriod', 'type': 'int'}, - 'storage_account_url': {'key': 'storageAccountUrl', 'type': 'str'}, - 'storage_access_key': {'key': 'storageAccessKey', 'type': 'str'}, - 'password': {'key': 'password', 'type': 'str'}, - 'backup_system_dbs': {'key': 'backupSystemDbs', 'type': 'bool'}, - 'backup_schedule_type': {'key': 'backupScheduleType', 'type': 'str'}, - 'full_backup_frequency': {'key': 'fullBackupFrequency', 'type': 'str'}, - 'full_backup_start_time': {'key': 'fullBackupStartTime', 'type': 'int'}, - 'full_backup_window_hours': {'key': 'fullBackupWindowHours', 'type': 'int'}, - 'log_backup_frequency': {'key': 'logBackupFrequency', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(AutoBackupSettings, self).__init__(**kwargs) - self.enable = kwargs.get('enable', None) - self.enable_encryption = kwargs.get('enable_encryption', None) - self.retention_period = kwargs.get('retention_period', None) - self.storage_account_url = kwargs.get('storage_account_url', None) - self.storage_access_key = kwargs.get('storage_access_key', None) - self.password = kwargs.get('password', None) - self.backup_system_dbs = kwargs.get('backup_system_dbs', None) - self.backup_schedule_type = kwargs.get('backup_schedule_type', None) - self.full_backup_frequency = kwargs.get('full_backup_frequency', None) - self.full_backup_start_time = kwargs.get('full_backup_start_time', None) - self.full_backup_window_hours = kwargs.get('full_backup_window_hours', None) - self.log_backup_frequency = kwargs.get('log_backup_frequency', None) - - -class AutoPatchingSettings(msrest.serialization.Model): - """Set a patching window during which Windows and SQL patches will be applied. - - :param enable: Enable or disable autopatching on SQL virtual machine. - :type enable: bool - :param day_of_week: Day of week to apply the patch on. Possible values include: "Monday", - "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday". - :type day_of_week: str or ~azure.mgmt.sqlvirtualmachine.models.DayOfWeek - :param maintenance_window_starting_hour: Hour of the day when patching is initiated. Local VM - time. - :type maintenance_window_starting_hour: int - :param maintenance_window_duration: Duration of patching. - :type maintenance_window_duration: int - """ - - _attribute_map = { - 'enable': {'key': 'enable', 'type': 'bool'}, - 'day_of_week': {'key': 'dayOfWeek', 'type': 'str'}, - 'maintenance_window_starting_hour': {'key': 'maintenanceWindowStartingHour', 'type': 'int'}, - 'maintenance_window_duration': {'key': 'maintenanceWindowDuration', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(AutoPatchingSettings, self).__init__(**kwargs) - self.enable = kwargs.get('enable', None) - self.day_of_week = kwargs.get('day_of_week', None) - self.maintenance_window_starting_hour = kwargs.get('maintenance_window_starting_hour', None) - self.maintenance_window_duration = kwargs.get('maintenance_window_duration', None) - - -class Resource(msrest.serialization.Model): - """ARM resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Resource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class ProxyResource(Resource): - """ARM proxy resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ProxyResource, self).__init__(**kwargs) - - -class AvailabilityGroupListener(ProxyResource): - """A SQL Server availability group listener. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar provisioning_state: Provisioning state to track the async operation status. - :vartype provisioning_state: str - :param availability_group_name: Name of the availability group. - :type availability_group_name: str - :param load_balancer_configurations: List of load balancer configurations for an availability - group listener. - :type load_balancer_configurations: - list[~azure.mgmt.sqlvirtualmachine.models.LoadBalancerConfiguration] - :param create_default_availability_group_if_not_exist: Create a default availability group if - it does not exist. - :type create_default_availability_group_if_not_exist: bool - :param port: Listener port. - :type port: int - """ - - _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'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'availability_group_name': {'key': 'properties.availabilityGroupName', 'type': 'str'}, - 'load_balancer_configurations': {'key': 'properties.loadBalancerConfigurations', 'type': '[LoadBalancerConfiguration]'}, - 'create_default_availability_group_if_not_exist': {'key': 'properties.createDefaultAvailabilityGroupIfNotExist', 'type': 'bool'}, - 'port': {'key': 'properties.port', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(AvailabilityGroupListener, self).__init__(**kwargs) - self.provisioning_state = None - self.availability_group_name = kwargs.get('availability_group_name', None) - self.load_balancer_configurations = kwargs.get('load_balancer_configurations', None) - self.create_default_availability_group_if_not_exist = kwargs.get('create_default_availability_group_if_not_exist', None) - self.port = kwargs.get('port', None) - - -class AvailabilityGroupListenerListResult(msrest.serialization.Model): - """A list of availability group listeners. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sqlvirtualmachine.models.AvailabilityGroupListener] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[AvailabilityGroupListener]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AvailabilityGroupListenerListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class KeyVaultCredentialSettings(msrest.serialization.Model): - """Configure your SQL virtual machine to be able to connect to the Azure Key Vault service. - - :param enable: Enable or disable key vault credential setting. - :type enable: bool - :param credential_name: Credential name. - :type credential_name: str - :param azure_key_vault_url: Azure Key Vault url. - :type azure_key_vault_url: str - :param service_principal_name: Service principal name to access key vault. - :type service_principal_name: str - :param service_principal_secret: Service principal name secret to access key vault. - :type service_principal_secret: str - """ - - _attribute_map = { - 'enable': {'key': 'enable', 'type': 'bool'}, - 'credential_name': {'key': 'credentialName', 'type': 'str'}, - 'azure_key_vault_url': {'key': 'azureKeyVaultUrl', 'type': 'str'}, - 'service_principal_name': {'key': 'servicePrincipalName', 'type': 'str'}, - 'service_principal_secret': {'key': 'servicePrincipalSecret', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(KeyVaultCredentialSettings, self).__init__(**kwargs) - self.enable = kwargs.get('enable', None) - self.credential_name = kwargs.get('credential_name', None) - self.azure_key_vault_url = kwargs.get('azure_key_vault_url', None) - self.service_principal_name = kwargs.get('service_principal_name', None) - self.service_principal_secret = kwargs.get('service_principal_secret', None) - - -class LoadBalancerConfiguration(msrest.serialization.Model): - """A load balancer configuration for an availability group listener. - - :param private_ip_address: Private IP address. - :type private_ip_address: ~azure.mgmt.sqlvirtualmachine.models.PrivateIPAddress - :param public_ip_address_resource_id: Resource id of the public IP. - :type public_ip_address_resource_id: str - :param load_balancer_resource_id: Resource id of the load balancer. - :type load_balancer_resource_id: str - :param probe_port: Probe port. - :type probe_port: int - :param sql_virtual_machine_instances: List of the SQL virtual machine instance resource id's - that are enrolled into the availability group listener. - :type sql_virtual_machine_instances: list[str] - """ - - _attribute_map = { - 'private_ip_address': {'key': 'privateIpAddress', 'type': 'PrivateIPAddress'}, - 'public_ip_address_resource_id': {'key': 'publicIpAddressResourceId', 'type': 'str'}, - 'load_balancer_resource_id': {'key': 'loadBalancerResourceId', 'type': 'str'}, - 'probe_port': {'key': 'probePort', 'type': 'int'}, - 'sql_virtual_machine_instances': {'key': 'sqlVirtualMachineInstances', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(LoadBalancerConfiguration, self).__init__(**kwargs) - self.private_ip_address = kwargs.get('private_ip_address', None) - self.public_ip_address_resource_id = kwargs.get('public_ip_address_resource_id', None) - self.load_balancer_resource_id = kwargs.get('load_balancer_resource_id', None) - self.probe_port = kwargs.get('probe_port', None) - self.sql_virtual_machine_instances = kwargs.get('sql_virtual_machine_instances', None) - - -class Operation(msrest.serialization.Model): - """SQL REST API operation definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The name of the operation being performed on this particular object. - :vartype name: str - :ivar display: The localized display information for this particular operation / action. - :vartype display: ~azure.mgmt.sqlvirtualmachine.models.OperationDisplay - :ivar origin: The intended executor of the operation. Possible values include: "user", - "system". - :vartype origin: str or ~azure.mgmt.sqlvirtualmachine.models.OperationOrigin - :ivar properties: Additional descriptions for the operation. - :vartype properties: dict[str, any] - """ - - _validation = { - 'name': {'readonly': True}, - 'display': {'readonly': True}, - 'origin': {'readonly': True}, - 'properties': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - 'origin': {'key': 'origin', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': '{object}'}, - } - - def __init__( - self, - **kwargs - ): - super(Operation, self).__init__(**kwargs) - self.name = None - self.display = None - self.origin = None - self.properties = None - - -class OperationDisplay(msrest.serialization.Model): - """Display metadata associated with the operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provider: The localized friendly form of the resource provider name. - :vartype provider: str - :ivar resource: The localized friendly form of the resource type related to this - action/operation. - :vartype resource: str - :ivar operation: The localized friendly name for the operation. - :vartype operation: str - :ivar description: The localized friendly description for the operation. - :vartype description: str - """ - - _validation = { - 'provider': {'readonly': True}, - 'resource': {'readonly': True}, - 'operation': {'readonly': True}, - 'description': {'readonly': True}, - } - - _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationDisplay, self).__init__(**kwargs) - self.provider = None - self.resource = None - self.operation = None - self.description = None - - -class OperationListResult(msrest.serialization.Model): - """Result of the request to list SQL operations. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sqlvirtualmachine.models.Operation] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class PrivateIPAddress(msrest.serialization.Model): - """A private IP address bound to the availability group listener. - - :param ip_address: Private IP address bound to the availability group listener. - :type ip_address: str - :param subnet_resource_id: Subnet used to include private IP. - :type subnet_resource_id: str - """ - - _attribute_map = { - 'ip_address': {'key': 'ipAddress', 'type': 'str'}, - 'subnet_resource_id': {'key': 'subnetResourceId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateIPAddress, self).__init__(**kwargs) - self.ip_address = kwargs.get('ip_address', None) - self.subnet_resource_id = kwargs.get('subnet_resource_id', None) - - -class ResourceIdentity(msrest.serialization.Model): - """Azure Active Directory identity configuration for a resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar principal_id: The Azure Active Directory principal id. - :vartype principal_id: str - :param type: The identity type. Set this to 'SystemAssigned' in order to automatically create - and assign an Azure Active Directory principal for the resource. Possible values include: - "SystemAssigned". - :type type: str or ~azure.mgmt.sqlvirtualmachine.models.IdentityType - :ivar tenant_id: The Azure Active Directory tenant id. - :vartype tenant_id: str - """ - - _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, - } - - _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceIdentity, self).__init__(**kwargs) - self.principal_id = None - self.type = kwargs.get('type', None) - self.tenant_id = None - - -class ServerConfigurationsManagementSettings(msrest.serialization.Model): - """Set the connectivity, storage and workload settings. - - :param sql_connectivity_update_settings: SQL connectivity type settings. - :type sql_connectivity_update_settings: - ~azure.mgmt.sqlvirtualmachine.models.SqlConnectivityUpdateSettings - :param sql_workload_type_update_settings: SQL workload type settings. - :type sql_workload_type_update_settings: - ~azure.mgmt.sqlvirtualmachine.models.SqlWorkloadTypeUpdateSettings - :param sql_storage_update_settings: SQL storage update settings. - :type sql_storage_update_settings: - ~azure.mgmt.sqlvirtualmachine.models.SqlStorageUpdateSettings - :param additional_features_server_configurations: Additional SQL feature settings. - :type additional_features_server_configurations: - ~azure.mgmt.sqlvirtualmachine.models.AdditionalFeaturesServerConfigurations - """ - - _attribute_map = { - 'sql_connectivity_update_settings': {'key': 'sqlConnectivityUpdateSettings', 'type': 'SqlConnectivityUpdateSettings'}, - 'sql_workload_type_update_settings': {'key': 'sqlWorkloadTypeUpdateSettings', 'type': 'SqlWorkloadTypeUpdateSettings'}, - 'sql_storage_update_settings': {'key': 'sqlStorageUpdateSettings', 'type': 'SqlStorageUpdateSettings'}, - 'additional_features_server_configurations': {'key': 'additionalFeaturesServerConfigurations', 'type': 'AdditionalFeaturesServerConfigurations'}, - } - - def __init__( - self, - **kwargs - ): - super(ServerConfigurationsManagementSettings, self).__init__(**kwargs) - self.sql_connectivity_update_settings = kwargs.get('sql_connectivity_update_settings', None) - self.sql_workload_type_update_settings = kwargs.get('sql_workload_type_update_settings', None) - self.sql_storage_update_settings = kwargs.get('sql_storage_update_settings', None) - self.additional_features_server_configurations = kwargs.get('additional_features_server_configurations', None) - - -class SqlConnectivityUpdateSettings(msrest.serialization.Model): - """Set the access level and network port settings for SQL Server. - - :param connectivity_type: SQL Server connectivity option. Possible values include: "LOCAL", - "PRIVATE", "PUBLIC". - :type connectivity_type: str or ~azure.mgmt.sqlvirtualmachine.models.ConnectivityType - :param port: SQL Server port. - :type port: int - :param sql_auth_update_user_name: SQL Server sysadmin login to create. - :type sql_auth_update_user_name: str - :param sql_auth_update_password: SQL Server sysadmin login password. - :type sql_auth_update_password: str - """ - - _attribute_map = { - 'connectivity_type': {'key': 'connectivityType', 'type': 'str'}, - 'port': {'key': 'port', 'type': 'int'}, - 'sql_auth_update_user_name': {'key': 'sqlAuthUpdateUserName', 'type': 'str'}, - 'sql_auth_update_password': {'key': 'sqlAuthUpdatePassword', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SqlConnectivityUpdateSettings, self).__init__(**kwargs) - self.connectivity_type = kwargs.get('connectivity_type', None) - self.port = kwargs.get('port', None) - self.sql_auth_update_user_name = kwargs.get('sql_auth_update_user_name', None) - self.sql_auth_update_password = kwargs.get('sql_auth_update_password', None) - - -class SQLStorageSettings(msrest.serialization.Model): - """Set disk storage settings for SQL Server. - - :param luns: Logical Unit Numbers for the disks. - :type luns: list[int] - :param default_file_path: SQL Server default file path. - :type default_file_path: str - """ - - _attribute_map = { - 'luns': {'key': 'luns', 'type': '[int]'}, - 'default_file_path': {'key': 'defaultFilePath', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SQLStorageSettings, self).__init__(**kwargs) - self.luns = kwargs.get('luns', None) - self.default_file_path = kwargs.get('default_file_path', None) - - -class SqlStorageUpdateSettings(msrest.serialization.Model): - """Set disk storage settings for SQL Server. - - :param disk_count: Virtual machine disk count. - :type disk_count: int - :param starting_device_id: Device id of the first disk to be updated. - :type starting_device_id: int - :param disk_configuration_type: Disk configuration to apply to SQL Server. Possible values - include: "NEW", "EXTEND", "ADD". - :type disk_configuration_type: str or - ~azure.mgmt.sqlvirtualmachine.models.DiskConfigurationType - """ - - _attribute_map = { - 'disk_count': {'key': 'diskCount', 'type': 'int'}, - 'starting_device_id': {'key': 'startingDeviceId', 'type': 'int'}, - 'disk_configuration_type': {'key': 'diskConfigurationType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SqlStorageUpdateSettings, self).__init__(**kwargs) - self.disk_count = kwargs.get('disk_count', None) - self.starting_device_id = kwargs.get('starting_device_id', None) - self.disk_configuration_type = kwargs.get('disk_configuration_type', None) - - -class TrackedResource(Resource): - """ARM tracked top level resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(TrackedResource, self).__init__(**kwargs) - self.location = kwargs['location'] - self.tags = kwargs.get('tags', None) - - -class SqlVirtualMachine(TrackedResource): - """A SQL virtual machine. - - 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 identity: Azure Active Directory identity of the server. - :type identity: ~azure.mgmt.sqlvirtualmachine.models.ResourceIdentity - :param virtual_machine_resource_id: ARM Resource id of underlying virtual machine created from - SQL marketplace image. - :type virtual_machine_resource_id: str - :ivar provisioning_state: Provisioning state to track the async operation status. - :vartype provisioning_state: str - :param sql_image_offer: SQL image offer. Examples include SQL2016-WS2016, SQL2017-WS2016. - :type sql_image_offer: str - :param sql_server_license_type: SQL Server license type. Possible values include: "PAYG", - "AHUB", "DR". - :type sql_server_license_type: str or ~azure.mgmt.sqlvirtualmachine.models.SqlServerLicenseType - :param sql_management: SQL Server Management type. Possible values include: "Full", - "LightWeight", "NoAgent". - :type sql_management: str or ~azure.mgmt.sqlvirtualmachine.models.SqlManagementMode - :param sql_image_sku: SQL Server edition type. Possible values include: "Developer", "Express", - "Standard", "Enterprise", "Web". - :type sql_image_sku: str or ~azure.mgmt.sqlvirtualmachine.models.SqlImageSku - :param sql_virtual_machine_group_resource_id: ARM resource id of the SQL virtual machine group - this SQL virtual machine is or will be part of. - :type sql_virtual_machine_group_resource_id: str - :param wsfc_domain_credentials: Domain credentials for setting up Windows Server Failover - Cluster for SQL availability group. - :type wsfc_domain_credentials: ~azure.mgmt.sqlvirtualmachine.models.WsfcDomainCredentials - :param auto_patching_settings: Auto patching settings for applying critical security updates to - SQL virtual machine. - :type auto_patching_settings: ~azure.mgmt.sqlvirtualmachine.models.AutoPatchingSettings - :param auto_backup_settings: Auto backup settings for SQL Server. - :type auto_backup_settings: ~azure.mgmt.sqlvirtualmachine.models.AutoBackupSettings - :param key_vault_credential_settings: Key vault credential settings. - :type key_vault_credential_settings: - ~azure.mgmt.sqlvirtualmachine.models.KeyVaultCredentialSettings - :param server_configurations_management_settings: SQL Server configuration management settings. - :type server_configurations_management_settings: - ~azure.mgmt.sqlvirtualmachine.models.ServerConfigurationsManagementSettings - :param storage_configuration_settings: Storage Configuration Settings. - :type storage_configuration_settings: - ~azure.mgmt.sqlvirtualmachine.models.StorageConfigurationSettings - """ - - _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}'}, - 'identity': {'key': 'identity', 'type': 'ResourceIdentity'}, - 'virtual_machine_resource_id': {'key': 'properties.virtualMachineResourceId', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'sql_image_offer': {'key': 'properties.sqlImageOffer', 'type': 'str'}, - 'sql_server_license_type': {'key': 'properties.sqlServerLicenseType', 'type': 'str'}, - 'sql_management': {'key': 'properties.sqlManagement', 'type': 'str'}, - 'sql_image_sku': {'key': 'properties.sqlImageSku', 'type': 'str'}, - 'sql_virtual_machine_group_resource_id': {'key': 'properties.sqlVirtualMachineGroupResourceId', 'type': 'str'}, - 'wsfc_domain_credentials': {'key': 'properties.wsfcDomainCredentials', 'type': 'WsfcDomainCredentials'}, - 'auto_patching_settings': {'key': 'properties.autoPatchingSettings', 'type': 'AutoPatchingSettings'}, - 'auto_backup_settings': {'key': 'properties.autoBackupSettings', 'type': 'AutoBackupSettings'}, - 'key_vault_credential_settings': {'key': 'properties.keyVaultCredentialSettings', 'type': 'KeyVaultCredentialSettings'}, - 'server_configurations_management_settings': {'key': 'properties.serverConfigurationsManagementSettings', 'type': 'ServerConfigurationsManagementSettings'}, - 'storage_configuration_settings': {'key': 'properties.storageConfigurationSettings', 'type': 'StorageConfigurationSettings'}, - } - - def __init__( - self, - **kwargs - ): - super(SqlVirtualMachine, self).__init__(**kwargs) - self.identity = kwargs.get('identity', None) - self.virtual_machine_resource_id = kwargs.get('virtual_machine_resource_id', None) - self.provisioning_state = None - self.sql_image_offer = kwargs.get('sql_image_offer', None) - self.sql_server_license_type = kwargs.get('sql_server_license_type', None) - self.sql_management = kwargs.get('sql_management', None) - self.sql_image_sku = kwargs.get('sql_image_sku', None) - self.sql_virtual_machine_group_resource_id = kwargs.get('sql_virtual_machine_group_resource_id', None) - self.wsfc_domain_credentials = kwargs.get('wsfc_domain_credentials', None) - self.auto_patching_settings = kwargs.get('auto_patching_settings', None) - self.auto_backup_settings = kwargs.get('auto_backup_settings', None) - self.key_vault_credential_settings = kwargs.get('key_vault_credential_settings', None) - self.server_configurations_management_settings = kwargs.get('server_configurations_management_settings', None) - self.storage_configuration_settings = kwargs.get('storage_configuration_settings', None) - - -class SqlVirtualMachineGroup(TrackedResource): - """A SQL virtual machine group. - - 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] - :ivar provisioning_state: Provisioning state to track the async operation status. - :vartype provisioning_state: str - :param sql_image_offer: SQL image offer. Examples may include SQL2016-WS2016, SQL2017-WS2016. - :type sql_image_offer: str - :param sql_image_sku: SQL image sku. Possible values include: "Developer", "Enterprise". - :type sql_image_sku: str or ~azure.mgmt.sqlvirtualmachine.models.SqlVmGroupImageSku - :ivar scale_type: Scale type. Possible values include: "HA". - :vartype scale_type: str or ~azure.mgmt.sqlvirtualmachine.models.ScaleType - :ivar cluster_manager_type: Type of cluster manager: Windows Server Failover Cluster (WSFC), - implied by the scale type of the group and the OS type. Possible values include: "WSFC". - :vartype cluster_manager_type: str or ~azure.mgmt.sqlvirtualmachine.models.ClusterManagerType - :ivar cluster_configuration: Cluster type. Possible values include: "Domainful". - :vartype cluster_configuration: str or - ~azure.mgmt.sqlvirtualmachine.models.ClusterConfiguration - :param wsfc_domain_profile: Cluster Active Directory domain profile. - :type wsfc_domain_profile: ~azure.mgmt.sqlvirtualmachine.models.WsfcDomainProfile - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'provisioning_state': {'readonly': True}, - 'scale_type': {'readonly': True}, - 'cluster_manager_type': {'readonly': True}, - 'cluster_configuration': {'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}'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'sql_image_offer': {'key': 'properties.sqlImageOffer', 'type': 'str'}, - 'sql_image_sku': {'key': 'properties.sqlImageSku', 'type': 'str'}, - 'scale_type': {'key': 'properties.scaleType', 'type': 'str'}, - 'cluster_manager_type': {'key': 'properties.clusterManagerType', 'type': 'str'}, - 'cluster_configuration': {'key': 'properties.clusterConfiguration', 'type': 'str'}, - 'wsfc_domain_profile': {'key': 'properties.wsfcDomainProfile', 'type': 'WsfcDomainProfile'}, - } - - def __init__( - self, - **kwargs - ): - super(SqlVirtualMachineGroup, self).__init__(**kwargs) - self.provisioning_state = None - self.sql_image_offer = kwargs.get('sql_image_offer', None) - self.sql_image_sku = kwargs.get('sql_image_sku', None) - self.scale_type = None - self.cluster_manager_type = None - self.cluster_configuration = None - self.wsfc_domain_profile = kwargs.get('wsfc_domain_profile', None) - - -class SqlVirtualMachineGroupListResult(msrest.serialization.Model): - """A list of SQL virtual machine groups. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sqlvirtualmachine.models.SqlVirtualMachineGroup] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[SqlVirtualMachineGroup]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SqlVirtualMachineGroupListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class SqlVirtualMachineGroupUpdate(msrest.serialization.Model): - """An update to a SQL virtual machine group. - - :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(SqlVirtualMachineGroupUpdate, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - - -class SqlVirtualMachineListResult(msrest.serialization.Model): - """A list of SQL virtual machines. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sqlvirtualmachine.models.SqlVirtualMachine] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[SqlVirtualMachine]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SqlVirtualMachineListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class SqlVirtualMachineUpdate(msrest.serialization.Model): - """An update to a SQL virtual machine. - - :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(SqlVirtualMachineUpdate, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - - -class SqlWorkloadTypeUpdateSettings(msrest.serialization.Model): - """Set workload type to optimize storage for SQL Server. - - :param sql_workload_type: SQL Server workload type. Possible values include: "GENERAL", "OLTP", - "DW". - :type sql_workload_type: str or ~azure.mgmt.sqlvirtualmachine.models.SqlWorkloadType - """ - - _attribute_map = { - 'sql_workload_type': {'key': 'sqlWorkloadType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SqlWorkloadTypeUpdateSettings, self).__init__(**kwargs) - self.sql_workload_type = kwargs.get('sql_workload_type', None) - - -class StorageConfigurationSettings(msrest.serialization.Model): - """Storage Configurations for SQL Data, Log and TempDb. - - :param sql_data_settings: SQL Server Data Storage Settings. - :type sql_data_settings: ~azure.mgmt.sqlvirtualmachine.models.SQLStorageSettings - :param sql_log_settings: SQL Server Log Storage Settings. - :type sql_log_settings: ~azure.mgmt.sqlvirtualmachine.models.SQLStorageSettings - :param sql_temp_db_settings: SQL Server TempDb Storage Settings. - :type sql_temp_db_settings: ~azure.mgmt.sqlvirtualmachine.models.SQLStorageSettings - :param disk_configuration_type: Disk configuration to apply to SQL Server. Possible values - include: "NEW", "EXTEND", "ADD". - :type disk_configuration_type: str or - ~azure.mgmt.sqlvirtualmachine.models.DiskConfigurationType - :param storage_workload_type: Storage workload type. Possible values include: "GENERAL", - "OLTP", "DW". - :type storage_workload_type: str or ~azure.mgmt.sqlvirtualmachine.models.StorageWorkloadType - """ - - _attribute_map = { - 'sql_data_settings': {'key': 'sqlDataSettings', 'type': 'SQLStorageSettings'}, - 'sql_log_settings': {'key': 'sqlLogSettings', 'type': 'SQLStorageSettings'}, - 'sql_temp_db_settings': {'key': 'sqlTempDbSettings', 'type': 'SQLStorageSettings'}, - 'disk_configuration_type': {'key': 'diskConfigurationType', 'type': 'str'}, - 'storage_workload_type': {'key': 'storageWorkloadType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(StorageConfigurationSettings, self).__init__(**kwargs) - self.sql_data_settings = kwargs.get('sql_data_settings', None) - self.sql_log_settings = kwargs.get('sql_log_settings', None) - self.sql_temp_db_settings = kwargs.get('sql_temp_db_settings', None) - self.disk_configuration_type = kwargs.get('disk_configuration_type', None) - self.storage_workload_type = kwargs.get('storage_workload_type', None) - - -class WsfcDomainCredentials(msrest.serialization.Model): - """Domain credentials for setting up Windows Server Failover Cluster for SQL availability group. - - :param cluster_bootstrap_account_password: Cluster bootstrap account password. - :type cluster_bootstrap_account_password: str - :param cluster_operator_account_password: Cluster operator account password. - :type cluster_operator_account_password: str - :param sql_service_account_password: SQL service account password. - :type sql_service_account_password: str - """ - - _attribute_map = { - 'cluster_bootstrap_account_password': {'key': 'clusterBootstrapAccountPassword', 'type': 'str'}, - 'cluster_operator_account_password': {'key': 'clusterOperatorAccountPassword', 'type': 'str'}, - 'sql_service_account_password': {'key': 'sqlServiceAccountPassword', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(WsfcDomainCredentials, self).__init__(**kwargs) - self.cluster_bootstrap_account_password = kwargs.get('cluster_bootstrap_account_password', None) - self.cluster_operator_account_password = kwargs.get('cluster_operator_account_password', None) - self.sql_service_account_password = kwargs.get('sql_service_account_password', None) - - -class WsfcDomainProfile(msrest.serialization.Model): - """Active Directory account details to operate Windows Server Failover Cluster. - - :param domain_fqdn: Fully qualified name of the domain. - :type domain_fqdn: str - :param ou_path: Organizational Unit path in which the nodes and cluster will be present. - :type ou_path: str - :param cluster_bootstrap_account: Account name used for creating cluster (at minimum needs - permissions to 'Create Computer Objects' in domain). - :type cluster_bootstrap_account: str - :param cluster_operator_account: Account name used for operating cluster i.e. will be part of - administrators group on all the participating virtual machines in the cluster. - :type cluster_operator_account: str - :param sql_service_account: Account name under which SQL service will run on all participating - SQL virtual machines in the cluster. - :type sql_service_account: str - :param file_share_witness_path: Optional path for fileshare witness. - :type file_share_witness_path: str - :param storage_account_url: Fully qualified ARM resource id of the witness storage account. - :type storage_account_url: str - :param storage_account_primary_key: Primary key of the witness storage account. - :type storage_account_primary_key: str - """ - - _attribute_map = { - 'domain_fqdn': {'key': 'domainFqdn', 'type': 'str'}, - 'ou_path': {'key': 'ouPath', 'type': 'str'}, - 'cluster_bootstrap_account': {'key': 'clusterBootstrapAccount', 'type': 'str'}, - 'cluster_operator_account': {'key': 'clusterOperatorAccount', 'type': 'str'}, - 'sql_service_account': {'key': 'sqlServiceAccount', 'type': 'str'}, - 'file_share_witness_path': {'key': 'fileShareWitnessPath', 'type': 'str'}, - 'storage_account_url': {'key': 'storageAccountUrl', 'type': 'str'}, - 'storage_account_primary_key': {'key': 'storageAccountPrimaryKey', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(WsfcDomainProfile, self).__init__(**kwargs) - self.domain_fqdn = kwargs.get('domain_fqdn', None) - self.ou_path = kwargs.get('ou_path', None) - self.cluster_bootstrap_account = kwargs.get('cluster_bootstrap_account', None) - self.cluster_operator_account = kwargs.get('cluster_operator_account', None) - self.sql_service_account = kwargs.get('sql_service_account', None) - self.file_share_witness_path = kwargs.get('file_share_witness_path', None) - self.storage_account_url = kwargs.get('storage_account_url', None) - self.storage_account_primary_key = kwargs.get('storage_account_primary_key', None) diff --git a/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/models/_models_py3.py b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/models/_models_py3.py index f21af5c6c9f7..2d85d88cc751 100644 --- a/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/models/_models_py3.py +++ b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/models/_models_py3.py @@ -16,8 +16,8 @@ class AdditionalFeaturesServerConfigurations(msrest.serialization.Model): """Additional SQL Server feature settings. - :param is_r_services_enabled: Enable or disable R services (SQL 2016 onwards). - :type is_r_services_enabled: bool + :ivar is_r_services_enabled: Enable or disable R services (SQL 2016 onwards). + :vartype is_r_services_enabled: bool """ _attribute_map = { @@ -30,6 +30,10 @@ def __init__( is_r_services_enabled: Optional[bool] = None, **kwargs ): + """ + :keyword is_r_services_enabled: Enable or disable R services (SQL 2016 onwards). + :paramtype is_r_services_enabled: bool + """ super(AdditionalFeaturesServerConfigurations, self).__init__(**kwargs) self.is_r_services_enabled = is_r_services_enabled @@ -37,35 +41,35 @@ def __init__( class AutoBackupSettings(msrest.serialization.Model): """Configure backups for databases in your SQL virtual machine. - :param enable: Enable or disable autobackup on SQL virtual machine. - :type enable: bool - :param enable_encryption: Enable or disable encryption for backup on SQL virtual machine. - :type enable_encryption: bool - :param retention_period: Retention period of backup: 1-30 days. - :type retention_period: int - :param storage_account_url: Storage account url where backup will be taken to. - :type storage_account_url: str - :param storage_access_key: Storage account key where backup will be taken to. - :type storage_access_key: str - :param password: Password for encryption on backup. - :type password: str - :param backup_system_dbs: Include or exclude system databases from auto backup. - :type backup_system_dbs: bool - :param backup_schedule_type: Backup schedule type. Possible values include: "Manual", + :ivar enable: Enable or disable autobackup on SQL virtual machine. + :vartype enable: bool + :ivar enable_encryption: Enable or disable encryption for backup on SQL virtual machine. + :vartype enable_encryption: bool + :ivar retention_period: Retention period of backup: 1-30 days. + :vartype retention_period: int + :ivar storage_account_url: Storage account url where backup will be taken to. + :vartype storage_account_url: str + :ivar storage_access_key: Storage account key where backup will be taken to. + :vartype storage_access_key: str + :ivar password: Password for encryption on backup. + :vartype password: str + :ivar backup_system_dbs: Include or exclude system databases from auto backup. + :vartype backup_system_dbs: bool + :ivar backup_schedule_type: Backup schedule type. Possible values include: "Manual", "Automated". - :type backup_schedule_type: str or ~azure.mgmt.sqlvirtualmachine.models.BackupScheduleType - :param full_backup_frequency: Frequency of full backups. In both cases, full backups begin + :vartype backup_schedule_type: str or ~azure.mgmt.sqlvirtualmachine.models.BackupScheduleType + :ivar full_backup_frequency: Frequency of full backups. In both cases, full backups begin during the next scheduled time window. Possible values include: "Daily", "Weekly". - :type full_backup_frequency: str or + :vartype full_backup_frequency: str or ~azure.mgmt.sqlvirtualmachine.models.FullBackupFrequencyType - :param full_backup_start_time: Start time of a given day during which full backups can take + :ivar full_backup_start_time: Start time of a given day during which full backups can take place. 0-23 hours. - :type full_backup_start_time: int - :param full_backup_window_hours: Duration of the time window of a given day during which full + :vartype full_backup_start_time: int + :ivar full_backup_window_hours: Duration of the time window of a given day during which full backups can take place. 1-23 hours. - :type full_backup_window_hours: int - :param log_backup_frequency: Frequency of log backups. 5-60 minutes. - :type log_backup_frequency: int + :vartype full_backup_window_hours: int + :ivar log_backup_frequency: Frequency of log backups. 5-60 minutes. + :vartype log_backup_frequency: int """ _attribute_map = { @@ -100,6 +104,37 @@ def __init__( log_backup_frequency: Optional[int] = None, **kwargs ): + """ + :keyword enable: Enable or disable autobackup on SQL virtual machine. + :paramtype enable: bool + :keyword enable_encryption: Enable or disable encryption for backup on SQL virtual machine. + :paramtype enable_encryption: bool + :keyword retention_period: Retention period of backup: 1-30 days. + :paramtype retention_period: int + :keyword storage_account_url: Storage account url where backup will be taken to. + :paramtype storage_account_url: str + :keyword storage_access_key: Storage account key where backup will be taken to. + :paramtype storage_access_key: str + :keyword password: Password for encryption on backup. + :paramtype password: str + :keyword backup_system_dbs: Include or exclude system databases from auto backup. + :paramtype backup_system_dbs: bool + :keyword backup_schedule_type: Backup schedule type. Possible values include: "Manual", + "Automated". + :paramtype backup_schedule_type: str or ~azure.mgmt.sqlvirtualmachine.models.BackupScheduleType + :keyword full_backup_frequency: Frequency of full backups. In both cases, full backups begin + during the next scheduled time window. Possible values include: "Daily", "Weekly". + :paramtype full_backup_frequency: str or + ~azure.mgmt.sqlvirtualmachine.models.FullBackupFrequencyType + :keyword full_backup_start_time: Start time of a given day during which full backups can take + place. 0-23 hours. + :paramtype full_backup_start_time: int + :keyword full_backup_window_hours: Duration of the time window of a given day during which full + backups can take place. 1-23 hours. + :paramtype full_backup_window_hours: int + :keyword log_backup_frequency: Frequency of log backups. 5-60 minutes. + :paramtype log_backup_frequency: int + """ super(AutoBackupSettings, self).__init__(**kwargs) self.enable = enable self.enable_encryption = enable_encryption @@ -118,16 +153,16 @@ def __init__( class AutoPatchingSettings(msrest.serialization.Model): """Set a patching window during which Windows and SQL patches will be applied. - :param enable: Enable or disable autopatching on SQL virtual machine. - :type enable: bool - :param day_of_week: Day of week to apply the patch on. Possible values include: "Monday", + :ivar enable: Enable or disable autopatching on SQL virtual machine. + :vartype enable: bool + :ivar day_of_week: Day of week to apply the patch on. Possible values include: "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday". - :type day_of_week: str or ~azure.mgmt.sqlvirtualmachine.models.DayOfWeek - :param maintenance_window_starting_hour: Hour of the day when patching is initiated. Local VM + :vartype day_of_week: str or ~azure.mgmt.sqlvirtualmachine.models.DayOfWeek + :ivar maintenance_window_starting_hour: Hour of the day when patching is initiated. Local VM time. - :type maintenance_window_starting_hour: int - :param maintenance_window_duration: Duration of patching. - :type maintenance_window_duration: int + :vartype maintenance_window_starting_hour: int + :ivar maintenance_window_duration: Duration of patching. + :vartype maintenance_window_duration: int """ _attribute_map = { @@ -146,6 +181,18 @@ def __init__( maintenance_window_duration: Optional[int] = None, **kwargs ): + """ + :keyword enable: Enable or disable autopatching on SQL virtual machine. + :paramtype enable: bool + :keyword day_of_week: Day of week to apply the patch on. Possible values include: "Monday", + "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday". + :paramtype day_of_week: str or ~azure.mgmt.sqlvirtualmachine.models.DayOfWeek + :keyword maintenance_window_starting_hour: Hour of the day when patching is initiated. Local VM + time. + :paramtype maintenance_window_starting_hour: int + :keyword maintenance_window_duration: Duration of patching. + :paramtype maintenance_window_duration: int + """ super(AutoPatchingSettings, self).__init__(**kwargs) self.enable = enable self.day_of_week = day_of_week @@ -182,6 +229,8 @@ def __init__( self, **kwargs ): + """ + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -217,6 +266,8 @@ def __init__( self, **kwargs ): + """ + """ super(ProxyResource, self).__init__(**kwargs) @@ -233,17 +284,17 @@ class AvailabilityGroupListener(ProxyResource): :vartype type: str :ivar provisioning_state: Provisioning state to track the async operation status. :vartype provisioning_state: str - :param availability_group_name: Name of the availability group. - :type availability_group_name: str - :param load_balancer_configurations: List of load balancer configurations for an availability + :ivar availability_group_name: Name of the availability group. + :vartype availability_group_name: str + :ivar load_balancer_configurations: List of load balancer configurations for an availability group listener. - :type load_balancer_configurations: + :vartype load_balancer_configurations: list[~azure.mgmt.sqlvirtualmachine.models.LoadBalancerConfiguration] - :param create_default_availability_group_if_not_exist: Create a default availability group if - it does not exist. - :type create_default_availability_group_if_not_exist: bool - :param port: Listener port. - :type port: int + :ivar create_default_availability_group_if_not_exist: Create a default availability group if it + does not exist. + :vartype create_default_availability_group_if_not_exist: bool + :ivar port: Listener port. + :vartype port: int """ _validation = { @@ -273,6 +324,19 @@ def __init__( port: Optional[int] = None, **kwargs ): + """ + :keyword availability_group_name: Name of the availability group. + :paramtype availability_group_name: str + :keyword load_balancer_configurations: List of load balancer configurations for an availability + group listener. + :paramtype load_balancer_configurations: + list[~azure.mgmt.sqlvirtualmachine.models.LoadBalancerConfiguration] + :keyword create_default_availability_group_if_not_exist: Create a default availability group if + it does not exist. + :paramtype create_default_availability_group_if_not_exist: bool + :keyword port: Listener port. + :paramtype port: int + """ super(AvailabilityGroupListener, self).__init__(**kwargs) self.provisioning_state = None self.availability_group_name = availability_group_name @@ -306,6 +370,8 @@ def __init__( self, **kwargs ): + """ + """ super(AvailabilityGroupListenerListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -314,16 +380,16 @@ def __init__( class KeyVaultCredentialSettings(msrest.serialization.Model): """Configure your SQL virtual machine to be able to connect to the Azure Key Vault service. - :param enable: Enable or disable key vault credential setting. - :type enable: bool - :param credential_name: Credential name. - :type credential_name: str - :param azure_key_vault_url: Azure Key Vault url. - :type azure_key_vault_url: str - :param service_principal_name: Service principal name to access key vault. - :type service_principal_name: str - :param service_principal_secret: Service principal name secret to access key vault. - :type service_principal_secret: str + :ivar enable: Enable or disable key vault credential setting. + :vartype enable: bool + :ivar credential_name: Credential name. + :vartype credential_name: str + :ivar azure_key_vault_url: Azure Key Vault url. + :vartype azure_key_vault_url: str + :ivar service_principal_name: Service principal name to access key vault. + :vartype service_principal_name: str + :ivar service_principal_secret: Service principal name secret to access key vault. + :vartype service_principal_secret: str """ _attribute_map = { @@ -344,6 +410,18 @@ def __init__( service_principal_secret: Optional[str] = None, **kwargs ): + """ + :keyword enable: Enable or disable key vault credential setting. + :paramtype enable: bool + :keyword credential_name: Credential name. + :paramtype credential_name: str + :keyword azure_key_vault_url: Azure Key Vault url. + :paramtype azure_key_vault_url: str + :keyword service_principal_name: Service principal name to access key vault. + :paramtype service_principal_name: str + :keyword service_principal_secret: Service principal name secret to access key vault. + :paramtype service_principal_secret: str + """ super(KeyVaultCredentialSettings, self).__init__(**kwargs) self.enable = enable self.credential_name = credential_name @@ -355,17 +433,17 @@ def __init__( class LoadBalancerConfiguration(msrest.serialization.Model): """A load balancer configuration for an availability group listener. - :param private_ip_address: Private IP address. - :type private_ip_address: ~azure.mgmt.sqlvirtualmachine.models.PrivateIPAddress - :param public_ip_address_resource_id: Resource id of the public IP. - :type public_ip_address_resource_id: str - :param load_balancer_resource_id: Resource id of the load balancer. - :type load_balancer_resource_id: str - :param probe_port: Probe port. - :type probe_port: int - :param sql_virtual_machine_instances: List of the SQL virtual machine instance resource id's + :ivar private_ip_address: Private IP address. + :vartype private_ip_address: ~azure.mgmt.sqlvirtualmachine.models.PrivateIPAddress + :ivar public_ip_address_resource_id: Resource id of the public IP. + :vartype public_ip_address_resource_id: str + :ivar load_balancer_resource_id: Resource id of the load balancer. + :vartype load_balancer_resource_id: str + :ivar probe_port: Probe port. + :vartype probe_port: int + :ivar sql_virtual_machine_instances: List of the SQL virtual machine instance resource id's that are enrolled into the availability group listener. - :type sql_virtual_machine_instances: list[str] + :vartype sql_virtual_machine_instances: list[str] """ _attribute_map = { @@ -386,6 +464,19 @@ def __init__( sql_virtual_machine_instances: Optional[List[str]] = None, **kwargs ): + """ + :keyword private_ip_address: Private IP address. + :paramtype private_ip_address: ~azure.mgmt.sqlvirtualmachine.models.PrivateIPAddress + :keyword public_ip_address_resource_id: Resource id of the public IP. + :paramtype public_ip_address_resource_id: str + :keyword load_balancer_resource_id: Resource id of the load balancer. + :paramtype load_balancer_resource_id: str + :keyword probe_port: Probe port. + :paramtype probe_port: int + :keyword sql_virtual_machine_instances: List of the SQL virtual machine instance resource id's + that are enrolled into the availability group listener. + :paramtype sql_virtual_machine_instances: list[str] + """ super(LoadBalancerConfiguration, self).__init__(**kwargs) self.private_ip_address = private_ip_address self.public_ip_address_resource_id = public_ip_address_resource_id @@ -428,6 +519,8 @@ def __init__( self, **kwargs ): + """ + """ super(Operation, self).__init__(**kwargs) self.name = None self.display = None @@ -469,6 +562,8 @@ def __init__( self, **kwargs ): + """ + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = None self.resource = None @@ -501,6 +596,8 @@ def __init__( self, **kwargs ): + """ + """ super(OperationListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -509,10 +606,10 @@ def __init__( class PrivateIPAddress(msrest.serialization.Model): """A private IP address bound to the availability group listener. - :param ip_address: Private IP address bound to the availability group listener. - :type ip_address: str - :param subnet_resource_id: Subnet used to include private IP. - :type subnet_resource_id: str + :ivar ip_address: Private IP address bound to the availability group listener. + :vartype ip_address: str + :ivar subnet_resource_id: Subnet used to include private IP. + :vartype subnet_resource_id: str """ _attribute_map = { @@ -527,6 +624,12 @@ def __init__( subnet_resource_id: Optional[str] = None, **kwargs ): + """ + :keyword ip_address: Private IP address bound to the availability group listener. + :paramtype ip_address: str + :keyword subnet_resource_id: Subnet used to include private IP. + :paramtype subnet_resource_id: str + """ super(PrivateIPAddress, self).__init__(**kwargs) self.ip_address = ip_address self.subnet_resource_id = subnet_resource_id @@ -539,10 +642,10 @@ class ResourceIdentity(msrest.serialization.Model): :ivar principal_id: The Azure Active Directory principal id. :vartype principal_id: str - :param type: The identity type. Set this to 'SystemAssigned' in order to automatically create + :ivar type: The identity type. Set this to 'SystemAssigned' in order to automatically create and assign an Azure Active Directory principal for the resource. Possible values include: "SystemAssigned". - :type type: str or ~azure.mgmt.sqlvirtualmachine.models.IdentityType + :vartype type: str or ~azure.mgmt.sqlvirtualmachine.models.IdentityType :ivar tenant_id: The Azure Active Directory tenant id. :vartype tenant_id: str """ @@ -564,6 +667,12 @@ def __init__( type: Optional[Union[str, "IdentityType"]] = None, **kwargs ): + """ + :keyword type: The identity type. Set this to 'SystemAssigned' in order to automatically create + and assign an Azure Active Directory principal for the resource. Possible values include: + "SystemAssigned". + :paramtype type: str or ~azure.mgmt.sqlvirtualmachine.models.IdentityType + """ super(ResourceIdentity, self).__init__(**kwargs) self.principal_id = None self.type = type @@ -573,17 +682,17 @@ def __init__( class ServerConfigurationsManagementSettings(msrest.serialization.Model): """Set the connectivity, storage and workload settings. - :param sql_connectivity_update_settings: SQL connectivity type settings. - :type sql_connectivity_update_settings: + :ivar sql_connectivity_update_settings: SQL connectivity type settings. + :vartype sql_connectivity_update_settings: ~azure.mgmt.sqlvirtualmachine.models.SqlConnectivityUpdateSettings - :param sql_workload_type_update_settings: SQL workload type settings. - :type sql_workload_type_update_settings: + :ivar sql_workload_type_update_settings: SQL workload type settings. + :vartype sql_workload_type_update_settings: ~azure.mgmt.sqlvirtualmachine.models.SqlWorkloadTypeUpdateSettings - :param sql_storage_update_settings: SQL storage update settings. - :type sql_storage_update_settings: + :ivar sql_storage_update_settings: SQL storage update settings. + :vartype sql_storage_update_settings: ~azure.mgmt.sqlvirtualmachine.models.SqlStorageUpdateSettings - :param additional_features_server_configurations: Additional SQL feature settings. - :type additional_features_server_configurations: + :ivar additional_features_server_configurations: Additional SQL feature settings. + :vartype additional_features_server_configurations: ~azure.mgmt.sqlvirtualmachine.models.AdditionalFeaturesServerConfigurations """ @@ -603,6 +712,20 @@ def __init__( additional_features_server_configurations: Optional["AdditionalFeaturesServerConfigurations"] = None, **kwargs ): + """ + :keyword sql_connectivity_update_settings: SQL connectivity type settings. + :paramtype sql_connectivity_update_settings: + ~azure.mgmt.sqlvirtualmachine.models.SqlConnectivityUpdateSettings + :keyword sql_workload_type_update_settings: SQL workload type settings. + :paramtype sql_workload_type_update_settings: + ~azure.mgmt.sqlvirtualmachine.models.SqlWorkloadTypeUpdateSettings + :keyword sql_storage_update_settings: SQL storage update settings. + :paramtype sql_storage_update_settings: + ~azure.mgmt.sqlvirtualmachine.models.SqlStorageUpdateSettings + :keyword additional_features_server_configurations: Additional SQL feature settings. + :paramtype additional_features_server_configurations: + ~azure.mgmt.sqlvirtualmachine.models.AdditionalFeaturesServerConfigurations + """ super(ServerConfigurationsManagementSettings, self).__init__(**kwargs) self.sql_connectivity_update_settings = sql_connectivity_update_settings self.sql_workload_type_update_settings = sql_workload_type_update_settings @@ -613,15 +736,15 @@ def __init__( class SqlConnectivityUpdateSettings(msrest.serialization.Model): """Set the access level and network port settings for SQL Server. - :param connectivity_type: SQL Server connectivity option. Possible values include: "LOCAL", + :ivar connectivity_type: SQL Server connectivity option. Possible values include: "LOCAL", "PRIVATE", "PUBLIC". - :type connectivity_type: str or ~azure.mgmt.sqlvirtualmachine.models.ConnectivityType - :param port: SQL Server port. - :type port: int - :param sql_auth_update_user_name: SQL Server sysadmin login to create. - :type sql_auth_update_user_name: str - :param sql_auth_update_password: SQL Server sysadmin login password. - :type sql_auth_update_password: str + :vartype connectivity_type: str or ~azure.mgmt.sqlvirtualmachine.models.ConnectivityType + :ivar port: SQL Server port. + :vartype port: int + :ivar sql_auth_update_user_name: SQL Server sysadmin login to create. + :vartype sql_auth_update_user_name: str + :ivar sql_auth_update_password: SQL Server sysadmin login password. + :vartype sql_auth_update_password: str """ _attribute_map = { @@ -640,6 +763,17 @@ def __init__( sql_auth_update_password: Optional[str] = None, **kwargs ): + """ + :keyword connectivity_type: SQL Server connectivity option. Possible values include: "LOCAL", + "PRIVATE", "PUBLIC". + :paramtype connectivity_type: str or ~azure.mgmt.sqlvirtualmachine.models.ConnectivityType + :keyword port: SQL Server port. + :paramtype port: int + :keyword sql_auth_update_user_name: SQL Server sysadmin login to create. + :paramtype sql_auth_update_user_name: str + :keyword sql_auth_update_password: SQL Server sysadmin login password. + :paramtype sql_auth_update_password: str + """ super(SqlConnectivityUpdateSettings, self).__init__(**kwargs) self.connectivity_type = connectivity_type self.port = port @@ -650,10 +784,10 @@ def __init__( class SQLStorageSettings(msrest.serialization.Model): """Set disk storage settings for SQL Server. - :param luns: Logical Unit Numbers for the disks. - :type luns: list[int] - :param default_file_path: SQL Server default file path. - :type default_file_path: str + :ivar luns: Logical Unit Numbers for the disks. + :vartype luns: list[int] + :ivar default_file_path: SQL Server default file path. + :vartype default_file_path: str """ _attribute_map = { @@ -668,6 +802,12 @@ def __init__( default_file_path: Optional[str] = None, **kwargs ): + """ + :keyword luns: Logical Unit Numbers for the disks. + :paramtype luns: list[int] + :keyword default_file_path: SQL Server default file path. + :paramtype default_file_path: str + """ super(SQLStorageSettings, self).__init__(**kwargs) self.luns = luns self.default_file_path = default_file_path @@ -676,13 +816,13 @@ def __init__( class SqlStorageUpdateSettings(msrest.serialization.Model): """Set disk storage settings for SQL Server. - :param disk_count: Virtual machine disk count. - :type disk_count: int - :param starting_device_id: Device id of the first disk to be updated. - :type starting_device_id: int - :param disk_configuration_type: Disk configuration to apply to SQL Server. Possible values + :ivar disk_count: Virtual machine disk count. + :vartype disk_count: int + :ivar starting_device_id: Device id of the first disk to be updated. + :vartype starting_device_id: int + :ivar disk_configuration_type: Disk configuration to apply to SQL Server. Possible values include: "NEW", "EXTEND", "ADD". - :type disk_configuration_type: str or + :vartype disk_configuration_type: str or ~azure.mgmt.sqlvirtualmachine.models.DiskConfigurationType """ @@ -700,6 +840,16 @@ def __init__( disk_configuration_type: Optional[Union[str, "DiskConfigurationType"]] = None, **kwargs ): + """ + :keyword disk_count: Virtual machine disk count. + :paramtype disk_count: int + :keyword starting_device_id: Device id of the first disk to be updated. + :paramtype starting_device_id: int + :keyword disk_configuration_type: Disk configuration to apply to SQL Server. Possible values + include: "NEW", "EXTEND", "ADD". + :paramtype disk_configuration_type: str or + ~azure.mgmt.sqlvirtualmachine.models.DiskConfigurationType + """ super(SqlStorageUpdateSettings, self).__init__(**kwargs) self.disk_count = disk_count self.starting_device_id = starting_device_id @@ -719,10 +869,10 @@ class TrackedResource(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -747,6 +897,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(TrackedResource, self).__init__(**kwargs) self.location = location self.tags = tags @@ -765,47 +921,48 @@ class SqlVirtualMachine(TrackedResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param identity: Azure Active Directory identity of the server. - :type identity: ~azure.mgmt.sqlvirtualmachine.models.ResourceIdentity - :param virtual_machine_resource_id: ARM Resource id of underlying virtual machine created from + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar identity: Azure Active Directory identity of the server. + :vartype identity: ~azure.mgmt.sqlvirtualmachine.models.ResourceIdentity + :ivar virtual_machine_resource_id: ARM Resource id of underlying virtual machine created from SQL marketplace image. - :type virtual_machine_resource_id: str + :vartype virtual_machine_resource_id: str :ivar provisioning_state: Provisioning state to track the async operation status. :vartype provisioning_state: str - :param sql_image_offer: SQL image offer. Examples include SQL2016-WS2016, SQL2017-WS2016. - :type sql_image_offer: str - :param sql_server_license_type: SQL Server license type. Possible values include: "PAYG", + :ivar sql_image_offer: SQL image offer. Examples include SQL2016-WS2016, SQL2017-WS2016. + :vartype sql_image_offer: str + :ivar sql_server_license_type: SQL Server license type. Possible values include: "PAYG", "AHUB", "DR". - :type sql_server_license_type: str or ~azure.mgmt.sqlvirtualmachine.models.SqlServerLicenseType - :param sql_management: SQL Server Management type. Possible values include: "Full", + :vartype sql_server_license_type: str or + ~azure.mgmt.sqlvirtualmachine.models.SqlServerLicenseType + :ivar sql_management: SQL Server Management type. Possible values include: "Full", "LightWeight", "NoAgent". - :type sql_management: str or ~azure.mgmt.sqlvirtualmachine.models.SqlManagementMode - :param sql_image_sku: SQL Server edition type. Possible values include: "Developer", "Express", + :vartype sql_management: str or ~azure.mgmt.sqlvirtualmachine.models.SqlManagementMode + :ivar sql_image_sku: SQL Server edition type. Possible values include: "Developer", "Express", "Standard", "Enterprise", "Web". - :type sql_image_sku: str or ~azure.mgmt.sqlvirtualmachine.models.SqlImageSku - :param sql_virtual_machine_group_resource_id: ARM resource id of the SQL virtual machine group + :vartype sql_image_sku: str or ~azure.mgmt.sqlvirtualmachine.models.SqlImageSku + :ivar sql_virtual_machine_group_resource_id: ARM resource id of the SQL virtual machine group this SQL virtual machine is or will be part of. - :type sql_virtual_machine_group_resource_id: str - :param wsfc_domain_credentials: Domain credentials for setting up Windows Server Failover + :vartype sql_virtual_machine_group_resource_id: str + :ivar wsfc_domain_credentials: Domain credentials for setting up Windows Server Failover Cluster for SQL availability group. - :type wsfc_domain_credentials: ~azure.mgmt.sqlvirtualmachine.models.WsfcDomainCredentials - :param auto_patching_settings: Auto patching settings for applying critical security updates to + :vartype wsfc_domain_credentials: ~azure.mgmt.sqlvirtualmachine.models.WsfcDomainCredentials + :ivar auto_patching_settings: Auto patching settings for applying critical security updates to SQL virtual machine. - :type auto_patching_settings: ~azure.mgmt.sqlvirtualmachine.models.AutoPatchingSettings - :param auto_backup_settings: Auto backup settings for SQL Server. - :type auto_backup_settings: ~azure.mgmt.sqlvirtualmachine.models.AutoBackupSettings - :param key_vault_credential_settings: Key vault credential settings. - :type key_vault_credential_settings: + :vartype auto_patching_settings: ~azure.mgmt.sqlvirtualmachine.models.AutoPatchingSettings + :ivar auto_backup_settings: Auto backup settings for SQL Server. + :vartype auto_backup_settings: ~azure.mgmt.sqlvirtualmachine.models.AutoBackupSettings + :ivar key_vault_credential_settings: Key vault credential settings. + :vartype key_vault_credential_settings: ~azure.mgmt.sqlvirtualmachine.models.KeyVaultCredentialSettings - :param server_configurations_management_settings: SQL Server configuration management settings. - :type server_configurations_management_settings: + :ivar server_configurations_management_settings: SQL Server configuration management settings. + :vartype server_configurations_management_settings: ~azure.mgmt.sqlvirtualmachine.models.ServerConfigurationsManagementSettings - :param storage_configuration_settings: Storage Configuration Settings. - :type storage_configuration_settings: + :ivar storage_configuration_settings: Storage Configuration Settings. + :vartype storage_configuration_settings: ~azure.mgmt.sqlvirtualmachine.models.StorageConfigurationSettings """ @@ -859,6 +1016,50 @@ def __init__( storage_configuration_settings: Optional["StorageConfigurationSettings"] = None, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword identity: Azure Active Directory identity of the server. + :paramtype identity: ~azure.mgmt.sqlvirtualmachine.models.ResourceIdentity + :keyword virtual_machine_resource_id: ARM Resource id of underlying virtual machine created + from SQL marketplace image. + :paramtype virtual_machine_resource_id: str + :keyword sql_image_offer: SQL image offer. Examples include SQL2016-WS2016, SQL2017-WS2016. + :paramtype sql_image_offer: str + :keyword sql_server_license_type: SQL Server license type. Possible values include: "PAYG", + "AHUB", "DR". + :paramtype sql_server_license_type: str or + ~azure.mgmt.sqlvirtualmachine.models.SqlServerLicenseType + :keyword sql_management: SQL Server Management type. Possible values include: "Full", + "LightWeight", "NoAgent". + :paramtype sql_management: str or ~azure.mgmt.sqlvirtualmachine.models.SqlManagementMode + :keyword sql_image_sku: SQL Server edition type. Possible values include: "Developer", + "Express", "Standard", "Enterprise", "Web". + :paramtype sql_image_sku: str or ~azure.mgmt.sqlvirtualmachine.models.SqlImageSku + :keyword sql_virtual_machine_group_resource_id: ARM resource id of the SQL virtual machine + group this SQL virtual machine is or will be part of. + :paramtype sql_virtual_machine_group_resource_id: str + :keyword wsfc_domain_credentials: Domain credentials for setting up Windows Server Failover + Cluster for SQL availability group. + :paramtype wsfc_domain_credentials: ~azure.mgmt.sqlvirtualmachine.models.WsfcDomainCredentials + :keyword auto_patching_settings: Auto patching settings for applying critical security updates + to SQL virtual machine. + :paramtype auto_patching_settings: ~azure.mgmt.sqlvirtualmachine.models.AutoPatchingSettings + :keyword auto_backup_settings: Auto backup settings for SQL Server. + :paramtype auto_backup_settings: ~azure.mgmt.sqlvirtualmachine.models.AutoBackupSettings + :keyword key_vault_credential_settings: Key vault credential settings. + :paramtype key_vault_credential_settings: + ~azure.mgmt.sqlvirtualmachine.models.KeyVaultCredentialSettings + :keyword server_configurations_management_settings: SQL Server configuration management + settings. + :paramtype server_configurations_management_settings: + ~azure.mgmt.sqlvirtualmachine.models.ServerConfigurationsManagementSettings + :keyword storage_configuration_settings: Storage Configuration Settings. + :paramtype storage_configuration_settings: + ~azure.mgmt.sqlvirtualmachine.models.StorageConfigurationSettings + """ super(SqlVirtualMachine, self).__init__(location=location, tags=tags, **kwargs) self.identity = identity self.virtual_machine_resource_id = virtual_machine_resource_id @@ -889,16 +1090,16 @@ class SqlVirtualMachineGroup(TrackedResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] :ivar provisioning_state: Provisioning state to track the async operation status. :vartype provisioning_state: str - :param sql_image_offer: SQL image offer. Examples may include SQL2016-WS2016, SQL2017-WS2016. - :type sql_image_offer: str - :param sql_image_sku: SQL image sku. Possible values include: "Developer", "Enterprise". - :type sql_image_sku: str or ~azure.mgmt.sqlvirtualmachine.models.SqlVmGroupImageSku + :ivar sql_image_offer: SQL image offer. Examples may include SQL2016-WS2016, SQL2017-WS2016. + :vartype sql_image_offer: str + :ivar sql_image_sku: SQL image sku. Possible values include: "Developer", "Enterprise". + :vartype sql_image_sku: str or ~azure.mgmt.sqlvirtualmachine.models.SqlVmGroupImageSku :ivar scale_type: Scale type. Possible values include: "HA". :vartype scale_type: str or ~azure.mgmt.sqlvirtualmachine.models.ScaleType :ivar cluster_manager_type: Type of cluster manager: Windows Server Failover Cluster (WSFC), @@ -907,8 +1108,8 @@ class SqlVirtualMachineGroup(TrackedResource): :ivar cluster_configuration: Cluster type. Possible values include: "Domainful". :vartype cluster_configuration: str or ~azure.mgmt.sqlvirtualmachine.models.ClusterConfiguration - :param wsfc_domain_profile: Cluster Active Directory domain profile. - :type wsfc_domain_profile: ~azure.mgmt.sqlvirtualmachine.models.WsfcDomainProfile + :ivar wsfc_domain_profile: Cluster Active Directory domain profile. + :vartype wsfc_domain_profile: ~azure.mgmt.sqlvirtualmachine.models.WsfcDomainProfile """ _validation = { @@ -947,6 +1148,18 @@ def __init__( wsfc_domain_profile: Optional["WsfcDomainProfile"] = None, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword sql_image_offer: SQL image offer. Examples may include SQL2016-WS2016, SQL2017-WS2016. + :paramtype sql_image_offer: str + :keyword sql_image_sku: SQL image sku. Possible values include: "Developer", "Enterprise". + :paramtype sql_image_sku: str or ~azure.mgmt.sqlvirtualmachine.models.SqlVmGroupImageSku + :keyword wsfc_domain_profile: Cluster Active Directory domain profile. + :paramtype wsfc_domain_profile: ~azure.mgmt.sqlvirtualmachine.models.WsfcDomainProfile + """ super(SqlVirtualMachineGroup, self).__init__(location=location, tags=tags, **kwargs) self.provisioning_state = None self.sql_image_offer = sql_image_offer @@ -982,6 +1195,8 @@ def __init__( self, **kwargs ): + """ + """ super(SqlVirtualMachineGroupListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -990,8 +1205,8 @@ def __init__( class SqlVirtualMachineGroupUpdate(msrest.serialization.Model): """An update to a SQL virtual machine group. - :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 = { @@ -1004,6 +1219,10 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(SqlVirtualMachineGroupUpdate, self).__init__(**kwargs) self.tags = tags @@ -1033,6 +1252,8 @@ def __init__( self, **kwargs ): + """ + """ super(SqlVirtualMachineListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -1041,8 +1262,8 @@ def __init__( class SqlVirtualMachineUpdate(msrest.serialization.Model): """An update to a SQL virtual machine. - :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 = { @@ -1055,6 +1276,10 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(SqlVirtualMachineUpdate, self).__init__(**kwargs) self.tags = tags @@ -1062,9 +1287,9 @@ def __init__( class SqlWorkloadTypeUpdateSettings(msrest.serialization.Model): """Set workload type to optimize storage for SQL Server. - :param sql_workload_type: SQL Server workload type. Possible values include: "GENERAL", "OLTP", + :ivar sql_workload_type: SQL Server workload type. Possible values include: "GENERAL", "OLTP", "DW". - :type sql_workload_type: str or ~azure.mgmt.sqlvirtualmachine.models.SqlWorkloadType + :vartype sql_workload_type: str or ~azure.mgmt.sqlvirtualmachine.models.SqlWorkloadType """ _attribute_map = { @@ -1077,6 +1302,11 @@ def __init__( sql_workload_type: Optional[Union[str, "SqlWorkloadType"]] = None, **kwargs ): + """ + :keyword sql_workload_type: SQL Server workload type. Possible values include: "GENERAL", + "OLTP", "DW". + :paramtype sql_workload_type: str or ~azure.mgmt.sqlvirtualmachine.models.SqlWorkloadType + """ super(SqlWorkloadTypeUpdateSettings, self).__init__(**kwargs) self.sql_workload_type = sql_workload_type @@ -1084,19 +1314,19 @@ def __init__( class StorageConfigurationSettings(msrest.serialization.Model): """Storage Configurations for SQL Data, Log and TempDb. - :param sql_data_settings: SQL Server Data Storage Settings. - :type sql_data_settings: ~azure.mgmt.sqlvirtualmachine.models.SQLStorageSettings - :param sql_log_settings: SQL Server Log Storage Settings. - :type sql_log_settings: ~azure.mgmt.sqlvirtualmachine.models.SQLStorageSettings - :param sql_temp_db_settings: SQL Server TempDb Storage Settings. - :type sql_temp_db_settings: ~azure.mgmt.sqlvirtualmachine.models.SQLStorageSettings - :param disk_configuration_type: Disk configuration to apply to SQL Server. Possible values + :ivar sql_data_settings: SQL Server Data Storage Settings. + :vartype sql_data_settings: ~azure.mgmt.sqlvirtualmachine.models.SQLStorageSettings + :ivar sql_log_settings: SQL Server Log Storage Settings. + :vartype sql_log_settings: ~azure.mgmt.sqlvirtualmachine.models.SQLStorageSettings + :ivar sql_temp_db_settings: SQL Server TempDb Storage Settings. + :vartype sql_temp_db_settings: ~azure.mgmt.sqlvirtualmachine.models.SQLStorageSettings + :ivar disk_configuration_type: Disk configuration to apply to SQL Server. Possible values include: "NEW", "EXTEND", "ADD". - :type disk_configuration_type: str or + :vartype disk_configuration_type: str or ~azure.mgmt.sqlvirtualmachine.models.DiskConfigurationType - :param storage_workload_type: Storage workload type. Possible values include: "GENERAL", - "OLTP", "DW". - :type storage_workload_type: str or ~azure.mgmt.sqlvirtualmachine.models.StorageWorkloadType + :ivar storage_workload_type: Storage workload type. Possible values include: "GENERAL", "OLTP", + "DW". + :vartype storage_workload_type: str or ~azure.mgmt.sqlvirtualmachine.models.StorageWorkloadType """ _attribute_map = { @@ -1117,6 +1347,22 @@ def __init__( storage_workload_type: Optional[Union[str, "StorageWorkloadType"]] = None, **kwargs ): + """ + :keyword sql_data_settings: SQL Server Data Storage Settings. + :paramtype sql_data_settings: ~azure.mgmt.sqlvirtualmachine.models.SQLStorageSettings + :keyword sql_log_settings: SQL Server Log Storage Settings. + :paramtype sql_log_settings: ~azure.mgmt.sqlvirtualmachine.models.SQLStorageSettings + :keyword sql_temp_db_settings: SQL Server TempDb Storage Settings. + :paramtype sql_temp_db_settings: ~azure.mgmt.sqlvirtualmachine.models.SQLStorageSettings + :keyword disk_configuration_type: Disk configuration to apply to SQL Server. Possible values + include: "NEW", "EXTEND", "ADD". + :paramtype disk_configuration_type: str or + ~azure.mgmt.sqlvirtualmachine.models.DiskConfigurationType + :keyword storage_workload_type: Storage workload type. Possible values include: "GENERAL", + "OLTP", "DW". + :paramtype storage_workload_type: str or + ~azure.mgmt.sqlvirtualmachine.models.StorageWorkloadType + """ super(StorageConfigurationSettings, self).__init__(**kwargs) self.sql_data_settings = sql_data_settings self.sql_log_settings = sql_log_settings @@ -1128,12 +1374,12 @@ def __init__( class WsfcDomainCredentials(msrest.serialization.Model): """Domain credentials for setting up Windows Server Failover Cluster for SQL availability group. - :param cluster_bootstrap_account_password: Cluster bootstrap account password. - :type cluster_bootstrap_account_password: str - :param cluster_operator_account_password: Cluster operator account password. - :type cluster_operator_account_password: str - :param sql_service_account_password: SQL service account password. - :type sql_service_account_password: str + :ivar cluster_bootstrap_account_password: Cluster bootstrap account password. + :vartype cluster_bootstrap_account_password: str + :ivar cluster_operator_account_password: Cluster operator account password. + :vartype cluster_operator_account_password: str + :ivar sql_service_account_password: SQL service account password. + :vartype sql_service_account_password: str """ _attribute_map = { @@ -1150,6 +1396,14 @@ def __init__( sql_service_account_password: Optional[str] = None, **kwargs ): + """ + :keyword cluster_bootstrap_account_password: Cluster bootstrap account password. + :paramtype cluster_bootstrap_account_password: str + :keyword cluster_operator_account_password: Cluster operator account password. + :paramtype cluster_operator_account_password: str + :keyword sql_service_account_password: SQL service account password. + :paramtype sql_service_account_password: str + """ super(WsfcDomainCredentials, self).__init__(**kwargs) self.cluster_bootstrap_account_password = cluster_bootstrap_account_password self.cluster_operator_account_password = cluster_operator_account_password @@ -1159,25 +1413,25 @@ def __init__( class WsfcDomainProfile(msrest.serialization.Model): """Active Directory account details to operate Windows Server Failover Cluster. - :param domain_fqdn: Fully qualified name of the domain. - :type domain_fqdn: str - :param ou_path: Organizational Unit path in which the nodes and cluster will be present. - :type ou_path: str - :param cluster_bootstrap_account: Account name used for creating cluster (at minimum needs + :ivar domain_fqdn: Fully qualified name of the domain. + :vartype domain_fqdn: str + :ivar ou_path: Organizational Unit path in which the nodes and cluster will be present. + :vartype ou_path: str + :ivar cluster_bootstrap_account: Account name used for creating cluster (at minimum needs permissions to 'Create Computer Objects' in domain). - :type cluster_bootstrap_account: str - :param cluster_operator_account: Account name used for operating cluster i.e. will be part of + :vartype cluster_bootstrap_account: str + :ivar cluster_operator_account: Account name used for operating cluster i.e. will be part of administrators group on all the participating virtual machines in the cluster. - :type cluster_operator_account: str - :param sql_service_account: Account name under which SQL service will run on all participating + :vartype cluster_operator_account: str + :ivar sql_service_account: Account name under which SQL service will run on all participating SQL virtual machines in the cluster. - :type sql_service_account: str - :param file_share_witness_path: Optional path for fileshare witness. - :type file_share_witness_path: str - :param storage_account_url: Fully qualified ARM resource id of the witness storage account. - :type storage_account_url: str - :param storage_account_primary_key: Primary key of the witness storage account. - :type storage_account_primary_key: str + :vartype sql_service_account: str + :ivar file_share_witness_path: Optional path for fileshare witness. + :vartype file_share_witness_path: str + :ivar storage_account_url: Fully qualified ARM resource id of the witness storage account. + :vartype storage_account_url: str + :ivar storage_account_primary_key: Primary key of the witness storage account. + :vartype storage_account_primary_key: str """ _attribute_map = { @@ -1204,6 +1458,27 @@ def __init__( storage_account_primary_key: Optional[str] = None, **kwargs ): + """ + :keyword domain_fqdn: Fully qualified name of the domain. + :paramtype domain_fqdn: str + :keyword ou_path: Organizational Unit path in which the nodes and cluster will be present. + :paramtype ou_path: str + :keyword cluster_bootstrap_account: Account name used for creating cluster (at minimum needs + permissions to 'Create Computer Objects' in domain). + :paramtype cluster_bootstrap_account: str + :keyword cluster_operator_account: Account name used for operating cluster i.e. will be part of + administrators group on all the participating virtual machines in the cluster. + :paramtype cluster_operator_account: str + :keyword sql_service_account: Account name under which SQL service will run on all + participating SQL virtual machines in the cluster. + :paramtype sql_service_account: str + :keyword file_share_witness_path: Optional path for fileshare witness. + :paramtype file_share_witness_path: str + :keyword storage_account_url: Fully qualified ARM resource id of the witness storage account. + :paramtype storage_account_url: str + :keyword storage_account_primary_key: Primary key of the witness storage account. + :paramtype storage_account_primary_key: str + """ super(WsfcDomainProfile, self).__init__(**kwargs) self.domain_fqdn = domain_fqdn self.ou_path = ou_path diff --git a/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/models/_sql_virtual_machine_management_client_enums.py b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/models/_sql_virtual_machine_management_client_enums.py index a1090b2b8121..bb0270e84be1 100644 --- a/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/models/_sql_virtual_machine_management_client_enums.py +++ b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/models/_sql_virtual_machine_management_client_enums.py @@ -6,47 +6,32 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta +from enum import Enum from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class BackupScheduleType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class BackupScheduleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Backup schedule type. """ MANUAL = "Manual" AUTOMATED = "Automated" -class ClusterConfiguration(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ClusterConfiguration(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Cluster type. """ DOMAINFUL = "Domainful" -class ClusterManagerType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ClusterManagerType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Type of cluster manager: Windows Server Failover Cluster (WSFC), implied by the scale type of the group and the OS type. """ WSFC = "WSFC" -class ConnectivityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ConnectivityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """SQL Server connectivity option. """ @@ -54,7 +39,7 @@ class ConnectivityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): PRIVATE = "PRIVATE" PUBLIC = "PUBLIC" -class DayOfWeek(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class DayOfWeek(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Day of week to apply the patch on. """ @@ -66,7 +51,7 @@ class DayOfWeek(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): SATURDAY = "Saturday" SUNDAY = "Sunday" -class DiskConfigurationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class DiskConfigurationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Disk configuration to apply to SQL Server. """ @@ -74,7 +59,7 @@ class DiskConfigurationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)) EXTEND = "EXTEND" ADD = "ADD" -class FullBackupFrequencyType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class FullBackupFrequencyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Frequency of full backups. In both cases, full backups begin during the next scheduled time window. """ @@ -82,27 +67,27 @@ class FullBackupFrequencyType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum DAILY = "Daily" WEEKLY = "Weekly" -class IdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The identity type. Set this to 'SystemAssigned' in order to automatically create and assign an Azure Active Directory principal for the resource. """ SYSTEM_ASSIGNED = "SystemAssigned" -class OperationOrigin(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class OperationOrigin(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The intended executor of the operation. """ USER = "user" SYSTEM = "system" -class ScaleType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Scale type. """ HA = "HA" -class SqlImageSku(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SqlImageSku(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """SQL Server edition type. """ @@ -112,7 +97,7 @@ class SqlImageSku(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): ENTERPRISE = "Enterprise" WEB = "Web" -class SqlManagementMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SqlManagementMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """SQL Server Management type. """ @@ -120,7 +105,7 @@ class SqlManagementMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): LIGHT_WEIGHT = "LightWeight" NO_AGENT = "NoAgent" -class SqlServerLicenseType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SqlServerLicenseType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """SQL Server license type. """ @@ -128,14 +113,14 @@ class SqlServerLicenseType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): AHUB = "AHUB" DR = "DR" -class SqlVmGroupImageSku(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SqlVmGroupImageSku(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """SQL image sku. """ DEVELOPER = "Developer" ENTERPRISE = "Enterprise" -class SqlWorkloadType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SqlWorkloadType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """SQL Server workload type. """ @@ -143,7 +128,7 @@ class SqlWorkloadType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): OLTP = "OLTP" DW = "DW" -class StorageWorkloadType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class StorageWorkloadType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Storage workload type. """ diff --git a/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/operations/_availability_group_listeners_operations.py b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/operations/_availability_group_listeners_operations.py index 7f7ec0096f54..88b0eca13e0f 100644 --- a/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/operations/_availability_group_listeners_operations.py +++ b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/operations/_availability_group_listeners_operations.py @@ -5,25 +5,177 @@ # 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_get_request( + resource_group_name: str, + sql_virtual_machine_group_name: str, + availability_group_listener_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2017-03-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/{sqlVirtualMachineGroupName}/availabilityGroupListeners/{availabilityGroupListenerName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "sqlVirtualMachineGroupName": _SERIALIZER.url("sql_virtual_machine_group_name", sql_virtual_machine_group_name, 'str'), + "availabilityGroupListenerName": _SERIALIZER.url("availability_group_listener_name", availability_group_listener_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + sql_virtual_machine_group_name: str, + availability_group_listener_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2017-03-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/{sqlVirtualMachineGroupName}/availabilityGroupListeners/{availabilityGroupListenerName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "sqlVirtualMachineGroupName": _SERIALIZER.url("sql_virtual_machine_group_name", sql_virtual_machine_group_name, 'str'), + "availabilityGroupListenerName": _SERIALIZER.url("availability_group_listener_name", availability_group_listener_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name: str, + sql_virtual_machine_group_name: str, + availability_group_listener_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2017-03-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/{sqlVirtualMachineGroupName}/availabilityGroupListeners/{availabilityGroupListenerName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "sqlVirtualMachineGroupName": _SERIALIZER.url("sql_virtual_machine_group_name", sql_virtual_machine_group_name, 'str'), + "availabilityGroupListenerName": _SERIALIZER.url("availability_group_listener_name", availability_group_listener_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_list_by_group_request( + resource_group_name: str, + sql_virtual_machine_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2017-03-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/{sqlVirtualMachineGroupName}/availabilityGroupListeners') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "sqlVirtualMachineGroupName": _SERIALIZER.url("sql_virtual_machine_group_name", sql_virtual_machine_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class AvailabilityGroupListenersOperations(object): """AvailabilityGroupListenersOperations operations. @@ -47,14 +199,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - sql_virtual_machine_group_name, # type: str - availability_group_listener_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.AvailabilityGroupListener" + resource_group_name: str, + sql_virtual_machine_group_name: str, + availability_group_listener_name: str, + **kwargs: Any + ) -> "_models.AvailabilityGroupListener": """Gets an availability group listener. :param resource_group_name: Name of the resource group that contains the resource. You can @@ -74,28 +226,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-03-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'sqlVirtualMachineGroupName': self._serialize.url("sql_virtual_machine_group_name", sql_virtual_machine_group_name, 'str'), - 'availabilityGroupListenerName': self._serialize.url("availability_group_listener_name", availability_group_listener_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + sql_virtual_machine_group_name=sql_virtual_machine_group_name, + availability_group_listener_name=availability_group_listener_name, + subscription_id=self._config.subscription_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 @@ -109,49 +251,40 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/{sqlVirtualMachineGroupName}/availabilityGroupListeners/{availabilityGroupListenerName}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - sql_virtual_machine_group_name, # type: str - availability_group_listener_name, # type: str - parameters, # type: "_models.AvailabilityGroupListener" - **kwargs # type: Any - ): - # type: (...) -> "_models.AvailabilityGroupListener" + resource_group_name: str, + sql_virtual_machine_group_name: str, + availability_group_listener_name: str, + parameters: "_models.AvailabilityGroupListener", + **kwargs: Any + ) -> "_models.AvailabilityGroupListener": cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilityGroupListener"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-03-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'sqlVirtualMachineGroupName': self._serialize.url("sql_virtual_machine_group_name", sql_virtual_machine_group_name, 'str'), - 'availabilityGroupListenerName': self._serialize.url("availability_group_listener_name", availability_group_listener_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + 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(parameters, 'AvailabilityGroupListener') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + sql_virtual_machine_group_name=sql_virtual_machine_group_name, + availability_group_listener_name=availability_group_listener_name, + subscription_id=self._config.subscription_id, + 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(parameters, 'AvailabilityGroupListener') - 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 @@ -169,17 +302,19 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/{sqlVirtualMachineGroupName}/availabilityGroupListeners/{availabilityGroupListenerName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - sql_virtual_machine_group_name, # type: str - availability_group_listener_name, # type: str - parameters, # type: "_models.AvailabilityGroupListener" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.AvailabilityGroupListener"] + resource_group_name: str, + sql_virtual_machine_group_name: str, + availability_group_listener_name: str, + parameters: "_models.AvailabilityGroupListener", + **kwargs: Any + ) -> LROPoller["_models.AvailabilityGroupListener"]: """Creates or updates an availability group listener. :param resource_group_name: Name of the resource group that contains the resource. You can @@ -193,15 +328,20 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.sqlvirtualmachine.models.AvailabilityGroupListener :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either AvailabilityGroupListener or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sqlvirtualmachine.models.AvailabilityGroupListener] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AvailabilityGroupListener or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sqlvirtualmachine.models.AvailabilityGroupListener] + :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.AvailabilityGroupListener"] lro_delay = kwargs.pop( 'polling_interval', @@ -214,28 +354,21 @@ def begin_create_or_update( sql_virtual_machine_group_name=sql_virtual_machine_group_name, availability_group_listener_name=availability_group_listener_name, parameters=parameters, + 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('AvailabilityGroupListener', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'sqlVirtualMachineGroupName': self._serialize.url("sql_virtual_machine_group_name", sql_virtual_machine_group_name, 'str'), - 'availabilityGroupListenerName': self._serialize.url("availability_group_listener_name", availability_group_listener_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -247,41 +380,33 @@ 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.SqlVirtualMachine/sqlVirtualMachineGroups/{sqlVirtualMachineGroupName}/availabilityGroupListeners/{availabilityGroupListenerName}'} # type: ignore def _delete_initial( self, - resource_group_name, # type: str - sql_virtual_machine_group_name, # type: str - availability_group_listener_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + sql_virtual_machine_group_name: str, + availability_group_listener_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-03-01-preview" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'sqlVirtualMachineGroupName': self._serialize.url("sql_virtual_machine_group_name", sql_virtual_machine_group_name, 'str'), - 'availabilityGroupListenerName': self._serialize.url("availability_group_listener_name", availability_group_listener_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + sql_virtual_machine_group_name=sql_virtual_machine_group_name, + availability_group_listener_name=availability_group_listener_name, + subscription_id=self._config.subscription_id, + 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 @@ -294,14 +419,15 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/{sqlVirtualMachineGroupName}/availabilityGroupListeners/{availabilityGroupListenerName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - sql_virtual_machine_group_name, # type: str - availability_group_listener_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + sql_virtual_machine_group_name: str, + availability_group_listener_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Deletes an availability group listener. :param resource_group_name: Name of the resource group that contains the resource. You can @@ -313,15 +439,17 @@ def begin_delete( :type availability_group_listener_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - 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', @@ -336,22 +464,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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'sqlVirtualMachineGroupName': self._serialize.url("sql_virtual_machine_group_name", sql_virtual_machine_group_name, 'str'), - 'availabilityGroupListenerName': self._serialize.url("availability_group_listener_name", availability_group_listener_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -363,15 +483,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.SqlVirtualMachine/sqlVirtualMachineGroups/{sqlVirtualMachineGroupName}/availabilityGroupListeners/{availabilityGroupListenerName}'} # type: ignore + @distributed_trace def list_by_group( self, - resource_group_name, # type: str - sql_virtual_machine_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AvailabilityGroupListenerListResult"] + resource_group_name: str, + sql_virtual_machine_group_name: str, + **kwargs: Any + ) -> Iterable["_models.AvailabilityGroupListenerListResult"]: """Lists all availability group listeners in a SQL virtual machine group. :param resource_group_name: Name of the resource group that contains the resource. You can @@ -380,8 +501,10 @@ def list_by_group( :param sql_virtual_machine_group_name: Name of the SQL virtual machine group. :type sql_virtual_machine_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 AvailabilityGroupListenerListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sqlvirtualmachine.models.AvailabilityGroupListenerListResult] + :return: An iterator like instance of either AvailabilityGroupListenerListResult or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sqlvirtualmachine.models.AvailabilityGroupListenerListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilityGroupListenerListResult"] @@ -389,36 +512,33 @@ def list_by_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-03-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_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'sqlVirtualMachineGroupName': self._serialize.url("sql_virtual_machine_group_name", sql_virtual_machine_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_group_request( + resource_group_name=resource_group_name, + sql_virtual_machine_group_name=sql_virtual_machine_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_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_group_request( + resource_group_name=resource_group_name, + sql_virtual_machine_group_name=sql_virtual_machine_group_name, + 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('AvailabilityGroupListenerListResult', pipeline_response) + deserialized = self._deserialize("AvailabilityGroupListenerListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -436,6 +556,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/operations/_operations.py b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/operations/_operations.py index 7d40e94d63b4..85e485687e8a 100644 --- a/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/operations/_operations.py +++ b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/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 = "2017-03-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.SqlVirtualMachine/operations') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class Operations(object): """Operations operations. @@ -45,11 +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.OperationListResult"] + **kwargs: Any + ) -> Iterable["_models.OperationListResult"]: """Lists all of the available SQL Rest API operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -62,30 +89,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-03-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('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -103,6 +127,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/operations/_sql_virtual_machine_groups_operations.py b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/operations/_sql_virtual_machine_groups_operations.py index 1b6cde936e1f..9b03dc340e18 100644 --- a/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/operations/_sql_virtual_machine_groups_operations.py +++ b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/operations/_sql_virtual_machine_groups_operations.py @@ -5,25 +5,244 @@ # 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_get_request( + resource_group_name: str, + sql_virtual_machine_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2017-03-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/{sqlVirtualMachineGroupName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "sqlVirtualMachineGroupName": _SERIALIZER.url("sql_virtual_machine_group_name", sql_virtual_machine_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + sql_virtual_machine_group_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2017-03-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/{sqlVirtualMachineGroupName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "sqlVirtualMachineGroupName": _SERIALIZER.url("sql_virtual_machine_group_name", sql_virtual_machine_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name: str, + sql_virtual_machine_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2017-03-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/{sqlVirtualMachineGroupName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "sqlVirtualMachineGroupName": _SERIALIZER.url("sql_virtual_machine_group_name", sql_virtual_machine_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_update_request_initial( + resource_group_name: str, + sql_virtual_machine_group_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2017-03-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/{sqlVirtualMachineGroupName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "sqlVirtualMachineGroupName": _SERIALIZER.url("sql_virtual_machine_group_name", sql_virtual_machine_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_resource_group_request( + resource_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2017-03-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2017-03-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups') + 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 SqlVirtualMachineGroupsOperations(object): """SqlVirtualMachineGroupsOperations operations. @@ -47,13 +266,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - sql_virtual_machine_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SqlVirtualMachineGroup" + resource_group_name: str, + sql_virtual_machine_group_name: str, + **kwargs: Any + ) -> "_models.SqlVirtualMachineGroup": """Gets a SQL virtual machine group. :param resource_group_name: Name of the resource group that contains the resource. You can @@ -71,27 +290,17 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-03-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'sqlVirtualMachineGroupName': self._serialize.url("sql_virtual_machine_group_name", sql_virtual_machine_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + sql_virtual_machine_group_name=sql_virtual_machine_group_name, + subscription_id=self._config.subscription_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 @@ -105,47 +314,38 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/{sqlVirtualMachineGroupName}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - sql_virtual_machine_group_name, # type: str - parameters, # type: "_models.SqlVirtualMachineGroup" - **kwargs # type: Any - ): - # type: (...) -> "_models.SqlVirtualMachineGroup" + resource_group_name: str, + sql_virtual_machine_group_name: str, + parameters: "_models.SqlVirtualMachineGroup", + **kwargs: Any + ) -> "_models.SqlVirtualMachineGroup": cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlVirtualMachineGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-03-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'sqlVirtualMachineGroupName': self._serialize.url("sql_virtual_machine_group_name", sql_virtual_machine_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SqlVirtualMachineGroup') - # 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( + resource_group_name=resource_group_name, + sql_virtual_machine_group_name=sql_virtual_machine_group_name, + subscription_id=self._config.subscription_id, + 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(parameters, 'SqlVirtualMachineGroup') - 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 @@ -163,16 +363,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.SqlVirtualMachine/sqlVirtualMachineGroups/{sqlVirtualMachineGroupName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - sql_virtual_machine_group_name, # type: str - parameters, # type: "_models.SqlVirtualMachineGroup" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.SqlVirtualMachineGroup"] + resource_group_name: str, + sql_virtual_machine_group_name: str, + parameters: "_models.SqlVirtualMachineGroup", + **kwargs: Any + ) -> LROPoller["_models.SqlVirtualMachineGroup"]: """Creates or updates a SQL virtual machine group. :param resource_group_name: Name of the resource group that contains the resource. You can @@ -184,15 +386,20 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.sqlvirtualmachine.models.SqlVirtualMachineGroup :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either SqlVirtualMachineGroup or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sqlvirtualmachine.models.SqlVirtualMachineGroup] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either SqlVirtualMachineGroup or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sqlvirtualmachine.models.SqlVirtualMachineGroup] + :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.SqlVirtualMachineGroup"] lro_delay = kwargs.pop( 'polling_interval', @@ -204,27 +411,21 @@ def begin_create_or_update( resource_group_name=resource_group_name, sql_virtual_machine_group_name=sql_virtual_machine_group_name, parameters=parameters, + 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('SqlVirtualMachineGroup', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'sqlVirtualMachineGroupName': self._serialize.url("sql_virtual_machine_group_name", sql_virtual_machine_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -236,39 +437,31 @@ 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.SqlVirtualMachine/sqlVirtualMachineGroups/{sqlVirtualMachineGroupName}'} # type: ignore def _delete_initial( self, - resource_group_name, # type: str - sql_virtual_machine_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + sql_virtual_machine_group_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-03-01-preview" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'sqlVirtualMachineGroupName': self._serialize.url("sql_virtual_machine_group_name", sql_virtual_machine_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + sql_virtual_machine_group_name=sql_virtual_machine_group_name, + subscription_id=self._config.subscription_id, + 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 @@ -281,13 +474,14 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/{sqlVirtualMachineGroupName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - sql_virtual_machine_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + sql_virtual_machine_group_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Deletes a SQL virtual machine group. :param resource_group_name: Name of the resource group that contains the resource. You can @@ -297,15 +491,17 @@ def begin_delete( :type sql_virtual_machine_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - 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', @@ -319,21 +515,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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'sqlVirtualMachineGroupName': self._serialize.url("sql_virtual_machine_group_name", sql_virtual_machine_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -345,47 +534,37 @@ 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.SqlVirtualMachine/sqlVirtualMachineGroups/{sqlVirtualMachineGroupName}'} # type: ignore def _update_initial( self, - resource_group_name, # type: str - sql_virtual_machine_group_name, # type: str - parameters, # type: "_models.SqlVirtualMachineGroupUpdate" - **kwargs # type: Any - ): - # type: (...) -> "_models.SqlVirtualMachineGroup" + resource_group_name: str, + sql_virtual_machine_group_name: str, + parameters: "_models.SqlVirtualMachineGroupUpdate", + **kwargs: Any + ) -> "_models.SqlVirtualMachineGroup": cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlVirtualMachineGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-03-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'sqlVirtualMachineGroupName': self._serialize.url("sql_virtual_machine_group_name", sql_virtual_machine_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SqlVirtualMachineGroupUpdate') - # 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_update_request_initial( + resource_group_name=resource_group_name, + sql_virtual_machine_group_name=sql_virtual_machine_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._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(parameters, 'SqlVirtualMachineGroupUpdate') - 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 @@ -399,16 +578,18 @@ def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/{sqlVirtualMachineGroupName}'} # type: ignore + + @distributed_trace def begin_update( self, - resource_group_name, # type: str - sql_virtual_machine_group_name, # type: str - parameters, # type: "_models.SqlVirtualMachineGroupUpdate" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.SqlVirtualMachineGroup"] + resource_group_name: str, + sql_virtual_machine_group_name: str, + parameters: "_models.SqlVirtualMachineGroupUpdate", + **kwargs: Any + ) -> LROPoller["_models.SqlVirtualMachineGroup"]: """Updates SQL virtual machine group tags. :param resource_group_name: Name of the resource group that contains the resource. You can @@ -420,15 +601,20 @@ def begin_update( :type parameters: ~azure.mgmt.sqlvirtualmachine.models.SqlVirtualMachineGroupUpdate :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either SqlVirtualMachineGroup or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sqlvirtualmachine.models.SqlVirtualMachineGroup] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either SqlVirtualMachineGroup or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sqlvirtualmachine.models.SqlVirtualMachineGroup] + :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.SqlVirtualMachineGroup"] lro_delay = kwargs.pop( 'polling_interval', @@ -440,27 +626,21 @@ def begin_update( resource_group_name=resource_group_name, sql_virtual_machine_group_name=sql_virtual_machine_group_name, parameters=parameters, + 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('SqlVirtualMachineGroup', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'sqlVirtualMachineGroupName': self._serialize.url("sql_virtual_machine_group_name", sql_virtual_machine_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -472,22 +652,25 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/{sqlVirtualMachineGroupName}'} # type: ignore + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SqlVirtualMachineGroupListResult"] + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.SqlVirtualMachineGroupListResult"]: """Gets all SQL virtual machine groups in a resource group. :param resource_group_name: Name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. :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 SqlVirtualMachineGroupListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sqlvirtualmachine.models.SqlVirtualMachineGroupListResult] + :return: An iterator like instance of either SqlVirtualMachineGroupListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sqlvirtualmachine.models.SqlVirtualMachineGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlVirtualMachineGroupListResult"] @@ -495,35 +678,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-03-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + 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('SqlVirtualMachineGroupListResult', pipeline_response) + deserialized = self._deserialize("SqlVirtualMachineGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -541,21 +720,24 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups'} # type: ignore + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SqlVirtualMachineGroupListResult"] + **kwargs: Any + ) -> Iterable["_models.SqlVirtualMachineGroupListResult"]: """Gets all SQL virtual machine groups in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SqlVirtualMachineGroupListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sqlvirtualmachine.models.SqlVirtualMachineGroupListResult] + :return: An iterator like instance of either SqlVirtualMachineGroupListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sqlvirtualmachine.models.SqlVirtualMachineGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlVirtualMachineGroupListResult"] @@ -563,34 +745,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-03-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + 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('SqlVirtualMachineGroupListResult', pipeline_response) + deserialized = self._deserialize("SqlVirtualMachineGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -608,6 +785,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/operations/_sql_virtual_machines_operations.py b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/operations/_sql_virtual_machines_operations.py index a257ee7d9d57..ed9ebd157195 100644 --- a/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/operations/_sql_virtual_machines_operations.py +++ b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/operations/_sql_virtual_machines_operations.py @@ -5,25 +5,283 @@ # 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_list_by_sql_vm_group_request( + resource_group_name: str, + sql_virtual_machine_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2017-03-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/{sqlVirtualMachineGroupName}/sqlVirtualMachines') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "sqlVirtualMachineGroupName": _SERIALIZER.url("sql_virtual_machine_group_name", sql_virtual_machine_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2017-03-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + sql_virtual_machine_name: str, + subscription_id: str, + *, + expand: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2017-03-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines/{sqlVirtualMachineName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "sqlVirtualMachineName": _SERIALIZER.url("sql_virtual_machine_name", sql_virtual_machine_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + sql_virtual_machine_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2017-03-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines/{sqlVirtualMachineName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "sqlVirtualMachineName": _SERIALIZER.url("sql_virtual_machine_name", sql_virtual_machine_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name: str, + sql_virtual_machine_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2017-03-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines/{sqlVirtualMachineName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "sqlVirtualMachineName": _SERIALIZER.url("sql_virtual_machine_name", sql_virtual_machine_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_update_request_initial( + resource_group_name: str, + sql_virtual_machine_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2017-03-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines/{sqlVirtualMachineName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "sqlVirtualMachineName": _SERIALIZER.url("sql_virtual_machine_name", sql_virtual_machine_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_resource_group_request( + resource_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2017-03-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class SqlVirtualMachinesOperations(object): """SqlVirtualMachinesOperations operations. @@ -47,13 +305,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_sql_vm_group( self, - resource_group_name, # type: str - sql_virtual_machine_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SqlVirtualMachineListResult"] + resource_group_name: str, + sql_virtual_machine_group_name: str, + **kwargs: Any + ) -> Iterable["_models.SqlVirtualMachineListResult"]: """Gets the list of sql virtual machines in a SQL virtual machine group. :param resource_group_name: Name of the resource group that contains the resource. You can @@ -62,8 +320,10 @@ def list_by_sql_vm_group( :param sql_virtual_machine_group_name: Name of the SQL virtual machine group. :type sql_virtual_machine_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 SqlVirtualMachineListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sqlvirtualmachine.models.SqlVirtualMachineListResult] + :return: An iterator like instance of either SqlVirtualMachineListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sqlvirtualmachine.models.SqlVirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlVirtualMachineListResult"] @@ -71,36 +331,33 @@ def list_by_sql_vm_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-03-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_sql_vm_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'sqlVirtualMachineGroupName': self._serialize.url("sql_virtual_machine_group_name", sql_virtual_machine_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_sql_vm_group_request( + resource_group_name=resource_group_name, + sql_virtual_machine_group_name=sql_virtual_machine_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_sql_vm_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_sql_vm_group_request( + resource_group_name=resource_group_name, + sql_virtual_machine_group_name=sql_virtual_machine_group_name, + 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('SqlVirtualMachineListResult', pipeline_response) + deserialized = self._deserialize("SqlVirtualMachineListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -118,21 +375,24 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_sql_vm_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/{sqlVirtualMachineGroupName}/sqlVirtualMachines'} # type: ignore + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SqlVirtualMachineListResult"] + **kwargs: Any + ) -> Iterable["_models.SqlVirtualMachineListResult"]: """Gets all SQL virtual machines in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SqlVirtualMachineListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sqlvirtualmachine.models.SqlVirtualMachineListResult] + :return: An iterator like instance of either SqlVirtualMachineListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sqlvirtualmachine.models.SqlVirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlVirtualMachineListResult"] @@ -140,34 +400,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-03-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + 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('SqlVirtualMachineListResult', pipeline_response) + deserialized = self._deserialize("SqlVirtualMachineListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -185,19 +440,20 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - sql_virtual_machine_name, # type: str - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.SqlVirtualMachine" + resource_group_name: str, + sql_virtual_machine_name: str, + expand: Optional[str] = None, + **kwargs: Any + ) -> "_models.SqlVirtualMachine": """Gets a SQL virtual machine. :param resource_group_name: Name of the resource group that contains the resource. You can @@ -217,29 +473,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-03-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'sqlVirtualMachineName': self._serialize.url("sql_virtual_machine_name", sql_virtual_machine_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - 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( + resource_group_name=resource_group_name, + sql_virtual_machine_name=sql_virtual_machine_name, + subscription_id=self._config.subscription_id, + expand=expand, + 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 @@ -253,47 +498,38 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines/{sqlVirtualMachineName}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - sql_virtual_machine_name, # type: str - parameters, # type: "_models.SqlVirtualMachine" - **kwargs # type: Any - ): - # type: (...) -> "_models.SqlVirtualMachine" + resource_group_name: str, + sql_virtual_machine_name: str, + parameters: "_models.SqlVirtualMachine", + **kwargs: Any + ) -> "_models.SqlVirtualMachine": cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlVirtualMachine"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-03-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'sqlVirtualMachineName': self._serialize.url("sql_virtual_machine_name", sql_virtual_machine_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + 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(parameters, 'SqlVirtualMachine') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + sql_virtual_machine_name=sql_virtual_machine_name, + subscription_id=self._config.subscription_id, + 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(parameters, 'SqlVirtualMachine') - 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 @@ -311,16 +547,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.SqlVirtualMachine/sqlVirtualMachines/{sqlVirtualMachineName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - sql_virtual_machine_name, # type: str - parameters, # type: "_models.SqlVirtualMachine" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.SqlVirtualMachine"] + resource_group_name: str, + sql_virtual_machine_name: str, + parameters: "_models.SqlVirtualMachine", + **kwargs: Any + ) -> LROPoller["_models.SqlVirtualMachine"]: """Creates or updates a SQL virtual machine. :param resource_group_name: Name of the resource group that contains the resource. You can @@ -332,15 +570,19 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.sqlvirtualmachine.models.SqlVirtualMachine :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either SqlVirtualMachine 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 SqlVirtualMachine or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sqlvirtualmachine.models.SqlVirtualMachine] - :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.SqlVirtualMachine"] lro_delay = kwargs.pop( 'polling_interval', @@ -352,27 +594,21 @@ def begin_create_or_update( resource_group_name=resource_group_name, sql_virtual_machine_name=sql_virtual_machine_name, parameters=parameters, + 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('SqlVirtualMachine', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'sqlVirtualMachineName': self._serialize.url("sql_virtual_machine_name", sql_virtual_machine_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -384,39 +620,31 @@ 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.SqlVirtualMachine/sqlVirtualMachines/{sqlVirtualMachineName}'} # type: ignore def _delete_initial( self, - resource_group_name, # type: str - sql_virtual_machine_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + sql_virtual_machine_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-03-01-preview" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'sqlVirtualMachineName': self._serialize.url("sql_virtual_machine_name", sql_virtual_machine_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + sql_virtual_machine_name=sql_virtual_machine_name, + subscription_id=self._config.subscription_id, + 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 @@ -429,13 +657,14 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines/{sqlVirtualMachineName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - sql_virtual_machine_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + sql_virtual_machine_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Deletes a SQL virtual machine. :param resource_group_name: Name of the resource group that contains the resource. You can @@ -445,15 +674,17 @@ def begin_delete( :type sql_virtual_machine_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - 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', @@ -467,21 +698,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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'sqlVirtualMachineName': self._serialize.url("sql_virtual_machine_name", sql_virtual_machine_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -493,47 +717,37 @@ 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.SqlVirtualMachine/sqlVirtualMachines/{sqlVirtualMachineName}'} # type: ignore def _update_initial( self, - resource_group_name, # type: str - sql_virtual_machine_name, # type: str - parameters, # type: "_models.SqlVirtualMachineUpdate" - **kwargs # type: Any - ): - # type: (...) -> "_models.SqlVirtualMachine" + resource_group_name: str, + sql_virtual_machine_name: str, + parameters: "_models.SqlVirtualMachineUpdate", + **kwargs: Any + ) -> "_models.SqlVirtualMachine": cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlVirtualMachine"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-03-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'sqlVirtualMachineName': self._serialize.url("sql_virtual_machine_name", sql_virtual_machine_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SqlVirtualMachineUpdate') - # 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_update_request_initial( + resource_group_name=resource_group_name, + sql_virtual_machine_name=sql_virtual_machine_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._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(parameters, 'SqlVirtualMachineUpdate') - 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 @@ -547,16 +761,18 @@ def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines/{sqlVirtualMachineName}'} # type: ignore + + @distributed_trace def begin_update( self, - resource_group_name, # type: str - sql_virtual_machine_name, # type: str - parameters, # type: "_models.SqlVirtualMachineUpdate" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.SqlVirtualMachine"] + resource_group_name: str, + sql_virtual_machine_name: str, + parameters: "_models.SqlVirtualMachineUpdate", + **kwargs: Any + ) -> LROPoller["_models.SqlVirtualMachine"]: """Updates a SQL virtual machine. :param resource_group_name: Name of the resource group that contains the resource. You can @@ -568,15 +784,19 @@ def begin_update( :type parameters: ~azure.mgmt.sqlvirtualmachine.models.SqlVirtualMachineUpdate :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either SqlVirtualMachine 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 SqlVirtualMachine or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sqlvirtualmachine.models.SqlVirtualMachine] - :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.SqlVirtualMachine"] lro_delay = kwargs.pop( 'polling_interval', @@ -588,27 +808,21 @@ def begin_update( resource_group_name=resource_group_name, sql_virtual_machine_name=sql_virtual_machine_name, parameters=parameters, + 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('SqlVirtualMachine', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'sqlVirtualMachineName': self._serialize.url("sql_virtual_machine_name", sql_virtual_machine_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -620,22 +834,25 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines/{sqlVirtualMachineName}'} # type: ignore + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SqlVirtualMachineListResult"] + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.SqlVirtualMachineListResult"]: """Gets all SQL virtual machines in a resource group. :param resource_group_name: Name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. :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 SqlVirtualMachineListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sqlvirtualmachine.models.SqlVirtualMachineListResult] + :return: An iterator like instance of either SqlVirtualMachineListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sqlvirtualmachine.models.SqlVirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlVirtualMachineListResult"] @@ -643,35 +860,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-03-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + 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('SqlVirtualMachineListResult', pipeline_response) + deserialized = self._deserialize("SqlVirtualMachineListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -689,6 +902,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data )