From 76d4e6dc32b94215d76dee6d151429d7c8ed866b Mon Sep 17 00:00:00 2001 From: PythonSdkPipelines Date: Mon, 8 Aug 2022 09:12:02 +0000 Subject: [PATCH 1/2] code and test --- sdk/rdbms/azure-mgmt-rdbms/CHANGELOG.md | 7 + sdk/rdbms/azure-mgmt-rdbms/_meta.json | 6 +- .../azure/mgmt/rdbms/_version.py | 2 +- .../azure/mgmt/rdbms/mariadb/_version.py | 2 +- .../azure/mgmt/rdbms/mysql/_version.py | 2 +- .../_my_sql_management_client.py | 15 +- .../rdbms/mysql_flexibleservers/_version.py | 2 +- .../aio/_my_sql_management_client.py | 15 +- .../aio/operations/__init__.py | 4 + .../_azure_ad_administrators_operations.py | 483 +++++++++++++ ...vailability_without_location_operations.py | 107 +++ .../mysql_flexibleservers/models/__init__.py | 8 + .../models/_models_py3.py | 276 +++++--- .../models/_my_sql_management_client_enums.py | 10 + .../operations/__init__.py | 4 + .../_azure_ad_administrators_operations.py | 647 ++++++++++++++++++ ...vailability_without_location_operations.py | 151 ++++ .../azure/mgmt/rdbms/postgresql/_version.py | 2 +- .../postgresql_flexibleservers/_version.py | 2 +- 19 files changed, 1657 insertions(+), 88 deletions(-) create mode 100644 sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mysql_flexibleservers/aio/operations/_azure_ad_administrators_operations.py create mode 100644 sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mysql_flexibleservers/aio/operations/_check_name_availability_without_location_operations.py create mode 100644 sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mysql_flexibleservers/operations/_azure_ad_administrators_operations.py create mode 100644 sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mysql_flexibleservers/operations/_check_name_availability_without_location_operations.py diff --git a/sdk/rdbms/azure-mgmt-rdbms/CHANGELOG.md b/sdk/rdbms/azure-mgmt-rdbms/CHANGELOG.md index 99d828f6de8d..81bd3c9e960e 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/CHANGELOG.md +++ b/sdk/rdbms/azure-mgmt-rdbms/CHANGELOG.md @@ -1,5 +1,12 @@ # Release History +## 10.2.0b3 (2022-08-08) + +**Features** + + - Added operation group AzureADAdministratorsOperations + - Added operation group CheckNameAvailabilityWithoutLocationOperations + ## 10.2.0b2 (2022-08-01) **Features** diff --git a/sdk/rdbms/azure-mgmt-rdbms/_meta.json b/sdk/rdbms/azure-mgmt-rdbms/_meta.json index ae55c904f9ae..7f79724060fb 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/_meta.json +++ b/sdk/rdbms/azure-mgmt-rdbms/_meta.json @@ -4,8 +4,8 @@ "@autorest/python@5.16.0", "@autorest/modelerfour@4.19.3" ], - "commit": "2dcad6d6e9a96882eb6d317e7500a94be007a9c6", + "commit": "352507b7909fabb6b6bb3e48b49d188c612c819f", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/postgresql/resource-manager/readme.md --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --python3-only --use=@autorest/python@5.16.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", - "readme": "specification/postgresql/resource-manager/readme.md" + "autorest_command": "autorest specification/mysql/resource-manager/readme.md --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --python3-only --use=@autorest/python@5.16.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", + "readme": "specification/mysql/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/_version.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/_version.py index d1635223267b..473290d92d90 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/_version.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/_version.py @@ -5,4 +5,4 @@ # license information. # -------------------------------------------------------------------------- -VERSION = "10.2.0b2" +VERSION = "10.2.0b3" diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mariadb/_version.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mariadb/_version.py index 904865f36a5c..a172f504a7eb 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mariadb/_version.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mariadb/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "10.2.0b2" +VERSION = "10.2.0b3" diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mysql/_version.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mysql/_version.py index 904865f36a5c..a172f504a7eb 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mysql/_version.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mysql/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "10.2.0b2" +VERSION = "10.2.0b3" diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mysql_flexibleservers/_my_sql_management_client.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mysql_flexibleservers/_my_sql_management_client.py index 1d5b498e7809..7c0dcc425705 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mysql_flexibleservers/_my_sql_management_client.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mysql_flexibleservers/_my_sql_management_client.py @@ -16,7 +16,7 @@ from . import models from ._configuration import MySQLManagementClientConfiguration -from .operations import BackupsOperations, CheckNameAvailabilityOperations, CheckVirtualNetworkSubnetUsageOperations, ConfigurationsOperations, DatabasesOperations, FirewallRulesOperations, GetPrivateDnsZoneSuffixOperations, LocationBasedCapabilitiesOperations, LogFilesOperations, Operations, ReplicasOperations, ServersOperations +from .operations import AzureADAdministratorsOperations, BackupsOperations, CheckNameAvailabilityOperations, CheckNameAvailabilityWithoutLocationOperations, CheckVirtualNetworkSubnetUsageOperations, ConfigurationsOperations, DatabasesOperations, FirewallRulesOperations, GetPrivateDnsZoneSuffixOperations, LocationBasedCapabilitiesOperations, LogFilesOperations, Operations, ReplicasOperations, ServersOperations if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -52,11 +52,18 @@ class MySQLManagementClient: # pylint: disable=too-many-instance-attributes :ivar check_name_availability: CheckNameAvailabilityOperations operations :vartype check_name_availability: azure.mgmt.rdbms.mysql_flexibleservers.operations.CheckNameAvailabilityOperations + :ivar check_name_availability_without_location: CheckNameAvailabilityWithoutLocationOperations + operations + :vartype check_name_availability_without_location: + azure.mgmt.rdbms.mysql_flexibleservers.operations.CheckNameAvailabilityWithoutLocationOperations :ivar get_private_dns_zone_suffix: GetPrivateDnsZoneSuffixOperations operations :vartype get_private_dns_zone_suffix: azure.mgmt.rdbms.mysql_flexibleservers.operations.GetPrivateDnsZoneSuffixOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.rdbms.mysql_flexibleservers.operations.Operations + :ivar azure_ad_administrators: AzureADAdministratorsOperations operations + :vartype azure_ad_administrators: + azure.mgmt.rdbms.mysql_flexibleservers.operations.AzureADAdministratorsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. @@ -114,12 +121,18 @@ def __init__( self.check_name_availability = CheckNameAvailabilityOperations( self._client, self._config, self._serialize, self._deserialize ) + self.check_name_availability_without_location = CheckNameAvailabilityWithoutLocationOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.get_private_dns_zone_suffix = GetPrivateDnsZoneSuffixOperations( self._client, self._config, self._serialize, self._deserialize ) self.operations = Operations( self._client, self._config, self._serialize, self._deserialize ) + self.azure_ad_administrators = AzureADAdministratorsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mysql_flexibleservers/_version.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mysql_flexibleservers/_version.py index 904865f36a5c..a172f504a7eb 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mysql_flexibleservers/_version.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mysql_flexibleservers/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "10.2.0b2" +VERSION = "10.2.0b3" diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mysql_flexibleservers/aio/_my_sql_management_client.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mysql_flexibleservers/aio/_my_sql_management_client.py index a8368d3c7818..a8f9e6ac2e4b 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mysql_flexibleservers/aio/_my_sql_management_client.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mysql_flexibleservers/aio/_my_sql_management_client.py @@ -16,7 +16,7 @@ from .. import models from ._configuration import MySQLManagementClientConfiguration -from .operations import BackupsOperations, CheckNameAvailabilityOperations, CheckVirtualNetworkSubnetUsageOperations, ConfigurationsOperations, DatabasesOperations, FirewallRulesOperations, GetPrivateDnsZoneSuffixOperations, LocationBasedCapabilitiesOperations, LogFilesOperations, Operations, ReplicasOperations, ServersOperations +from .operations import AzureADAdministratorsOperations, BackupsOperations, CheckNameAvailabilityOperations, CheckNameAvailabilityWithoutLocationOperations, CheckVirtualNetworkSubnetUsageOperations, ConfigurationsOperations, DatabasesOperations, FirewallRulesOperations, GetPrivateDnsZoneSuffixOperations, LocationBasedCapabilitiesOperations, LogFilesOperations, Operations, ReplicasOperations, ServersOperations if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -52,11 +52,18 @@ class MySQLManagementClient: # pylint: disable=too-many-instance-attributes :ivar check_name_availability: CheckNameAvailabilityOperations operations :vartype check_name_availability: azure.mgmt.rdbms.mysql_flexibleservers.aio.operations.CheckNameAvailabilityOperations + :ivar check_name_availability_without_location: CheckNameAvailabilityWithoutLocationOperations + operations + :vartype check_name_availability_without_location: + azure.mgmt.rdbms.mysql_flexibleservers.aio.operations.CheckNameAvailabilityWithoutLocationOperations :ivar get_private_dns_zone_suffix: GetPrivateDnsZoneSuffixOperations operations :vartype get_private_dns_zone_suffix: azure.mgmt.rdbms.mysql_flexibleservers.aio.operations.GetPrivateDnsZoneSuffixOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.rdbms.mysql_flexibleservers.aio.operations.Operations + :ivar azure_ad_administrators: AzureADAdministratorsOperations operations + :vartype azure_ad_administrators: + azure.mgmt.rdbms.mysql_flexibleservers.aio.operations.AzureADAdministratorsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. @@ -114,12 +121,18 @@ def __init__( self.check_name_availability = CheckNameAvailabilityOperations( self._client, self._config, self._serialize, self._deserialize ) + self.check_name_availability_without_location = CheckNameAvailabilityWithoutLocationOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.get_private_dns_zone_suffix = GetPrivateDnsZoneSuffixOperations( self._client, self._config, self._serialize, self._deserialize ) self.operations = Operations( self._client, self._config, self._serialize, self._deserialize ) + self.azure_ad_administrators = AzureADAdministratorsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mysql_flexibleservers/aio/operations/__init__.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mysql_flexibleservers/aio/operations/__init__.py index 4243355cdad8..fe672c1663f0 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mysql_flexibleservers/aio/operations/__init__.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mysql_flexibleservers/aio/operations/__init__.py @@ -16,8 +16,10 @@ from ._location_based_capabilities_operations import LocationBasedCapabilitiesOperations from ._check_virtual_network_subnet_usage_operations import CheckVirtualNetworkSubnetUsageOperations from ._check_name_availability_operations import CheckNameAvailabilityOperations +from ._check_name_availability_without_location_operations import CheckNameAvailabilityWithoutLocationOperations from ._get_private_dns_zone_suffix_operations import GetPrivateDnsZoneSuffixOperations from ._operations import Operations +from ._azure_ad_administrators_operations import AzureADAdministratorsOperations from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import @@ -33,8 +35,10 @@ 'LocationBasedCapabilitiesOperations', 'CheckVirtualNetworkSubnetUsageOperations', 'CheckNameAvailabilityOperations', + 'CheckNameAvailabilityWithoutLocationOperations', 'GetPrivateDnsZoneSuffixOperations', 'Operations', + 'AzureADAdministratorsOperations', ] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() \ No newline at end of file diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mysql_flexibleservers/aio/operations/_azure_ad_administrators_operations.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mysql_flexibleservers/aio/operations/_azure_ad_administrators_operations.py new file mode 100644 index 000000000000..ae248d49ef60 --- /dev/null +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mysql_flexibleservers/aio/operations/_azure_ad_administrators_operations.py @@ -0,0 +1,483 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._azure_ad_administrators_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_server_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class AzureADAdministratorsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.rdbms.mysql_flexibleservers.aio.MySQLManagementClient`'s + :attr:`azure_ad_administrators` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + async def _create_or_update_initial( + self, + resource_group_name: str, + server_name: str, + administrator_name: Union[str, "_models.AdministratorName"], + parameters: _models.AzureADAdministrator, + **kwargs: Any + ) -> Optional[_models.AzureADAdministrator]: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.AzureADAdministrator]] + + _json = self._serialize.body(parameters, 'AzureADAdministrator') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + administrator_name=administrator_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('AzureADAdministrator', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('AzureADAdministrator', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/administrators/{administratorName}"} # type: ignore + + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + administrator_name: Union[str, "_models.AdministratorName"], + parameters: _models.AzureADAdministrator, + **kwargs: Any + ) -> AsyncLROPoller[_models.AzureADAdministrator]: + """Creates or updates an existing Azure Active Directory administrator. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param server_name: The name of the server. + :type server_name: str + :param administrator_name: The name of the Azure AD Administrator. + :type administrator_name: str or + ~azure.mgmt.rdbms.mysql_flexibleservers.models.AdministratorName + :param parameters: The required parameters for creating or updating an aad administrator. + :type parameters: ~azure.mgmt.rdbms.mysql_flexibleservers.models.AzureADAdministrator + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AzureADAdministrator or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.rdbms.mysql_flexibleservers.models.AzureADAdministrator] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AzureADAdministrator] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + 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( # type: ignore + resource_group_name=resource_group_name, + server_name=server_name, + administrator_name=administrator_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('AzureADAdministrator', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/administrators/{administratorName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + server_name: str, + administrator_name: Union[str, "_models.AdministratorName"], + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + administrator_name=administrator_name, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/administrators/{administratorName}"} # type: ignore + + + @distributed_trace_async + async def begin_delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + server_name: str, + administrator_name: Union[str, "_models.AdministratorName"], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes an Azure AD Administrator. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param server_name: The name of the server. + :type server_name: str + :param administrator_name: The name of the Azure AD Administrator. + :type administrator_name: str or + ~azure.mgmt.rdbms.mysql_flexibleservers.models.AdministratorName + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + 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( # type: ignore + resource_group_name=resource_group_name, + server_name=server_name, + administrator_name=administrator_name, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/administrators/{administratorName}"} # type: ignore + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + server_name: str, + administrator_name: Union[str, "_models.AdministratorName"], + **kwargs: Any + ) -> _models.AzureADAdministrator: + """Gets information about an azure ad administrator. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param server_name: The name of the server. + :type server_name: str + :param administrator_name: The name of the Azure AD Administrator. + :type administrator_name: str or + ~azure.mgmt.rdbms.mysql_flexibleservers.models.AdministratorName + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AzureADAdministrator, or the result of cls(response) + :rtype: ~azure.mgmt.rdbms.mysql_flexibleservers.models.AzureADAdministrator + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AzureADAdministrator] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + administrator_name=administrator_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('AzureADAdministrator', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/administrators/{administratorName}"} # type: ignore + + + @distributed_trace + def list_by_server( + self, + resource_group_name: str, + server_name: str, + **kwargs: Any + ) -> AsyncIterable[_models.AdministratorListResult]: + """List all the AAD administrators in a given server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param server_name: The name of the server. + :type server_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AdministratorListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.rdbms.mysql_flexibleservers.models.AdministratorListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AdministratorListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_server_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + api_version=api_version, + template_url=self.list_by_server.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_server_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("AdministratorListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_server.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/administrators"} # type: ignore diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mysql_flexibleservers/aio/operations/_check_name_availability_without_location_operations.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mysql_flexibleservers/aio/operations/_check_name_availability_without_location_operations.py new file mode 100644 index 000000000000..f7899ed3de4f --- /dev/null +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mysql_flexibleservers/aio/operations/_check_name_availability_without_location_operations.py @@ -0,0 +1,107 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._check_name_availability_without_location_operations import build_execute_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class CheckNameAvailabilityWithoutLocationOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.rdbms.mysql_flexibleservers.aio.MySQLManagementClient`'s + :attr:`check_name_availability_without_location` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace_async + async def execute( + self, + name_availability_request: _models.NameAvailabilityRequest, + **kwargs: Any + ) -> _models.NameAvailability: + """Check the availability of name for server. + + :param name_availability_request: The required parameters for checking if server name is + available. + :type name_availability_request: + ~azure.mgmt.rdbms.mysql_flexibleservers.models.NameAvailabilityRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: NameAvailability, or the result of cls(response) + :rtype: ~azure.mgmt.rdbms.mysql_flexibleservers.models.NameAvailability + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.NameAvailability] + + _json = self._serialize.body(name_availability_request, 'NameAvailabilityRequest') + + request = build_execute_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.execute.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('NameAvailability', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + execute.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.DBforMySQL/checkNameAvailability"} # type: ignore + diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mysql_flexibleservers/models/__init__.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mysql_flexibleservers/models/__init__.py index 9a4c39bc9526..4aaaec63be05 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mysql_flexibleservers/models/__init__.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mysql_flexibleservers/models/__init__.py @@ -6,6 +6,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from ._models_py3 import AdministratorListResult +from ._models_py3 import AzureADAdministrator from ._models_py3 import Backup from ._models_py3 import CapabilitiesListResult from ._models_py3 import CapabilityProperties @@ -55,6 +57,8 @@ from ._my_sql_management_client_enums import ( + AdministratorName, + AdministratorType, ConfigurationSource, CreateMode, CreatedByType, @@ -75,6 +79,8 @@ from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ + 'AdministratorListResult', + 'AzureADAdministrator', 'Backup', 'CapabilitiesListResult', 'CapabilityProperties', @@ -121,6 +127,8 @@ 'UserAssignedIdentity', 'VirtualNetworkSubnetUsageParameter', 'VirtualNetworkSubnetUsageResult', + 'AdministratorName', + 'AdministratorType', 'ConfigurationSource', 'CreateMode', 'CreatedByType', diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mysql_flexibleservers/models/_models_py3.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mysql_flexibleservers/models/_models_py3.py index 875d84cf47d9..cc2cb6e6b1ae 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mysql_flexibleservers/models/_models_py3.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mysql_flexibleservers/models/_models_py3.py @@ -16,6 +16,193 @@ import __init__ as _models +class AdministratorListResult(msrest.serialization.Model): + """A List of azure ad administrators. + + :ivar value: The list of azure ad administrator of a server. + :vartype value: list[~azure.mgmt.rdbms.mysql_flexibleservers.models.AzureADAdministrator] + :ivar next_link: The link used to get the next page of operations. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[AzureADAdministrator]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["_models.AzureADAdministrator"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: The list of azure ad administrator of a server. + :paramtype value: list[~azure.mgmt.rdbms.mysql_flexibleservers.models.AzureADAdministrator] + :keyword next_link: The link used to get the next page of operations. + :paramtype next_link: str + """ + super(AdministratorListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class Resource(msrest.serialization.Model): + """Common fields that are returned in the response for all Azure Resource Manager resources. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :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): + """The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a location. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :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 AzureADAdministrator(ProxyResource): + """Represents a Administrator. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: The system metadata relating to this resource. + :vartype system_data: ~azure.mgmt.rdbms.mysql_flexibleservers.models.SystemData + :ivar administrator_type: Type of the sever administrator. Known values are: "ActiveDirectory". + :vartype administrator_type: str or + ~azure.mgmt.rdbms.mysql_flexibleservers.models.AdministratorType + :ivar login: Login name of the server administrator. + :vartype login: str + :ivar sid: SID (object ID) of the server administrator. + :vartype sid: str + :ivar tenant_id: Tenant ID of the administrator. + :vartype tenant_id: str + :ivar identity_resource_id: The resource id of the identity used for AAD Authentication. + :vartype identity_resource_id: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'administrator_type': {'key': 'properties.administratorType', 'type': 'str'}, + 'login': {'key': 'properties.login', 'type': 'str'}, + 'sid': {'key': 'properties.sid', 'type': 'str'}, + 'tenant_id': {'key': 'properties.tenantId', 'type': 'str'}, + 'identity_resource_id': {'key': 'properties.identityResourceId', 'type': 'str'}, + } + + def __init__( + self, + *, + administrator_type: Optional[Union[str, "_models.AdministratorType"]] = None, + login: Optional[str] = None, + sid: Optional[str] = None, + tenant_id: Optional[str] = None, + identity_resource_id: Optional[str] = None, + **kwargs + ): + """ + :keyword administrator_type: Type of the sever administrator. Known values are: + "ActiveDirectory". + :paramtype administrator_type: str or + ~azure.mgmt.rdbms.mysql_flexibleservers.models.AdministratorType + :keyword login: Login name of the server administrator. + :paramtype login: str + :keyword sid: SID (object ID) of the server administrator. + :paramtype sid: str + :keyword tenant_id: Tenant ID of the administrator. + :paramtype tenant_id: str + :keyword identity_resource_id: The resource id of the identity used for AAD Authentication. + :paramtype identity_resource_id: str + """ + super(AzureADAdministrator, self).__init__(**kwargs) + self.system_data = None + self.administrator_type = administrator_type + self.login = login + self.sid = sid + self.tenant_id = tenant_id + self.identity_resource_id = identity_resource_id + + class Backup(msrest.serialization.Model): """Storage Profile properties of a server. @@ -137,81 +324,6 @@ def __init__( self.supported_flexible_server_editions = None -class Resource(msrest.serialization.Model): - """Common fields that are returned in the response for all Azure Resource Manager resources. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :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): - """The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a location. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :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 Configuration(ProxyResource): """Represents a Configuration. @@ -524,9 +636,9 @@ class DataEncryption(msrest.serialization.Model): _attribute_map = { 'primary_user_assigned_identity_id': {'key': 'primaryUserAssignedIdentityId', 'type': 'str'}, - 'primary_key_uri': {'key': 'primaryKeyUri', 'type': 'str'}, + 'primary_key_uri': {'key': 'primaryKeyURI', 'type': 'str'}, 'geo_backup_user_assigned_identity_id': {'key': 'geoBackupUserAssignedIdentityId', 'type': 'str'}, - 'geo_backup_key_uri': {'key': 'geoBackupKeyUri', 'type': 'str'}, + 'geo_backup_key_uri': {'key': 'geoBackupKeyURI', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, } @@ -2181,16 +2293,24 @@ class VirtualNetworkSubnetUsageResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. + :ivar location: The location name. + :vartype location: str + :ivar subscription_id: The subscription id. + :vartype subscription_id: str :ivar delegated_subnets_usage: A list of delegated subnet usage. :vartype delegated_subnets_usage: list[~azure.mgmt.rdbms.mysql_flexibleservers.models.DelegatedSubnetUsage] """ _validation = { + 'location': {'readonly': True}, + 'subscription_id': {'readonly': True}, 'delegated_subnets_usage': {'readonly': True}, } _attribute_map = { + 'location': {'key': 'location', 'type': 'str'}, + 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, 'delegated_subnets_usage': {'key': 'delegatedSubnetsUsage', 'type': '[DelegatedSubnetUsage]'}, } @@ -2201,4 +2321,6 @@ def __init__( """ """ super(VirtualNetworkSubnetUsageResult, self).__init__(**kwargs) + self.location = None + self.subscription_id = None self.delegated_subnets_usage = None diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mysql_flexibleservers/models/_my_sql_management_client_enums.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mysql_flexibleservers/models/_my_sql_management_client_enums.py index 3eb53abf51d9..fcd51b19361b 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mysql_flexibleservers/models/_my_sql_management_client_enums.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mysql_flexibleservers/models/_my_sql_management_client_enums.py @@ -10,6 +10,16 @@ from azure.core import CaseInsensitiveEnumMeta +class AdministratorName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + + ACTIVE_DIRECTORY = "ActiveDirectory" + +class AdministratorType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of the sever administrator. + """ + + ACTIVE_DIRECTORY = "ActiveDirectory" + class ConfigurationSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Source of the configuration. """ diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mysql_flexibleservers/operations/__init__.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mysql_flexibleservers/operations/__init__.py index 4243355cdad8..fe672c1663f0 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mysql_flexibleservers/operations/__init__.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mysql_flexibleservers/operations/__init__.py @@ -16,8 +16,10 @@ from ._location_based_capabilities_operations import LocationBasedCapabilitiesOperations from ._check_virtual_network_subnet_usage_operations import CheckVirtualNetworkSubnetUsageOperations from ._check_name_availability_operations import CheckNameAvailabilityOperations +from ._check_name_availability_without_location_operations import CheckNameAvailabilityWithoutLocationOperations from ._get_private_dns_zone_suffix_operations import GetPrivateDnsZoneSuffixOperations from ._operations import Operations +from ._azure_ad_administrators_operations import AzureADAdministratorsOperations from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import @@ -33,8 +35,10 @@ 'LocationBasedCapabilitiesOperations', 'CheckVirtualNetworkSubnetUsageOperations', 'CheckNameAvailabilityOperations', + 'CheckNameAvailabilityWithoutLocationOperations', 'GetPrivateDnsZoneSuffixOperations', 'Operations', + 'AzureADAdministratorsOperations', ] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() \ No newline at end of file diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mysql_flexibleservers/operations/_azure_ad_administrators_operations.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mysql_flexibleservers/operations/_azure_ad_administrators_operations.py new file mode 100644 index 000000000000..1a8e198be00c --- /dev/null +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mysql_flexibleservers/operations/_azure_ad_administrators_operations.py @@ -0,0 +1,647 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_or_update_request_initial( + subscription_id: str, + resource_group_name: str, + server_name: str, + administrator_name: Union[str, "_models.AdministratorName"], + *, + json: Optional[_models.AzureADAdministrator] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/administrators/{administratorName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "administratorName": _SERIALIZER.url("administrator_name", administrator_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + subscription_id: str, + resource_group_name: str, + server_name: str, + administrator_name: Union[str, "_models.AdministratorName"], + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/administrators/{administratorName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "administratorName": _SERIALIZER.url("administrator_name", administrator_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + server_name: str, + administrator_name: Union[str, "_models.AdministratorName"], + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/administrators/{administratorName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + "administratorName": _SERIALIZER.url("administrator_name", administrator_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_by_server_request( + subscription_id: str, + resource_group_name: str, + server_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/administrators") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "serverName": _SERIALIZER.url("server_name", server_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class AzureADAdministratorsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.rdbms.mysql_flexibleservers.MySQLManagementClient`'s + :attr:`azure_ad_administrators` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + def _create_or_update_initial( + self, + resource_group_name: str, + server_name: str, + administrator_name: Union[str, "_models.AdministratorName"], + parameters: _models.AzureADAdministrator, + **kwargs: Any + ) -> Optional[_models.AzureADAdministrator]: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.AzureADAdministrator]] + + _json = self._serialize.body(parameters, 'AzureADAdministrator') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + administrator_name=administrator_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('AzureADAdministrator', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('AzureADAdministrator', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/administrators/{administratorName}"} # type: ignore + + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + administrator_name: Union[str, "_models.AdministratorName"], + parameters: _models.AzureADAdministrator, + **kwargs: Any + ) -> LROPoller[_models.AzureADAdministrator]: + """Creates or updates an existing Azure Active Directory administrator. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param server_name: The name of the server. + :type server_name: str + :param administrator_name: The name of the Azure AD Administrator. + :type administrator_name: str or + ~azure.mgmt.rdbms.mysql_flexibleservers.models.AdministratorName + :param parameters: The required parameters for creating or updating an aad administrator. + :type parameters: ~azure.mgmt.rdbms.mysql_flexibleservers.models.AzureADAdministrator + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AzureADAdministrator or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.rdbms.mysql_flexibleservers.models.AzureADAdministrator] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AzureADAdministrator] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + 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( # type: ignore + resource_group_name=resource_group_name, + server_name=server_name, + administrator_name=administrator_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('AzureADAdministrator', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/administrators/{administratorName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + server_name: str, + administrator_name: Union[str, "_models.AdministratorName"], + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + administrator_name=administrator_name, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/administrators/{administratorName}"} # type: ignore + + + @distributed_trace + def begin_delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + server_name: str, + administrator_name: Union[str, "_models.AdministratorName"], + **kwargs: Any + ) -> LROPoller[None]: + """Deletes an Azure AD Administrator. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param server_name: The name of the server. + :type server_name: str + :param administrator_name: The name of the Azure AD Administrator. + :type administrator_name: str or + ~azure.mgmt.rdbms.mysql_flexibleservers.models.AdministratorName + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + 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( # type: ignore + resource_group_name=resource_group_name, + server_name=server_name, + administrator_name=administrator_name, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/administrators/{administratorName}"} # type: ignore + + @distributed_trace + def get( + self, + resource_group_name: str, + server_name: str, + administrator_name: Union[str, "_models.AdministratorName"], + **kwargs: Any + ) -> _models.AzureADAdministrator: + """Gets information about an azure ad administrator. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param server_name: The name of the server. + :type server_name: str + :param administrator_name: The name of the Azure AD Administrator. + :type administrator_name: str or + ~azure.mgmt.rdbms.mysql_flexibleservers.models.AdministratorName + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AzureADAdministrator, or the result of cls(response) + :rtype: ~azure.mgmt.rdbms.mysql_flexibleservers.models.AzureADAdministrator + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AzureADAdministrator] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + administrator_name=administrator_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('AzureADAdministrator', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/administrators/{administratorName}"} # type: ignore + + + @distributed_trace + def list_by_server( + self, + resource_group_name: str, + server_name: str, + **kwargs: Any + ) -> Iterable[_models.AdministratorListResult]: + """List all the AAD administrators in a given server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param server_name: The name of the server. + :type server_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AdministratorListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.rdbms.mysql_flexibleservers.models.AdministratorListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AdministratorListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_server_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + api_version=api_version, + template_url=self.list_by_server.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_server_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_name=server_name, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("AdministratorListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_server.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/administrators"} # type: ignore diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mysql_flexibleservers/operations/_check_name_availability_without_location_operations.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mysql_flexibleservers/operations/_check_name_availability_without_location_operations.py new file mode 100644 index 000000000000..3cd64fdbaff8 --- /dev/null +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mysql_flexibleservers/operations/_check_name_availability_without_location_operations.py @@ -0,0 +1,151 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_execute_request( + subscription_id: str, + *, + json: Optional[_models.NameAvailabilityRequest] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.DBforMySQL/checkNameAvailability") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + +class CheckNameAvailabilityWithoutLocationOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.rdbms.mysql_flexibleservers.MySQLManagementClient`'s + :attr:`check_name_availability_without_location` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def execute( + self, + name_availability_request: _models.NameAvailabilityRequest, + **kwargs: Any + ) -> _models.NameAvailability: + """Check the availability of name for server. + + :param name_availability_request: The required parameters for checking if server name is + available. + :type name_availability_request: + ~azure.mgmt.rdbms.mysql_flexibleservers.models.NameAvailabilityRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: NameAvailability, or the result of cls(response) + :rtype: ~azure.mgmt.rdbms.mysql_flexibleservers.models.NameAvailability + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.NameAvailability] + + _json = self._serialize.body(name_availability_request, 'NameAvailabilityRequest') + + request = build_execute_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.execute.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('NameAvailability', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + execute.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.DBforMySQL/checkNameAvailability"} # type: ignore + diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql/_version.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql/_version.py index 904865f36a5c..a172f504a7eb 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql/_version.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "10.2.0b2" +VERSION = "10.2.0b3" diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/_version.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/_version.py index 904865f36a5c..a172f504a7eb 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/_version.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "10.2.0b2" +VERSION = "10.2.0b3" From 5b89ba39ee6b28aa09ca1c7457f0bb911145b2cb Mon Sep 17 00:00:00 2001 From: zhenbiao wei <424401670@qq.com> Date: Tue, 9 Aug 2022 09:50:24 +0800 Subject: [PATCH 2/2] Update CHANGELOG.md --- sdk/rdbms/azure-mgmt-rdbms/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/rdbms/azure-mgmt-rdbms/CHANGELOG.md b/sdk/rdbms/azure-mgmt-rdbms/CHANGELOG.md index 81bd3c9e960e..05776b9d82c9 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/CHANGELOG.md +++ b/sdk/rdbms/azure-mgmt-rdbms/CHANGELOG.md @@ -1,6 +1,6 @@ # Release History -## 10.2.0b3 (2022-08-08) +## 10.2.0b3 (2022-08-09) **Features**