diff --git a/sdk/sql/azure-mgmt-sqlvirtualmachine/CHANGELOG.md b/sdk/sql/azure-mgmt-sqlvirtualmachine/CHANGELOG.md new file mode 100644 index 000000000000..578ed6acf479 --- /dev/null +++ b/sdk/sql/azure-mgmt-sqlvirtualmachine/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 0.1.0 (1970-01-01) + +* Initial Release diff --git a/sdk/sql/azure-mgmt-sqlvirtualmachine/MANIFEST.in b/sdk/sql/azure-mgmt-sqlvirtualmachine/MANIFEST.in new file mode 100644 index 000000000000..3a9b6517412b --- /dev/null +++ b/sdk/sql/azure-mgmt-sqlvirtualmachine/MANIFEST.in @@ -0,0 +1,6 @@ +include _meta.json +recursive-include tests *.py *.yaml +include *.md +include azure/__init__.py +include azure/mgmt/__init__.py + diff --git a/sdk/sql/azure-mgmt-sqlvirtualmachine/README.md b/sdk/sql/azure-mgmt-sqlvirtualmachine/README.md new file mode 100644 index 000000000000..624ebd63719d --- /dev/null +++ b/sdk/sql/azure-mgmt-sqlvirtualmachine/README.md @@ -0,0 +1,27 @@ +# Microsoft Azure SDK for Python + +This is the Microsoft Azure MyService Management Client Library. +This package has been tested with Python 2.7, 3.5, 3.6, 3.7 and 3.8. +For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all). + + +# Usage + + +To learn how to use this package, see the [quickstart guide](https://aka.ms/azsdk/python/mgmt) + + + +For docs and references, see [Python SDK References](https://docs.microsoft.com/python/api/overview/azure/) +Code samples for this package can be found at [MyService Management](https://docs.microsoft.com/samples/browse/?languages=python&term=Getting%20started%20-%20Managing&terms=Getting%20started%20-%20Managing) on docs.microsoft.com. +Additional code samples for different Azure services are available at [Samples Repo](https://aka.ms/azsdk/python/mgmt/samples) + + +# Provide Feedback + +If you encounter any bugs or have suggestions, please file an issue in the +[Issues](https://github.com/Azure/azure-sdk-for-python/issues) +section of the project. + + +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-python%2Fazure-mgmt-sqlvirtualmachine%2FREADME.png) diff --git a/sdk/sql/azure-mgmt-sqlvirtualmachine/_meta.json b/sdk/sql/azure-mgmt-sqlvirtualmachine/_meta.json new file mode 100644 index 000000000000..b6cc3968b908 --- /dev/null +++ b/sdk/sql/azure-mgmt-sqlvirtualmachine/_meta.json @@ -0,0 +1,8 @@ +{ + "autorest": "3.4.2", + "use": "@autorest/python@5.6.6", + "commit": "c4b508f6f0290b64fbdd5367d439f8153744984d", + "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.6.6 --version=3.4.2", + "readme": "specification/sqlvirtualmachine/resource-manager/readme.md" +} \ No newline at end of file diff --git a/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/__init__.py b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/__init__.py new file mode 100644 index 000000000000..0260537a02bb --- /dev/null +++ b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/__init__.py @@ -0,0 +1 @@ +__path__ = __import__('pkgutil').extend_path(__path__, __name__) \ No newline at end of file diff --git a/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/__init__.py b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/__init__.py new file mode 100644 index 000000000000..0260537a02bb --- /dev/null +++ b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/__init__.py @@ -0,0 +1 @@ +__path__ = __import__('pkgutil').extend_path(__path__, __name__) \ 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 new file mode 100644 index 000000000000..a04832314d83 --- /dev/null +++ b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/__init__.py @@ -0,0 +1,19 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._sql_virtual_machine_management_client import SqlVirtualMachineManagementClient +from ._version import VERSION + +__version__ = VERSION +__all__ = ['SqlVirtualMachineManagementClient'] + +try: + from ._patch import patch_sdk # type: ignore + patch_sdk() +except ImportError: + pass diff --git a/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/_configuration.py b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/_configuration.py new file mode 100644 index 000000000000..6787072b571c --- /dev/null +++ b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/_configuration.py @@ -0,0 +1,71 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy + +from ._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.credentials import TokenCredential + + +class SqlVirtualMachineManagementClientConfiguration(Configuration): + """Configuration for SqlVirtualMachineManagementClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: Subscription ID that identifies an Azure subscription. + :type subscription_id: str + """ + + def __init__( + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + 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 + self.api_version = "2017-03-01-preview" + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-sqlvirtualmachine/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.BearerTokenCredentialPolicy(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 new file mode 100644 index 000000000000..ee77bb53de2a --- /dev/null +++ b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/_metadata.json @@ -0,0 +1,106 @@ +{ + "chosen_version": "2017-03-01-preview", + "total_api_version_list": ["2017-03-01-preview"], + "client": { + "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, + "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\"]}}}" + }, + "global_parameters": { + "sync": { + "credential": { + "signature": "credential, # type: \"TokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id, # type: str", + "description": "Subscription ID that identifies an Azure subscription.", + "docstring_type": "str", + "required": true + } + }, + "async": { + "credential": { + "signature": "credential: \"AsyncTokenCredential\",", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "Subscription ID that identifies an Azure subscription.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id", + "service_client_specific": { + "sync": { + "api_version": { + "signature": "api_version=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url=None, # type: Optional[str]", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "async": { + "api_version": { + "signature": "api_version: Optional[str] = None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: Optional[str] = None,", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } + }, + "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\"]}}}" + }, + "operation_groups": { + "availability_group_listeners": "AvailabilityGroupListenersOperations", + "operations": "Operations", + "sql_virtual_machine_groups": "SqlVirtualMachineGroupsOperations", + "sql_virtual_machines": "SqlVirtualMachinesOperations" + } +} \ 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 new file mode 100644 index 000000000000..b79a8fcdadfa --- /dev/null +++ b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/_sql_virtual_machine_management_client.py @@ -0,0 +1,104 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import TYPE_CHECKING + +from azure.mgmt.core import ARMPipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.credentials import TokenCredential + from azure.core.pipeline.transport import HttpRequest, HttpResponse + +from ._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): + """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 + :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 + :ivar sql_virtual_machines: SqlVirtualMachinesOperations operations + :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. + """ + + 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) + 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.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 + """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. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.pipeline.transport.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 + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> SqlVirtualMachineManagementClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/_version.py b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/_version.py new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/_version.py @@ -0,0 +1,9 @@ +# 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. +# -------------------------------------------------------------------------- + +VERSION = "1.0.0b1" 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 new file mode 100644 index 000000000000..966ad89f9404 --- /dev/null +++ b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/aio/__init__.py @@ -0,0 +1,10 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._sql_virtual_machine_management_client import SqlVirtualMachineManagementClient +__all__ = ['SqlVirtualMachineManagementClient'] 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 new file mode 100644 index 000000000000..706a78ff51fe --- /dev/null +++ b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/aio/_configuration.py @@ -0,0 +1,67 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy + +from .._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class SqlVirtualMachineManagementClientConfiguration(Configuration): + """Configuration for SqlVirtualMachineManagementClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: Subscription ID that identifies an Azure subscription. + :type subscription_id: str + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + 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 + self.api_version = "2017-03-01-preview" + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-sqlvirtualmachine/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) 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 new file mode 100644 index 000000000000..dbec59145552 --- /dev/null +++ b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/aio/_sql_virtual_machine_management_client.py @@ -0,0 +1,97 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, Optional, TYPE_CHECKING + +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +from ._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): + """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 + :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 + :ivar sql_virtual_machines: SqlVirtualMachinesOperations operations + :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. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: Optional[str] = None, + **kwargs: Any + ) -> None: + if not base_url: + base_url = 'https://management.azure.com' + self._config = SqlVirtualMachineManagementClientConfiguration(credential, 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.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: + """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. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.pipeline.transport.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 + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "SqlVirtualMachineManagementClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/aio/operations/__init__.py b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/aio/operations/__init__.py new file mode 100644 index 000000000000..c54af11a6331 --- /dev/null +++ b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/aio/operations/__init__.py @@ -0,0 +1,19 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._availability_group_listeners_operations import AvailabilityGroupListenersOperations +from ._operations import Operations +from ._sql_virtual_machine_groups_operations import SqlVirtualMachineGroupsOperations +from ._sql_virtual_machines_operations import SqlVirtualMachinesOperations + +__all__ = [ + 'AvailabilityGroupListenersOperations', + 'Operations', + 'SqlVirtualMachineGroupsOperations', + 'SqlVirtualMachinesOperations', +] 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 new file mode 100644 index 000000000000..5f4ffca1647d --- /dev/null +++ b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/aio/operations/_availability_group_listeners_operations.py @@ -0,0 +1,432 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, 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.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class AvailabilityGroupListenersOperations: + """AvailabilityGroupListenersOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.sqlvirtualmachine.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def get( + self, + resource_group_name: str, + sql_virtual_machine_group_name: str, + availability_group_listener_name: str, + **kwargs + ) -> "_models.AvailabilityGroupListener": + """Gets an availability group listener. + + :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 + :param sql_virtual_machine_group_name: Name of the SQL virtual machine group. + :type sql_virtual_machine_group_name: str + :param availability_group_listener_name: Name of the availability group listener. + :type availability_group_listener_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AvailabilityGroupListener, or the result of cls(response) + :rtype: ~azure.mgmt.sqlvirtualmachine.models.AvailabilityGroupListener + :raises: ~azure.core.exceptions.HttpResponseError + """ + 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" + 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 = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('AvailabilityGroupListener', pipeline_response) + + if cls: + 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, + sql_virtual_machine_group_name: str, + availability_group_listener_name: str, + parameters: "_models.AvailabilityGroupListener", + **kwargs + ) -> "_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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, '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 + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('AvailabilityGroupListener', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('AvailabilityGroupListener', pipeline_response) + + if cls: + 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 + + async def begin_create_or_update( + self, + resource_group_name: str, + sql_virtual_machine_group_name: str, + availability_group_listener_name: str, + parameters: "_models.AvailabilityGroupListener", + **kwargs + ) -> AsyncLROPoller["_models.AvailabilityGroupListener"]: + """Creates or updates an availability group listener. + + :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 + :param sql_virtual_machine_group_name: Name of the SQL virtual machine group. + :type sql_virtual_machine_group_name: str + :param availability_group_listener_name: Name of the availability group listener. + :type availability_group_listener_name: str + :param parameters: The availability group listener. + :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: Pass in True if you'd like the AsyncARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :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: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilityGroupListener"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + sql_virtual_machine_group_name=sql_virtual_machine_group_name, + availability_group_listener_name=availability_group_listener_name, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_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) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + 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( + self, + resource_group_name: str, + sql_virtual_machine_group_name: str, + availability_group_listener_name: str, + **kwargs + ) -> 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 = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/{sqlVirtualMachineGroupName}/availabilityGroupListeners/{availabilityGroupListenerName}'} # type: ignore + + async def begin_delete( + self, + resource_group_name: str, + sql_virtual_machine_group_name: str, + availability_group_listener_name: str, + **kwargs + ) -> AsyncLROPoller[None]: + """Deletes an availability group listener. + + :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 + :param sql_virtual_machine_group_name: Name of the SQL virtual machine group. + :type sql_virtual_machine_group_name: str + :param availability_group_listener_name: Name of the availability group listener. + :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: Pass in True if you'd like the AsyncARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + sql_virtual_machine_group_name=sql_virtual_machine_group_name, + availability_group_listener_name=availability_group_listener_name, + 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) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + 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 + + def list_by_group( + self, + resource_group_name: str, + sql_virtual_machine_group_name: str, + **kwargs + ) -> AsyncIterable["_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 + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :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] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilityGroupListenerListResult"] + error_map = { + 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) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('AvailabilityGroupListenerListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/{sqlVirtualMachineGroupName}/availabilityGroupListeners'} # type: ignore 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 new file mode 100644 index 000000000000..0e209b0ff928 --- /dev/null +++ b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/aio/operations/_operations.py @@ -0,0 +1,104 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, 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.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class Operations: + """Operations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.sqlvirtualmachine.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + **kwargs + ) -> AsyncIterable["_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 + :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] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-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 = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('OperationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.SqlVirtualMachine/operations'} # type: ignore 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 new file mode 100644 index 000000000000..a770b8ae9543 --- /dev/null +++ b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/aio/operations/_sql_virtual_machine_groups_operations.py @@ -0,0 +1,601 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, 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.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class SqlVirtualMachineGroupsOperations: + """SqlVirtualMachineGroupsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.sqlvirtualmachine.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def get( + self, + resource_group_name: str, + sql_virtual_machine_group_name: str, + **kwargs + ) -> "_models.SqlVirtualMachineGroup": + """Gets a SQL virtual machine 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 + :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: SqlVirtualMachineGroup, or the result of cls(response) + :rtype: ~azure.mgmt.sqlvirtualmachine.models.SqlVirtualMachineGroup + :raises: ~azure.core.exceptions.HttpResponseError + """ + 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" + 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 = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('SqlVirtualMachineGroup', pipeline_response) + + if cls: + 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, + sql_virtual_machine_group_name: str, + parameters: "_models.SqlVirtualMachineGroup", + **kwargs + ) -> "_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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, '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 + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('SqlVirtualMachineGroup', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('SqlVirtualMachineGroup', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/{sqlVirtualMachineGroupName}'} # type: ignore + + async def begin_create_or_update( + self, + resource_group_name: str, + sql_virtual_machine_group_name: str, + parameters: "_models.SqlVirtualMachineGroup", + **kwargs + ) -> AsyncLROPoller["_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 + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :param sql_virtual_machine_group_name: Name of the SQL virtual machine group. + :type sql_virtual_machine_group_name: str + :param parameters: The SQL virtual machine group. + :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: Pass in True if you'd like the AsyncARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :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: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlVirtualMachineGroup"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + sql_virtual_machine_group_name=sql_virtual_machine_group_name, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_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) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + 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( + self, + resource_group_name: str, + sql_virtual_machine_group_name: str, + **kwargs + ) -> 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 = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/{sqlVirtualMachineGroupName}'} # type: ignore + + async def begin_delete( + self, + resource_group_name: str, + sql_virtual_machine_group_name: str, + **kwargs + ) -> AsyncLROPoller[None]: + """Deletes a SQL virtual machine 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 + :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 + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + sql_virtual_machine_group_name=sql_virtual_machine_group_name, + 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) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + 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( + self, + resource_group_name: str, + sql_virtual_machine_group_name: str, + parameters: "_models.SqlVirtualMachineGroupUpdate", + **kwargs + ) -> "_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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, '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 + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('SqlVirtualMachineGroup', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/{sqlVirtualMachineGroupName}'} # type: ignore + + async def begin_update( + self, + resource_group_name: str, + sql_virtual_machine_group_name: str, + parameters: "_models.SqlVirtualMachineGroupUpdate", + **kwargs + ) -> AsyncLROPoller["_models.SqlVirtualMachineGroup"]: + """Updates SQL virtual machine group tags. + + :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 + :param sql_virtual_machine_group_name: Name of the SQL virtual machine group. + :type sql_virtual_machine_group_name: str + :param parameters: The SQL virtual machine group. + :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: Pass in True if you'd like the AsyncARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :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: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlVirtualMachineGroup"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + sql_virtual_machine_group_name=sql_virtual_machine_group_name, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_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) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + 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 + + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs + ) -> AsyncIterable["_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.async_paging.AsyncItemPaged[~azure.mgmt.sqlvirtualmachine.models.SqlVirtualMachineGroupListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlVirtualMachineGroupListResult"] + error_map = { + 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) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('SqlVirtualMachineGroupListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + 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 + + def list( + self, + **kwargs + ) -> AsyncIterable["_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.async_paging.AsyncItemPaged[~azure.mgmt.sqlvirtualmachine.models.SqlVirtualMachineGroupListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlVirtualMachineGroupListResult"] + error_map = { + 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) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('SqlVirtualMachineGroupListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups'} # type: ignore 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 new file mode 100644 index 000000000000..898e9b1bbb26 --- /dev/null +++ b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/aio/operations/_sql_virtual_machines_operations.py @@ -0,0 +1,681 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, 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.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class SqlVirtualMachinesOperations: + """SqlVirtualMachinesOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.sqlvirtualmachine.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_by_sql_vm_group( + self, + resource_group_name: str, + sql_virtual_machine_group_name: str, + **kwargs + ) -> AsyncIterable["_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 + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :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] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlVirtualMachineListResult"] + error_map = { + 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) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('SqlVirtualMachineListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + 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 + + def list( + self, + **kwargs + ) -> AsyncIterable["_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.async_paging.AsyncItemPaged[~azure.mgmt.sqlvirtualmachine.models.SqlVirtualMachineListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlVirtualMachineListResult"] + error_map = { + 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) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('SqlVirtualMachineListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines'} # type: ignore + + async def get( + self, + resource_group_name: str, + sql_virtual_machine_name: str, + expand: Optional[str] = None, + **kwargs + ) -> "_models.SqlVirtualMachine": + """Gets a SQL virtual machine. + + :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 + :param sql_virtual_machine_name: Name of the SQL virtual machine. + :type sql_virtual_machine_name: str + :param expand: The child resources to include in the response. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SqlVirtualMachine, or the result of cls(response) + :rtype: ~azure.mgmt.sqlvirtualmachine.models.SqlVirtualMachine + :raises: ~azure.core.exceptions.HttpResponseError + """ + 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" + 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 = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('SqlVirtualMachine', pipeline_response) + + if cls: + 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, + sql_virtual_machine_name: str, + parameters: "_models.SqlVirtualMachine", + **kwargs + ) -> "_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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, '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 + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('SqlVirtualMachine', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('SqlVirtualMachine', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines/{sqlVirtualMachineName}'} # type: ignore + + async def begin_create_or_update( + self, + resource_group_name: str, + sql_virtual_machine_name: str, + parameters: "_models.SqlVirtualMachine", + **kwargs + ) -> AsyncLROPoller["_models.SqlVirtualMachine"]: + """Creates or updates a SQL virtual machine. + + :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 + :param sql_virtual_machine_name: Name of the SQL virtual machine. + :type sql_virtual_machine_name: str + :param parameters: The SQL virtual machine. + :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: Pass in True if you'd like the AsyncARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :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: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlVirtualMachine"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + sql_virtual_machine_name=sql_virtual_machine_name, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_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) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + 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( + self, + resource_group_name: str, + sql_virtual_machine_name: str, + **kwargs + ) -> 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 = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines/{sqlVirtualMachineName}'} # type: ignore + + async def begin_delete( + self, + resource_group_name: str, + sql_virtual_machine_name: str, + **kwargs + ) -> AsyncLROPoller[None]: + """Deletes a SQL virtual machine. + + :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 + :param sql_virtual_machine_name: Name of the SQL virtual machine. + :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: Pass in True if you'd like the AsyncARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + sql_virtual_machine_name=sql_virtual_machine_name, + 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) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + 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( + self, + resource_group_name: str, + sql_virtual_machine_name: str, + parameters: "_models.SqlVirtualMachineUpdate", + **kwargs + ) -> "_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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, '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 + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('SqlVirtualMachine', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines/{sqlVirtualMachineName}'} # type: ignore + + async def begin_update( + self, + resource_group_name: str, + sql_virtual_machine_name: str, + parameters: "_models.SqlVirtualMachineUpdate", + **kwargs + ) -> AsyncLROPoller["_models.SqlVirtualMachine"]: + """Updates a SQL virtual machine. + + :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 + :param sql_virtual_machine_name: Name of the SQL virtual machine. + :type sql_virtual_machine_name: str + :param parameters: The SQL virtual machine. + :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: Pass in True if you'd like the AsyncARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :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: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlVirtualMachine"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + sql_virtual_machine_name=sql_virtual_machine_name, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_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) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + 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 + + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs + ) -> AsyncIterable["_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.async_paging.AsyncItemPaged[~azure.mgmt.sqlvirtualmachine.models.SqlVirtualMachineListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlVirtualMachineListResult"] + error_map = { + 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) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('SqlVirtualMachineListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines'} # type: ignore 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 new file mode 100644 index 000000000000..782a8b58942e --- /dev/null +++ b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/models/__init__.py @@ -0,0 +1,135 @@ +# 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. +# -------------------------------------------------------------------------- + +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 ._sql_virtual_machine_management_client_enums import ( + BackupScheduleType, + ClusterConfiguration, + ClusterManagerType, + ConnectivityType, + DayOfWeek, + DiskConfigurationType, + FullBackupFrequencyType, + IdentityType, + OperationOrigin, + ScaleType, + SqlImageSku, + SqlManagementMode, + SqlServerLicenseType, + SqlVmGroupImageSku, + SqlWorkloadType, + StorageWorkloadType, +) + +__all__ = [ + 'AdditionalFeaturesServerConfigurations', + 'AutoBackupSettings', + 'AutoPatchingSettings', + 'AvailabilityGroupListener', + 'AvailabilityGroupListenerListResult', + 'KeyVaultCredentialSettings', + 'LoadBalancerConfiguration', + 'Operation', + 'OperationDisplay', + 'OperationListResult', + 'PrivateIPAddress', + 'ProxyResource', + 'Resource', + 'ResourceIdentity', + 'SQLStorageSettings', + 'ServerConfigurationsManagementSettings', + 'SqlConnectivityUpdateSettings', + 'SqlStorageUpdateSettings', + 'SqlVirtualMachine', + 'SqlVirtualMachineGroup', + 'SqlVirtualMachineGroupListResult', + 'SqlVirtualMachineGroupUpdate', + 'SqlVirtualMachineListResult', + 'SqlVirtualMachineUpdate', + 'SqlWorkloadTypeUpdateSettings', + 'StorageConfigurationSettings', + 'TrackedResource', + 'WsfcDomainCredentials', + 'WsfcDomainProfile', + 'BackupScheduleType', + 'ClusterConfiguration', + 'ClusterManagerType', + 'ConnectivityType', + 'DayOfWeek', + 'DiskConfigurationType', + 'FullBackupFrequencyType', + 'IdentityType', + 'OperationOrigin', + 'ScaleType', + 'SqlImageSku', + 'SqlManagementMode', + 'SqlServerLicenseType', + 'SqlVmGroupImageSku', + 'SqlWorkloadType', + 'StorageWorkloadType', +] 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 new file mode 100644 index 000000000000..d6c89d146ad9 --- /dev/null +++ b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/models/_models.py @@ -0,0 +1,1102 @@ +# 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, str] + """ + + _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': '{str}'}, + } + + 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 new file mode 100644 index 000000000000..766aa98d3732 --- /dev/null +++ b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/models/_models_py3.py @@ -0,0 +1,1215 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Dict, List, Optional, Union + +import msrest.serialization + +from ._sql_virtual_machine_management_client_enums import * + + +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, + *, + is_r_services_enabled: Optional[bool] = None, + **kwargs + ): + super(AdditionalFeaturesServerConfigurations, self).__init__(**kwargs) + self.is_r_services_enabled = is_r_services_enabled + + +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, + *, + enable: Optional[bool] = None, + enable_encryption: Optional[bool] = None, + retention_period: Optional[int] = None, + storage_account_url: Optional[str] = None, + storage_access_key: Optional[str] = None, + password: Optional[str] = None, + backup_system_dbs: Optional[bool] = None, + backup_schedule_type: Optional[Union[str, "BackupScheduleType"]] = None, + full_backup_frequency: Optional[Union[str, "FullBackupFrequencyType"]] = None, + full_backup_start_time: Optional[int] = None, + full_backup_window_hours: Optional[int] = None, + log_backup_frequency: Optional[int] = None, + **kwargs + ): + super(AutoBackupSettings, self).__init__(**kwargs) + self.enable = enable + self.enable_encryption = enable_encryption + self.retention_period = retention_period + self.storage_account_url = storage_account_url + self.storage_access_key = storage_access_key + self.password = password + self.backup_system_dbs = backup_system_dbs + self.backup_schedule_type = backup_schedule_type + self.full_backup_frequency = full_backup_frequency + self.full_backup_start_time = full_backup_start_time + self.full_backup_window_hours = full_backup_window_hours + self.log_backup_frequency = log_backup_frequency + + +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, + *, + enable: Optional[bool] = None, + day_of_week: Optional[Union[str, "DayOfWeek"]] = None, + maintenance_window_starting_hour: Optional[int] = None, + maintenance_window_duration: Optional[int] = None, + **kwargs + ): + super(AutoPatchingSettings, self).__init__(**kwargs) + self.enable = enable + self.day_of_week = day_of_week + self.maintenance_window_starting_hour = maintenance_window_starting_hour + self.maintenance_window_duration = maintenance_window_duration + + +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, + *, + availability_group_name: Optional[str] = None, + load_balancer_configurations: Optional[List["LoadBalancerConfiguration"]] = None, + create_default_availability_group_if_not_exist: Optional[bool] = None, + port: Optional[int] = None, + **kwargs + ): + super(AvailabilityGroupListener, self).__init__(**kwargs) + self.provisioning_state = None + self.availability_group_name = availability_group_name + self.load_balancer_configurations = load_balancer_configurations + self.create_default_availability_group_if_not_exist = create_default_availability_group_if_not_exist + self.port = port + + +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, + *, + enable: Optional[bool] = None, + credential_name: Optional[str] = None, + azure_key_vault_url: Optional[str] = None, + service_principal_name: Optional[str] = None, + service_principal_secret: Optional[str] = None, + **kwargs + ): + super(KeyVaultCredentialSettings, self).__init__(**kwargs) + self.enable = enable + self.credential_name = credential_name + self.azure_key_vault_url = azure_key_vault_url + self.service_principal_name = service_principal_name + self.service_principal_secret = service_principal_secret + + +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, + *, + private_ip_address: Optional["PrivateIPAddress"] = None, + public_ip_address_resource_id: Optional[str] = None, + load_balancer_resource_id: Optional[str] = None, + probe_port: Optional[int] = None, + sql_virtual_machine_instances: Optional[List[str]] = None, + **kwargs + ): + super(LoadBalancerConfiguration, self).__init__(**kwargs) + self.private_ip_address = private_ip_address + self.public_ip_address_resource_id = public_ip_address_resource_id + self.load_balancer_resource_id = load_balancer_resource_id + self.probe_port = probe_port + self.sql_virtual_machine_instances = sql_virtual_machine_instances + + +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, str] + """ + + _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': '{str}'}, + } + + 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, + *, + ip_address: Optional[str] = None, + subnet_resource_id: Optional[str] = None, + **kwargs + ): + super(PrivateIPAddress, self).__init__(**kwargs) + self.ip_address = ip_address + self.subnet_resource_id = subnet_resource_id + + +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, + *, + type: Optional[Union[str, "IdentityType"]] = None, + **kwargs + ): + super(ResourceIdentity, self).__init__(**kwargs) + self.principal_id = None + self.type = type + 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, + *, + sql_connectivity_update_settings: Optional["SqlConnectivityUpdateSettings"] = None, + sql_workload_type_update_settings: Optional["SqlWorkloadTypeUpdateSettings"] = None, + sql_storage_update_settings: Optional["SqlStorageUpdateSettings"] = None, + additional_features_server_configurations: Optional["AdditionalFeaturesServerConfigurations"] = None, + **kwargs + ): + 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 + self.sql_storage_update_settings = sql_storage_update_settings + self.additional_features_server_configurations = additional_features_server_configurations + + +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, + *, + connectivity_type: Optional[Union[str, "ConnectivityType"]] = None, + port: Optional[int] = None, + sql_auth_update_user_name: Optional[str] = None, + sql_auth_update_password: Optional[str] = None, + **kwargs + ): + super(SqlConnectivityUpdateSettings, self).__init__(**kwargs) + self.connectivity_type = connectivity_type + self.port = port + self.sql_auth_update_user_name = sql_auth_update_user_name + self.sql_auth_update_password = sql_auth_update_password + + +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, + *, + luns: Optional[List[int]] = None, + default_file_path: Optional[str] = None, + **kwargs + ): + super(SQLStorageSettings, self).__init__(**kwargs) + self.luns = luns + self.default_file_path = default_file_path + + +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, + *, + disk_count: Optional[int] = None, + starting_device_id: Optional[int] = None, + disk_configuration_type: Optional[Union[str, "DiskConfigurationType"]] = None, + **kwargs + ): + super(SqlStorageUpdateSettings, self).__init__(**kwargs) + self.disk_count = disk_count + self.starting_device_id = starting_device_id + self.disk_configuration_type = disk_configuration_type + + +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, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + super(TrackedResource, self).__init__(**kwargs) + self.location = location + self.tags = tags + + +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, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + identity: Optional["ResourceIdentity"] = None, + virtual_machine_resource_id: Optional[str] = None, + sql_image_offer: Optional[str] = None, + sql_server_license_type: Optional[Union[str, "SqlServerLicenseType"]] = None, + sql_management: Optional[Union[str, "SqlManagementMode"]] = None, + sql_image_sku: Optional[Union[str, "SqlImageSku"]] = None, + sql_virtual_machine_group_resource_id: Optional[str] = None, + wsfc_domain_credentials: Optional["WsfcDomainCredentials"] = None, + auto_patching_settings: Optional["AutoPatchingSettings"] = None, + auto_backup_settings: Optional["AutoBackupSettings"] = None, + key_vault_credential_settings: Optional["KeyVaultCredentialSettings"] = None, + server_configurations_management_settings: Optional["ServerConfigurationsManagementSettings"] = None, + storage_configuration_settings: Optional["StorageConfigurationSettings"] = None, + **kwargs + ): + super(SqlVirtualMachine, self).__init__(location=location, tags=tags, **kwargs) + self.identity = identity + self.virtual_machine_resource_id = virtual_machine_resource_id + self.provisioning_state = None + self.sql_image_offer = sql_image_offer + self.sql_server_license_type = sql_server_license_type + self.sql_management = sql_management + self.sql_image_sku = sql_image_sku + self.sql_virtual_machine_group_resource_id = sql_virtual_machine_group_resource_id + self.wsfc_domain_credentials = wsfc_domain_credentials + self.auto_patching_settings = auto_patching_settings + self.auto_backup_settings = auto_backup_settings + self.key_vault_credential_settings = key_vault_credential_settings + self.server_configurations_management_settings = server_configurations_management_settings + self.storage_configuration_settings = storage_configuration_settings + + +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, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + sql_image_offer: Optional[str] = None, + sql_image_sku: Optional[Union[str, "SqlVmGroupImageSku"]] = None, + wsfc_domain_profile: Optional["WsfcDomainProfile"] = None, + **kwargs + ): + super(SqlVirtualMachineGroup, self).__init__(location=location, tags=tags, **kwargs) + self.provisioning_state = None + self.sql_image_offer = sql_image_offer + self.sql_image_sku = sql_image_sku + self.scale_type = None + self.cluster_manager_type = None + self.cluster_configuration = None + self.wsfc_domain_profile = wsfc_domain_profile + + +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, + *, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + super(SqlVirtualMachineGroupUpdate, self).__init__(**kwargs) + self.tags = tags + + +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, + *, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + super(SqlVirtualMachineUpdate, self).__init__(**kwargs) + self.tags = tags + + +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, + *, + sql_workload_type: Optional[Union[str, "SqlWorkloadType"]] = None, + **kwargs + ): + super(SqlWorkloadTypeUpdateSettings, self).__init__(**kwargs) + self.sql_workload_type = sql_workload_type + + +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, + *, + sql_data_settings: Optional["SQLStorageSettings"] = None, + sql_log_settings: Optional["SQLStorageSettings"] = None, + sql_temp_db_settings: Optional["SQLStorageSettings"] = None, + disk_configuration_type: Optional[Union[str, "DiskConfigurationType"]] = None, + storage_workload_type: Optional[Union[str, "StorageWorkloadType"]] = None, + **kwargs + ): + super(StorageConfigurationSettings, self).__init__(**kwargs) + self.sql_data_settings = sql_data_settings + self.sql_log_settings = sql_log_settings + self.sql_temp_db_settings = sql_temp_db_settings + self.disk_configuration_type = disk_configuration_type + self.storage_workload_type = storage_workload_type + + +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, + *, + cluster_bootstrap_account_password: Optional[str] = None, + cluster_operator_account_password: Optional[str] = None, + sql_service_account_password: Optional[str] = None, + **kwargs + ): + super(WsfcDomainCredentials, self).__init__(**kwargs) + self.cluster_bootstrap_account_password = cluster_bootstrap_account_password + self.cluster_operator_account_password = cluster_operator_account_password + self.sql_service_account_password = sql_service_account_password + + +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, + *, + domain_fqdn: Optional[str] = None, + ou_path: Optional[str] = None, + cluster_bootstrap_account: Optional[str] = None, + cluster_operator_account: Optional[str] = None, + sql_service_account: Optional[str] = None, + file_share_witness_path: Optional[str] = None, + storage_account_url: Optional[str] = None, + storage_account_primary_key: Optional[str] = None, + **kwargs + ): + super(WsfcDomainProfile, self).__init__(**kwargs) + self.domain_fqdn = domain_fqdn + self.ou_path = ou_path + self.cluster_bootstrap_account = cluster_bootstrap_account + self.cluster_operator_account = cluster_operator_account + self.sql_service_account = sql_service_account + self.file_share_witness_path = file_share_witness_path + self.storage_account_url = storage_account_url + self.storage_account_primary_key = storage_account_primary_key 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 new file mode 100644 index 000000000000..a1090b2b8121 --- /dev/null +++ b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/models/_sql_virtual_machine_management_client_enums.py @@ -0,0 +1,152 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from enum import Enum, EnumMeta +from six import with_metaclass + +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)): + """Backup schedule type. + """ + + MANUAL = "Manual" + AUTOMATED = "Automated" + +class ClusterConfiguration(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Cluster type. + """ + + DOMAINFUL = "Domainful" + +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)): + """SQL Server connectivity option. + """ + + LOCAL = "LOCAL" + PRIVATE = "PRIVATE" + PUBLIC = "PUBLIC" + +class DayOfWeek(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Day of week to apply the patch on. + """ + + MONDAY = "Monday" + TUESDAY = "Tuesday" + WEDNESDAY = "Wednesday" + THURSDAY = "Thursday" + FRIDAY = "Friday" + SATURDAY = "Saturday" + SUNDAY = "Sunday" + +class DiskConfigurationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Disk configuration to apply to SQL Server. + """ + + NEW = "NEW" + EXTEND = "EXTEND" + ADD = "ADD" + +class FullBackupFrequencyType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Frequency of full backups. In both cases, full backups begin during the next scheduled time + window. + """ + + DAILY = "Daily" + WEEKLY = "Weekly" + +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)): + """The intended executor of the operation. + """ + + USER = "user" + SYSTEM = "system" + +class ScaleType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Scale type. + """ + + HA = "HA" + +class SqlImageSku(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """SQL Server edition type. + """ + + DEVELOPER = "Developer" + EXPRESS = "Express" + STANDARD = "Standard" + ENTERPRISE = "Enterprise" + WEB = "Web" + +class SqlManagementMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """SQL Server Management type. + """ + + FULL = "Full" + LIGHT_WEIGHT = "LightWeight" + NO_AGENT = "NoAgent" + +class SqlServerLicenseType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """SQL Server license type. + """ + + PAYG = "PAYG" + AHUB = "AHUB" + DR = "DR" + +class SqlVmGroupImageSku(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """SQL image sku. + """ + + DEVELOPER = "Developer" + ENTERPRISE = "Enterprise" + +class SqlWorkloadType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """SQL Server workload type. + """ + + GENERAL = "GENERAL" + OLTP = "OLTP" + DW = "DW" + +class StorageWorkloadType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Storage workload type. + """ + + GENERAL = "GENERAL" + OLTP = "OLTP" + DW = "DW" diff --git a/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/operations/__init__.py b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/operations/__init__.py new file mode 100644 index 000000000000..c54af11a6331 --- /dev/null +++ b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/operations/__init__.py @@ -0,0 +1,19 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._availability_group_listeners_operations import AvailabilityGroupListenersOperations +from ._operations import Operations +from ._sql_virtual_machine_groups_operations import SqlVirtualMachineGroupsOperations +from ._sql_virtual_machines_operations import SqlVirtualMachinesOperations + +__all__ = [ + 'AvailabilityGroupListenersOperations', + 'Operations', + 'SqlVirtualMachineGroupsOperations', + 'SqlVirtualMachinesOperations', +] 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 new file mode 100644 index 000000000000..20153faca297 --- /dev/null +++ b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/operations/_availability_group_listeners_operations.py @@ -0,0 +1,442 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +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.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class AvailabilityGroupListenersOperations(object): + """AvailabilityGroupListenersOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.sqlvirtualmachine.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + 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" + """Gets an availability group listener. + + :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 + :param sql_virtual_machine_group_name: Name of the SQL virtual machine group. + :type sql_virtual_machine_group_name: str + :param availability_group_listener_name: Name of the availability group listener. + :type availability_group_listener_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AvailabilityGroupListener, or the result of cls(response) + :rtype: ~azure.mgmt.sqlvirtualmachine.models.AvailabilityGroupListener + :raises: ~azure.core.exceptions.HttpResponseError + """ + 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" + 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 = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('AvailabilityGroupListener', pipeline_response) + + if cls: + 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" + 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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, '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 + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('AvailabilityGroupListener', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('AvailabilityGroupListener', pipeline_response) + + if cls: + 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 + + 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"] + """Creates or updates an availability group listener. + + :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 + :param sql_virtual_machine_group_name: Name of the SQL virtual machine group. + :type sql_virtual_machine_group_name: str + :param availability_group_listener_name: Name of the availability group listener. + :type availability_group_listener_name: str + :param parameters: The availability group listener. + :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: Pass in True if you'd like the ARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :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: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilityGroupListener"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + sql_virtual_machine_group_name=sql_virtual_machine_group_name, + availability_group_listener_name=availability_group_listener_name, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_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) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + 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 + 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 = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/{sqlVirtualMachineGroupName}/availabilityGroupListeners/{availabilityGroupListenerName}'} # type: ignore + + 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] + """Deletes an availability group listener. + + :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 + :param sql_virtual_machine_group_name: Name of the SQL virtual machine group. + :type sql_virtual_machine_group_name: str + :param availability_group_listener_name: Name of the availability group listener. + :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: Pass in True if you'd like the ARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + sql_virtual_machine_group_name=sql_virtual_machine_group_name, + availability_group_listener_name=availability_group_listener_name, + 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) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + 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 + + def list_by_group( + self, + resource_group_name, # type: str + sql_virtual_machine_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> 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 + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :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] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilityGroupListenerListResult"] + error_map = { + 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) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('AvailabilityGroupListenerListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_by_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/{sqlVirtualMachineGroupName}/availabilityGroupListeners'} # type: ignore 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 new file mode 100644 index 000000000000..7d40e94d63b4 --- /dev/null +++ b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/operations/_operations.py @@ -0,0 +1,109 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +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.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class Operations(object): + """Operations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.sqlvirtualmachine.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + **kwargs # type: Any + ): + # type: (...) -> 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 + :return: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sqlvirtualmachine.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-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 = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('OperationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.SqlVirtualMachine/operations'} # type: ignore 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 new file mode 100644 index 000000000000..4ce2ca75b00f --- /dev/null +++ b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/operations/_sql_virtual_machine_groups_operations.py @@ -0,0 +1,614 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +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.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class SqlVirtualMachineGroupsOperations(object): + """SqlVirtualMachineGroupsOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.sqlvirtualmachine.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def get( + self, + resource_group_name, # type: str + sql_virtual_machine_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.SqlVirtualMachineGroup" + """Gets a SQL virtual machine 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 + :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: SqlVirtualMachineGroup, or the result of cls(response) + :rtype: ~azure.mgmt.sqlvirtualmachine.models.SqlVirtualMachineGroup + :raises: ~azure.core.exceptions.HttpResponseError + """ + 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" + 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 = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('SqlVirtualMachineGroup', pipeline_response) + + if cls: + 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" + 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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, '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 + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('SqlVirtualMachineGroup', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('SqlVirtualMachineGroup', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/{sqlVirtualMachineGroupName}'} # type: ignore + + 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"] + """Creates or updates a SQL virtual machine 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 + :param sql_virtual_machine_group_name: Name of the SQL virtual machine group. + :type sql_virtual_machine_group_name: str + :param parameters: The SQL virtual machine group. + :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: Pass in True if you'd like the ARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :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: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlVirtualMachineGroup"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + sql_virtual_machine_group_name=sql_virtual_machine_group_name, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_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) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + 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 + 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 = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/{sqlVirtualMachineGroupName}'} # type: ignore + + def begin_delete( + self, + resource_group_name, # type: str + sql_virtual_machine_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller[None] + """Deletes a SQL virtual machine 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 + :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 + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: Pass in True if you'd like the ARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + sql_virtual_machine_group_name=sql_virtual_machine_group_name, + 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) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + 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" + 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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, '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 + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('SqlVirtualMachineGroup', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/{sqlVirtualMachineGroupName}'} # type: ignore + + 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"] + """Updates SQL virtual machine group tags. + + :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 + :param sql_virtual_machine_group_name: Name of the SQL virtual machine group. + :type sql_virtual_machine_group_name: str + :param parameters: The SQL virtual machine group. + :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: Pass in True if you'd like the ARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :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: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlVirtualMachineGroup"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + sql_virtual_machine_group_name=sql_virtual_machine_group_name, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_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) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + 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 + + def list_by_resource_group( + self, + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> 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] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlVirtualMachineGroupListResult"] + error_map = { + 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) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('SqlVirtualMachineGroupListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups'} # type: ignore + + def list( + self, + **kwargs # type: Any + ): + # type: (...) -> 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] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlVirtualMachineGroupListResult"] + error_map = { + 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) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('SqlVirtualMachineGroupListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups'} # type: ignore 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 new file mode 100644 index 000000000000..2e89fca3c966 --- /dev/null +++ b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/operations/_sql_virtual_machines_operations.py @@ -0,0 +1,695 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +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.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class SqlVirtualMachinesOperations(object): + """SqlVirtualMachinesOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.sqlvirtualmachine.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + 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"] + """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 + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :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] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlVirtualMachineListResult"] + error_map = { + 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) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('SqlVirtualMachineListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return 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 + + def list( + self, + **kwargs # type: Any + ): + # type: (...) -> 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] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlVirtualMachineListResult"] + error_map = { + 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) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('SqlVirtualMachineListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines'} # type: ignore + + 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" + """Gets a SQL virtual machine. + + :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 + :param sql_virtual_machine_name: Name of the SQL virtual machine. + :type sql_virtual_machine_name: str + :param expand: The child resources to include in the response. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SqlVirtualMachine, or the result of cls(response) + :rtype: ~azure.mgmt.sqlvirtualmachine.models.SqlVirtualMachine + :raises: ~azure.core.exceptions.HttpResponseError + """ + 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" + 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 = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('SqlVirtualMachine', pipeline_response) + + if cls: + 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" + 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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, '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 + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('SqlVirtualMachine', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('SqlVirtualMachine', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines/{sqlVirtualMachineName}'} # type: ignore + + 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"] + """Creates or updates a SQL virtual machine. + + :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 + :param sql_virtual_machine_name: Name of the SQL virtual machine. + :type sql_virtual_machine_name: str + :param parameters: The SQL virtual machine. + :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: Pass in True if you'd like the ARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sqlvirtualmachine.models.SqlVirtualMachine] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlVirtualMachine"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + sql_virtual_machine_name=sql_virtual_machine_name, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_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) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + 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 + 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 = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines/{sqlVirtualMachineName}'} # type: ignore + + def begin_delete( + self, + resource_group_name, # type: str + sql_virtual_machine_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller[None] + """Deletes a SQL virtual machine. + + :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 + :param sql_virtual_machine_name: Name of the SQL virtual machine. + :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: Pass in True if you'd like the ARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + sql_virtual_machine_name=sql_virtual_machine_name, + 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) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + 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" + 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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, '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 + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('SqlVirtualMachine', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines/{sqlVirtualMachineName}'} # type: ignore + + 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"] + """Updates a SQL virtual machine. + + :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 + :param sql_virtual_machine_name: Name of the SQL virtual machine. + :type sql_virtual_machine_name: str + :param parameters: The SQL virtual machine. + :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: Pass in True if you'd like the ARMPolling polling method, + False for no polling, or your own initialized polling object for a personal polling strategy. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sqlvirtualmachine.models.SqlVirtualMachine] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlVirtualMachine"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + sql_virtual_machine_name=sql_virtual_machine_name, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_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) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + 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 + + def list_by_resource_group( + self, + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> 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] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlVirtualMachineListResult"] + error_map = { + 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) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('SqlVirtualMachineListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines'} # type: ignore diff --git a/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/py.typed b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/sql/azure-mgmt-sqlvirtualmachine/azure/mgmt/sqlvirtualmachine/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/sql/azure-mgmt-sqlvirtualmachine/sdk_packaging.toml b/sdk/sql/azure-mgmt-sqlvirtualmachine/sdk_packaging.toml new file mode 100644 index 000000000000..adf000ca686b --- /dev/null +++ b/sdk/sql/azure-mgmt-sqlvirtualmachine/sdk_packaging.toml @@ -0,0 +1,9 @@ +[packaging] +package_name = "azure-mgmt-sqlvirtualmachine" +package_nspkg = "azure-mgmt-nspkg" +package_pprint_name = "MyService Management" +package_doc_id = "" +is_stable = false +is_arm = true +need_msrestazure = false +need_azuremgmtcore = true diff --git a/sdk/sql/azure-mgmt-sqlvirtualmachine/setup.cfg b/sdk/sql/azure-mgmt-sqlvirtualmachine/setup.cfg new file mode 100644 index 000000000000..3c6e79cf31da --- /dev/null +++ b/sdk/sql/azure-mgmt-sqlvirtualmachine/setup.cfg @@ -0,0 +1,2 @@ +[bdist_wheel] +universal=1 diff --git a/sdk/sql/azure-mgmt-sqlvirtualmachine/setup.py b/sdk/sql/azure-mgmt-sqlvirtualmachine/setup.py new file mode 100644 index 000000000000..f7cb66591ab9 --- /dev/null +++ b/sdk/sql/azure-mgmt-sqlvirtualmachine/setup.py @@ -0,0 +1,91 @@ +#!/usr/bin/env python + +#------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +#-------------------------------------------------------------------------- + +import re +import os.path +from io import open +from setuptools import find_packages, setup + +# Change the PACKAGE_NAME only to change folder and different name +PACKAGE_NAME = "azure-mgmt-sqlvirtualmachine" +PACKAGE_PPRINT_NAME = "MyService Management" + +# a-b-c => a/b/c +package_folder_path = PACKAGE_NAME.replace('-', '/') +# a-b-c => a.b.c +namespace_name = PACKAGE_NAME.replace('-', '.') + +# azure v0.x is not compatible with this package +# azure v0.x used to have a __version__ attribute (newer versions don't) +try: + import azure + try: + ver = azure.__version__ + raise Exception( + 'This package is incompatible with azure=={}. '.format(ver) + + 'Uninstall it with "pip uninstall azure".' + ) + except AttributeError: + pass +except ImportError: + pass + +# Version extraction inspired from 'requests' +with open(os.path.join(package_folder_path, 'version.py') + if os.path.exists(os.path.join(package_folder_path, 'version.py')) + else os.path.join(package_folder_path, '_version.py'), 'r') as fd: + version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', + fd.read(), re.MULTILINE).group(1) + +if not version: + raise RuntimeError('Cannot find version information') + +with open('README.md', encoding='utf-8') as f: + readme = f.read() +with open('CHANGELOG.md', encoding='utf-8') as f: + changelog = f.read() + +setup( + name=PACKAGE_NAME, + version=version, + description='Microsoft Azure {} Client Library for Python'.format(PACKAGE_PPRINT_NAME), + long_description=readme + '\n\n' + changelog, + long_description_content_type='text/markdown', + license='MIT License', + author='Microsoft Corporation', + author_email='azpysdkhelp@microsoft.com', + url='https://github.com/Azure/azure-sdk-for-python', + classifiers=[ + 'Development Status :: 4 - Beta', + 'Programming Language :: Python', + 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'License :: OSI Approved :: MIT License', + ], + zip_safe=False, + packages=find_packages(exclude=[ + 'tests', + # Exclude packages that will be covered by PEP420 or nspkg + 'azure', + 'azure.mgmt', + ]), + install_requires=[ + 'msrest>=0.6.21', + 'azure-common~=1.1', + 'azure-mgmt-core>=1.2.0,<2.0.0', + ], + extras_require={ + ":python_version<'3.0'": ['azure-mgmt-nspkg'], + } +)