diff --git a/sdk/sql/azure-mgmt-sql/_meta.json b/sdk/sql/azure-mgmt-sql/_meta.json index ca1773301ac0..b4d38593a04d 100644 --- a/sdk/sql/azure-mgmt-sql/_meta.json +++ b/sdk/sql/azure-mgmt-sql/_meta.json @@ -1,11 +1,11 @@ { - "commit": "fa6609332acece21de44c0bf885cbcb3d87bd01f", + "commit": "bb9b10199d2a51cd2ec404f03beb17a92c647a95", "repository_url": "https://github.com/Azure/azure-rest-api-specs", "autorest": "3.10.2", "use": [ "@autorest/python@6.19.0", "@autorest/modelerfour@4.27.0" ], - "autorest_command": "autorest specification/sql/resource-manager/readme.md --generate-sample=True --generate-test=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --use=@autorest/python@6.19.0 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False", + "autorest_command": "autorest specification/sql/resource-manager/readme.md --generate-sample=True --generate-test=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/python@6.19.0 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False", "readme": "specification/sql/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_version.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_version.py index ccd58626575a..c78e629b6f08 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_version.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "4.0.0b19" +VERSION = "0.9.0" diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_distributed_availability_groups_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_distributed_availability_groups_operations.py index d90d108a9d95..65480382e1f8 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_distributed_availability_groups_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_distributed_availability_groups_operations.py @@ -34,8 +34,10 @@ from ...operations._distributed_availability_groups_operations import ( build_create_or_update_request, build_delete_request, + build_failover_request, build_get_request, build_list_by_instance_request, + build_set_role_request, build_update_request, ) @@ -86,7 +88,7 @@ def list_by_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01-preview")) cls: ClsType[_models.DistributedAvailabilityGroupsListResult] = kwargs.pop("cls", None) error_map: MutableMapping[int, Type[HttpResponseError]] = { @@ -134,7 +136,8 @@ async def get_next(next_link=None): 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response @@ -172,7 +175,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01-preview")) cls: ClsType[_models.DistributedAvailabilityGroup] = kwargs.pop("cls", None) _request = build_get_request( @@ -195,7 +198,8 @@ async def get( 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("DistributedAvailabilityGroup", pipeline_response.http_response) @@ -223,7 +227,7 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) @@ -263,7 +267,8 @@ async def _create_or_update_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -363,7 +368,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DistributedAvailabilityGroup] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -426,7 +431,7 @@ async def _delete_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01-preview")) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( @@ -454,7 +459,8 @@ async def _delete_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -487,7 +493,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01-preview")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -544,7 +550,7 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) @@ -584,7 +590,8 @@ async def _update_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -684,7 +691,7 @@ async def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DistributedAvailabilityGroup] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -728,3 +735,422 @@ def get_long_running_output(pipeline_response): return AsyncLROPoller[_models.DistributedAvailabilityGroup]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) + + async def _failover_initial( + self, + resource_group_name: str, + managed_instance_name: str, + distributed_availability_group_name: str, + parameters: Union[_models.DistributedAvailabilityGroupsFailoverRequest, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DistributedAvailabilityGroupsFailoverRequest") + + _request = build_failover_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + distributed_availability_group_name=distributed_availability_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_failover( + self, + resource_group_name: str, + managed_instance_name: str, + distributed_availability_group_name: str, + parameters: _models.DistributedAvailabilityGroupsFailoverRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DistributedAvailabilityGroup]: + """Performs requested failover type in this distributed availability group. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param distributed_availability_group_name: The distributed availability group name. Required. + :type distributed_availability_group_name: str + :param parameters: The distributed availability group failover request parameters. Required. + :type parameters: ~azure.mgmt.sql.models.DistributedAvailabilityGroupsFailoverRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either DistributedAvailabilityGroup or the + result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.DistributedAvailabilityGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_failover( + self, + resource_group_name: str, + managed_instance_name: str, + distributed_availability_group_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DistributedAvailabilityGroup]: + """Performs requested failover type in this distributed availability group. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param distributed_availability_group_name: The distributed availability group name. Required. + :type distributed_availability_group_name: str + :param parameters: The distributed availability group failover request parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either DistributedAvailabilityGroup or the + result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.DistributedAvailabilityGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_failover( + self, + resource_group_name: str, + managed_instance_name: str, + distributed_availability_group_name: str, + parameters: Union[_models.DistributedAvailabilityGroupsFailoverRequest, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.DistributedAvailabilityGroup]: + """Performs requested failover type in this distributed availability group. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param distributed_availability_group_name: The distributed availability group name. Required. + :type distributed_availability_group_name: str + :param parameters: The distributed availability group failover request parameters. Is either a + DistributedAvailabilityGroupsFailoverRequest type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.sql.models.DistributedAvailabilityGroupsFailoverRequest or + IO[bytes] + :return: An instance of AsyncLROPoller that returns either DistributedAvailabilityGroup or the + result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.DistributedAvailabilityGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DistributedAvailabilityGroup] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._failover_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + distributed_availability_group_name=distributed_availability_group_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DistributedAvailabilityGroup", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.DistributedAvailabilityGroup].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.DistributedAvailabilityGroup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _set_role_initial( + self, + resource_group_name: str, + managed_instance_name: str, + distributed_availability_group_name: str, + parameters: Union[_models.DistributedAvailabilityGroupSetRole, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DistributedAvailabilityGroupSetRole") + + _request = build_set_role_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + distributed_availability_group_name=distributed_availability_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_set_role( + self, + resource_group_name: str, + managed_instance_name: str, + distributed_availability_group_name: str, + parameters: _models.DistributedAvailabilityGroupSetRole, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DistributedAvailabilityGroup]: + """Sets the role for managed instance in a distributed availability group. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param distributed_availability_group_name: The distributed availability group name. Required. + :type distributed_availability_group_name: str + :param parameters: The distributed availability group set role request parameters. Required. + :type parameters: ~azure.mgmt.sql.models.DistributedAvailabilityGroupSetRole + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either DistributedAvailabilityGroup or the + result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.DistributedAvailabilityGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_set_role( + self, + resource_group_name: str, + managed_instance_name: str, + distributed_availability_group_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DistributedAvailabilityGroup]: + """Sets the role for managed instance in a distributed availability group. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param distributed_availability_group_name: The distributed availability group name. Required. + :type distributed_availability_group_name: str + :param parameters: The distributed availability group set role request parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either DistributedAvailabilityGroup or the + result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.DistributedAvailabilityGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_set_role( + self, + resource_group_name: str, + managed_instance_name: str, + distributed_availability_group_name: str, + parameters: Union[_models.DistributedAvailabilityGroupSetRole, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.DistributedAvailabilityGroup]: + """Sets the role for managed instance in a distributed availability group. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param distributed_availability_group_name: The distributed availability group name. Required. + :type distributed_availability_group_name: str + :param parameters: The distributed availability group set role request parameters. Is either a + DistributedAvailabilityGroupSetRole type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.sql.models.DistributedAvailabilityGroupSetRole or IO[bytes] + :return: An instance of AsyncLROPoller that returns either DistributedAvailabilityGroup or the + result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.DistributedAvailabilityGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DistributedAvailabilityGroup] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._set_role_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + distributed_availability_group_name=distributed_availability_group_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DistributedAvailabilityGroup", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.DistributedAvailabilityGroup].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.DistributedAvailabilityGroup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/__init__.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/__init__.py index 0137688191e3..1b89fb810ad7 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/__init__.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/__init__.py @@ -17,6 +17,7 @@ from ._models_py3 import Baseline from ._models_py3 import BaselineAdjustedResult from ._models_py3 import BenchmarkReference +from ._models_py3 import CertificateInfo from ._models_py3 import ChangeLongTermRetentionBackupAccessTierParameters from ._models_py3 import CheckNameAvailabilityRequest from ._models_py3 import CheckNameAvailabilityResponse @@ -66,6 +67,9 @@ from ._models_py3 import DeletedServer from ._models_py3 import DeletedServerListResult from ._models_py3 import DistributedAvailabilityGroup +from ._models_py3 import DistributedAvailabilityGroupDatabase +from ._models_py3 import DistributedAvailabilityGroupSetRole +from ._models_py3 import DistributedAvailabilityGroupsFailoverRequest from ._models_py3 import DistributedAvailabilityGroupsListResult from ._models_py3 import EditionCapability from ._models_py3 import ElasticPool @@ -473,6 +477,8 @@ from ._sql_management_client_enums import ExternalGovernanceStatus from ._sql_management_client_enums import FailoverGroupDatabasesSecondaryType from ._sql_management_client_enums import FailoverGroupReplicationRole +from ._sql_management_client_enums import FailoverModeType +from ._sql_management_client_enums import FailoverType from ._sql_management_client_enums import FreeLimitExhaustionBehavior from ._sql_management_client_enums import FreemiumType from ._sql_management_client_enums import GeoBackupPolicyName @@ -483,6 +489,7 @@ from ._sql_management_client_enums import ImplementationMethod from ._sql_management_client_enums import InstanceFailoverGroupReplicationRole from ._sql_management_client_enums import InstancePoolLicenseType +from ._sql_management_client_enums import InstanceRole from ._sql_management_client_enums import IsRetryable from ._sql_management_client_enums import JobAgentState from ._sql_management_client_enums import JobExecutionLifecycle @@ -494,6 +501,7 @@ from ._sql_management_client_enums import JobTargetType from ._sql_management_client_enums import LedgerDigestUploadsName from ._sql_management_client_enums import LedgerDigestUploadsState +from ._sql_management_client_enums import LinkRole from ._sql_management_client_enums import LogSizeUnit from ._sql_management_client_enums import LongTermRetentionPolicyName from ._sql_management_client_enums import ManagedDatabaseCreateMode @@ -530,13 +538,16 @@ from ._sql_management_client_enums import RecommendedActionCurrentState from ._sql_management_client_enums import RecommendedActionInitiatedBy from ._sql_management_client_enums import RecommendedSensitivityLabelUpdateKind +from ._sql_management_client_enums import ReplicaConnectedState +from ._sql_management_client_enums import ReplicaSynchronizationHealth from ._sql_management_client_enums import ReplicaType from ._sql_management_client_enums import ReplicationLinkType -from ._sql_management_client_enums import ReplicationMode +from ._sql_management_client_enums import ReplicationModeType from ._sql_management_client_enums import ReplicationRole from ._sql_management_client_enums import ReplicationState from ._sql_management_client_enums import RestoreDetailsName from ._sql_management_client_enums import RestorePointType +from ._sql_management_client_enums import RoleChangeType from ._sql_management_client_enums import RuleSeverity from ._sql_management_client_enums import RuleStatus from ._sql_management_client_enums import RuleType @@ -547,6 +558,7 @@ from ._sql_management_client_enums import SecurityAlertPolicyState from ._sql_management_client_enums import SecurityAlertsPolicyState from ._sql_management_client_enums import SecurityEventType +from ._sql_management_client_enums import SeedingModeType from ._sql_management_client_enums import SensitivityLabelRank from ._sql_management_client_enums import SensitivityLabelSource from ._sql_management_client_enums import SensitivityLabelUpdateKind @@ -601,6 +613,7 @@ "Baseline", "BaselineAdjustedResult", "BenchmarkReference", + "CertificateInfo", "ChangeLongTermRetentionBackupAccessTierParameters", "CheckNameAvailabilityRequest", "CheckNameAvailabilityResponse", @@ -650,6 +663,9 @@ "DeletedServer", "DeletedServerListResult", "DistributedAvailabilityGroup", + "DistributedAvailabilityGroupDatabase", + "DistributedAvailabilityGroupSetRole", + "DistributedAvailabilityGroupsFailoverRequest", "DistributedAvailabilityGroupsListResult", "EditionCapability", "ElasticPool", @@ -1056,6 +1072,8 @@ "ExternalGovernanceStatus", "FailoverGroupDatabasesSecondaryType", "FailoverGroupReplicationRole", + "FailoverModeType", + "FailoverType", "FreeLimitExhaustionBehavior", "FreemiumType", "GeoBackupPolicyName", @@ -1066,6 +1084,7 @@ "ImplementationMethod", "InstanceFailoverGroupReplicationRole", "InstancePoolLicenseType", + "InstanceRole", "IsRetryable", "JobAgentState", "JobExecutionLifecycle", @@ -1077,6 +1096,7 @@ "JobTargetType", "LedgerDigestUploadsName", "LedgerDigestUploadsState", + "LinkRole", "LogSizeUnit", "LongTermRetentionPolicyName", "ManagedDatabaseCreateMode", @@ -1113,13 +1133,16 @@ "RecommendedActionCurrentState", "RecommendedActionInitiatedBy", "RecommendedSensitivityLabelUpdateKind", + "ReplicaConnectedState", + "ReplicaSynchronizationHealth", "ReplicaType", "ReplicationLinkType", - "ReplicationMode", + "ReplicationModeType", "ReplicationRole", "ReplicationState", "RestoreDetailsName", "RestorePointType", + "RoleChangeType", "RuleSeverity", "RuleStatus", "RuleType", @@ -1130,6 +1153,7 @@ "SecurityAlertPolicyState", "SecurityAlertsPolicyState", "SecurityEventType", + "SeedingModeType", "SensitivityLabelRank", "SensitivityLabelSource", "SensitivityLabelUpdateKind", diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/_models_py3.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/_models_py3.py index 23ddb6a0f209..d7ffcf8b85ed 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/_models_py3.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/_models_py3.py @@ -528,6 +528,34 @@ def __init__(self, **kwargs: Any) -> None: self.reference = None +class CertificateInfo(_serialization.Model): + """Certificate information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar certificate_name: The certificate name. + :vartype certificate_name: str + :ivar expiry_date: The certificate expiry date. + :vartype expiry_date: ~datetime.datetime + """ + + _validation = { + "certificate_name": {"readonly": True}, + "expiry_date": {"readonly": True}, + } + + _attribute_map = { + "certificate_name": {"key": "certificateName", "type": "str"}, + "expiry_date": {"key": "expiryDate", "type": "iso-8601"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.certificate_name = None + self.expiry_date = None + + class ChangeLongTermRetentionBackupAccessTierParameters(_serialization.Model): # pylint: disable=name-too-long """Contains the information necessary to change long term retention backup access tier and related operation mode. @@ -4083,90 +4111,309 @@ class DistributedAvailabilityGroup(ProxyResource): # pylint: disable=too-many-i :vartype name: str :ivar type: Resource type. :vartype type: str - :ivar target_database: The name of the target database. - :vartype target_database: str - :ivar source_endpoint: The source endpoint. - :vartype source_endpoint: str - :ivar primary_availability_group_name: The primary availability group name. - :vartype primary_availability_group_name: str - :ivar secondary_availability_group_name: The secondary availability group name. - :vartype secondary_availability_group_name: str - :ivar replication_mode: The replication mode of a distributed availability group. Parameter - will be ignored during link creation. Known values are: "Async", "Sync", and "Async". - :vartype replication_mode: str or ~azure.mgmt.sql.models.ReplicationMode - :ivar distributed_availability_group_id: The distributed availability group id. + :ivar distributed_availability_group_name: Name of the distributed availability group. + :vartype distributed_availability_group_name: str + :ivar distributed_availability_group_id: ID of the distributed availability group. :vartype distributed_availability_group_id: str - :ivar source_replica_id: The source replica id. - :vartype source_replica_id: str - :ivar target_replica_id: The target replica id. - :vartype target_replica_id: str - :ivar link_state: The link state. - :vartype link_state: str - :ivar last_hardened_lsn: The last hardened lsn. - :vartype last_hardened_lsn: str + :ivar replication_mode: Replication mode of the link. Known values are: "Async", "Sync", and + "Async". + :vartype replication_mode: str or ~azure.mgmt.sql.models.ReplicationModeType + :ivar partner_link_role: SQL server side link role. Known values are: "Primary" and + "Secondary". + :vartype partner_link_role: str or ~azure.mgmt.sql.models.LinkRole + :ivar partner_availability_group_name: SQL server side availability group name. + :vartype partner_availability_group_name: str + :ivar partner_endpoint: SQL server side endpoint - IP or DNS resolvable name. + :vartype partner_endpoint: str + :ivar instance_link_role: Managed instance side link role. Known values are: "Primary" and + "Secondary". + :vartype instance_link_role: str or ~azure.mgmt.sql.models.LinkRole + :ivar instance_availability_group_name: Managed instance side availability group name. + :vartype instance_availability_group_name: str + :ivar failover_mode: The link failover mode - can be Manual if intended to be used for two-way + failover with a supported SQL Server, or None for one-way failover to Azure. Known values are: + "None" and "Manual". + :vartype failover_mode: str or ~azure.mgmt.sql.models.FailoverModeType + :ivar seeding_mode: Database seeding mode – can be Automatic (default), or Manual for supported + scenarios. Known values are: "Automatic" and "Manual". + :vartype seeding_mode: str or ~azure.mgmt.sql.models.SeedingModeType + :ivar databases: Databases in the distributed availability group. + :vartype databases: list[~azure.mgmt.sql.models.DistributedAvailabilityGroupDatabase] """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, + "distributed_availability_group_name": {"readonly": True}, "distributed_availability_group_id": {"readonly": True}, - "source_replica_id": {"readonly": True}, - "target_replica_id": {"readonly": True}, - "link_state": {"readonly": True}, - "last_hardened_lsn": {"readonly": True}, + "partner_link_role": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, - "target_database": {"key": "properties.targetDatabase", "type": "str"}, - "source_endpoint": {"key": "properties.sourceEndpoint", "type": "str"}, - "primary_availability_group_name": {"key": "properties.primaryAvailabilityGroupName", "type": "str"}, - "secondary_availability_group_name": {"key": "properties.secondaryAvailabilityGroupName", "type": "str"}, - "replication_mode": {"key": "properties.replicationMode", "type": "str"}, + "distributed_availability_group_name": {"key": "properties.distributedAvailabilityGroupName", "type": "str"}, "distributed_availability_group_id": {"key": "properties.distributedAvailabilityGroupId", "type": "str"}, - "source_replica_id": {"key": "properties.sourceReplicaId", "type": "str"}, - "target_replica_id": {"key": "properties.targetReplicaId", "type": "str"}, - "link_state": {"key": "properties.linkState", "type": "str"}, - "last_hardened_lsn": {"key": "properties.lastHardenedLsn", "type": "str"}, + "replication_mode": {"key": "properties.replicationMode", "type": "str"}, + "partner_link_role": {"key": "properties.partnerLinkRole", "type": "str"}, + "partner_availability_group_name": {"key": "properties.partnerAvailabilityGroupName", "type": "str"}, + "partner_endpoint": {"key": "properties.partnerEndpoint", "type": "str"}, + "instance_link_role": {"key": "properties.instanceLinkRole", "type": "str"}, + "instance_availability_group_name": {"key": "properties.instanceAvailabilityGroupName", "type": "str"}, + "failover_mode": {"key": "properties.failoverMode", "type": "str"}, + "seeding_mode": {"key": "properties.seedingMode", "type": "str"}, + "databases": {"key": "properties.databases", "type": "[DistributedAvailabilityGroupDatabase]"}, } def __init__( self, *, - target_database: Optional[str] = None, - source_endpoint: Optional[str] = None, - primary_availability_group_name: Optional[str] = None, - secondary_availability_group_name: Optional[str] = None, - replication_mode: Optional[Union[str, "_models.ReplicationMode"]] = None, + replication_mode: Optional[Union[str, "_models.ReplicationModeType"]] = None, + partner_availability_group_name: Optional[str] = None, + partner_endpoint: Optional[str] = None, + instance_link_role: Optional[Union[str, "_models.LinkRole"]] = None, + instance_availability_group_name: Optional[str] = None, + failover_mode: Optional[Union[str, "_models.FailoverModeType"]] = None, + seeding_mode: Optional[Union[str, "_models.SeedingModeType"]] = None, + databases: Optional[List["_models.DistributedAvailabilityGroupDatabase"]] = None, **kwargs: Any ) -> None: """ - :keyword target_database: The name of the target database. - :paramtype target_database: str - :keyword source_endpoint: The source endpoint. - :paramtype source_endpoint: str - :keyword primary_availability_group_name: The primary availability group name. - :paramtype primary_availability_group_name: str - :keyword secondary_availability_group_name: The secondary availability group name. - :paramtype secondary_availability_group_name: str - :keyword replication_mode: The replication mode of a distributed availability group. Parameter - will be ignored during link creation. Known values are: "Async", "Sync", and "Async". - :paramtype replication_mode: str or ~azure.mgmt.sql.models.ReplicationMode - """ - super().__init__(**kwargs) - self.target_database = target_database - self.source_endpoint = source_endpoint - self.primary_availability_group_name = primary_availability_group_name - self.secondary_availability_group_name = secondary_availability_group_name - self.replication_mode = replication_mode + :keyword replication_mode: Replication mode of the link. Known values are: "Async", "Sync", and + "Async". + :paramtype replication_mode: str or ~azure.mgmt.sql.models.ReplicationModeType + :keyword partner_availability_group_name: SQL server side availability group name. + :paramtype partner_availability_group_name: str + :keyword partner_endpoint: SQL server side endpoint - IP or DNS resolvable name. + :paramtype partner_endpoint: str + :keyword instance_link_role: Managed instance side link role. Known values are: "Primary" and + "Secondary". + :paramtype instance_link_role: str or ~azure.mgmt.sql.models.LinkRole + :keyword instance_availability_group_name: Managed instance side availability group name. + :paramtype instance_availability_group_name: str + :keyword failover_mode: The link failover mode - can be Manual if intended to be used for + two-way failover with a supported SQL Server, or None for one-way failover to Azure. Known + values are: "None" and "Manual". + :paramtype failover_mode: str or ~azure.mgmt.sql.models.FailoverModeType + :keyword seeding_mode: Database seeding mode – can be Automatic (default), or Manual for + supported scenarios. Known values are: "Automatic" and "Manual". + :paramtype seeding_mode: str or ~azure.mgmt.sql.models.SeedingModeType + :keyword databases: Databases in the distributed availability group. + :paramtype databases: list[~azure.mgmt.sql.models.DistributedAvailabilityGroupDatabase] + """ + super().__init__(**kwargs) + self.distributed_availability_group_name = None self.distributed_availability_group_id = None - self.source_replica_id = None - self.target_replica_id = None - self.link_state = None + self.replication_mode = replication_mode + self.partner_link_role = None + self.partner_availability_group_name = partner_availability_group_name + self.partner_endpoint = partner_endpoint + self.instance_link_role = instance_link_role + self.instance_availability_group_name = instance_availability_group_name + self.failover_mode = failover_mode + self.seeding_mode = seeding_mode + self.databases = databases + + +class DistributedAvailabilityGroupDatabase(_serialization.Model): # pylint: disable=too-many-instance-attributes + """Database specific information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar database_name: The name of the database in link. + :vartype database_name: str + :ivar instance_replica_id: Managed instance replica id. + :vartype instance_replica_id: str + :ivar partner_replica_id: SQL server replica id. + :vartype partner_replica_id: str + :ivar replica_state: Current link state. + :vartype replica_state: str + :ivar seeding_progress: Seeding progress. + :vartype seeding_progress: str + :ivar synchronization_health: Link health state. Known values are: "NOT_HEALTHY", + "PARTIALLY_HEALTHY", and "HEALTHY". + :vartype synchronization_health: str or ~azure.mgmt.sql.models.ReplicaSynchronizationHealth + :ivar connected_state: Link connected state. Known values are: "DISCONNECTED" and "CONNECTED". + :vartype connected_state: str or ~azure.mgmt.sql.models.ReplicaConnectedState + :ivar last_received_lsn: Last received LSN. + :vartype last_received_lsn: str + :ivar last_received_time: Last received LSN time. + :vartype last_received_time: ~datetime.datetime + :ivar last_sent_lsn: Last sent LSN. + :vartype last_sent_lsn: str + :ivar last_sent_time: Last sent LSN time. + :vartype last_sent_time: ~datetime.datetime + :ivar last_commit_lsn: Last commit LSN. + :vartype last_commit_lsn: str + :ivar last_commit_time: Last commit LSN time. + :vartype last_commit_time: ~datetime.datetime + :ivar last_hardened_lsn: Last hardened LSN. + :vartype last_hardened_lsn: str + :ivar last_hardened_time: Last hardened LSN time. + :vartype last_hardened_time: ~datetime.datetime + :ivar last_backup_lsn: Last backup LSN. + :vartype last_backup_lsn: str + :ivar last_backup_time: Last backup LSN time. + :vartype last_backup_time: ~datetime.datetime + :ivar most_recent_link_error: The most recent link connection error description. + :vartype most_recent_link_error: str + :ivar partner_auth_cert_validity: SQL server certificate validity. + :vartype partner_auth_cert_validity: ~azure.mgmt.sql.models.CertificateInfo + :ivar instance_send_replication_lag_seconds: Replication lag when Managed Instance link side is + primary. + :vartype instance_send_replication_lag_seconds: int + :ivar instance_redo_replication_lag_seconds: Redo lag when Managed Instance link side is + primary. + :vartype instance_redo_replication_lag_seconds: int + """ + + _validation = { + "instance_replica_id": {"readonly": True}, + "partner_replica_id": {"readonly": True}, + "replica_state": {"readonly": True}, + "seeding_progress": {"readonly": True}, + "synchronization_health": {"readonly": True}, + "connected_state": {"readonly": True}, + "last_received_lsn": {"readonly": True}, + "last_received_time": {"readonly": True}, + "last_sent_lsn": {"readonly": True}, + "last_sent_time": {"readonly": True}, + "last_commit_lsn": {"readonly": True}, + "last_commit_time": {"readonly": True}, + "last_hardened_lsn": {"readonly": True}, + "last_hardened_time": {"readonly": True}, + "last_backup_lsn": {"readonly": True}, + "last_backup_time": {"readonly": True}, + "most_recent_link_error": {"readonly": True}, + "partner_auth_cert_validity": {"readonly": True}, + "instance_send_replication_lag_seconds": {"readonly": True}, + "instance_redo_replication_lag_seconds": {"readonly": True}, + } + + _attribute_map = { + "database_name": {"key": "databaseName", "type": "str"}, + "instance_replica_id": {"key": "instanceReplicaId", "type": "str"}, + "partner_replica_id": {"key": "partnerReplicaId", "type": "str"}, + "replica_state": {"key": "replicaState", "type": "str"}, + "seeding_progress": {"key": "seedingProgress", "type": "str"}, + "synchronization_health": {"key": "synchronizationHealth", "type": "str"}, + "connected_state": {"key": "connectedState", "type": "str"}, + "last_received_lsn": {"key": "lastReceivedLsn", "type": "str"}, + "last_received_time": {"key": "lastReceivedTime", "type": "iso-8601"}, + "last_sent_lsn": {"key": "lastSentLsn", "type": "str"}, + "last_sent_time": {"key": "lastSentTime", "type": "iso-8601"}, + "last_commit_lsn": {"key": "lastCommitLsn", "type": "str"}, + "last_commit_time": {"key": "lastCommitTime", "type": "iso-8601"}, + "last_hardened_lsn": {"key": "lastHardenedLsn", "type": "str"}, + "last_hardened_time": {"key": "lastHardenedTime", "type": "iso-8601"}, + "last_backup_lsn": {"key": "lastBackupLsn", "type": "str"}, + "last_backup_time": {"key": "lastBackupTime", "type": "iso-8601"}, + "most_recent_link_error": {"key": "mostRecentLinkError", "type": "str"}, + "partner_auth_cert_validity": {"key": "partnerAuthCertValidity", "type": "CertificateInfo"}, + "instance_send_replication_lag_seconds": {"key": "instanceSendReplicationLagSeconds", "type": "int"}, + "instance_redo_replication_lag_seconds": {"key": "instanceRedoReplicationLagSeconds", "type": "int"}, + } + + def __init__(self, *, database_name: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword database_name: The name of the database in link. + :paramtype database_name: str + """ + super().__init__(**kwargs) + self.database_name = database_name + self.instance_replica_id = None + self.partner_replica_id = None + self.replica_state = None + self.seeding_progress = None + self.synchronization_health = None + self.connected_state = None + self.last_received_lsn = None + self.last_received_time = None + self.last_sent_lsn = None + self.last_sent_time = None + self.last_commit_lsn = None + self.last_commit_time = None self.last_hardened_lsn = None + self.last_hardened_time = None + self.last_backup_lsn = None + self.last_backup_time = None + self.most_recent_link_error = None + self.partner_auth_cert_validity = None + self.instance_send_replication_lag_seconds = None + self.instance_redo_replication_lag_seconds = None + + +class DistributedAvailabilityGroupSetRole(_serialization.Model): + """Distributed availability group failover request. + + All required parameters must be populated in order to send to server. + + :ivar instance_role: New role of managed instance in a distributed availability group, can be + Primary or Secondary. Required. Known values are: "Primary" and "Secondary". + :vartype instance_role: str or ~azure.mgmt.sql.models.InstanceRole + :ivar role_change_type: The type of the role change, can be Planned or Forced. Required. Known + values are: "Forced" and "Planned". + :vartype role_change_type: str or ~azure.mgmt.sql.models.RoleChangeType + """ + + _validation = { + "instance_role": {"required": True}, + "role_change_type": {"required": True}, + } + + _attribute_map = { + "instance_role": {"key": "instanceRole", "type": "str"}, + "role_change_type": {"key": "roleChangeType", "type": "str"}, + } + + def __init__( + self, + *, + instance_role: Union[str, "_models.InstanceRole"], + role_change_type: Union[str, "_models.RoleChangeType"], + **kwargs: Any + ) -> None: + """ + :keyword instance_role: New role of managed instance in a distributed availability group, can + be Primary or Secondary. Required. Known values are: "Primary" and "Secondary". + :paramtype instance_role: str or ~azure.mgmt.sql.models.InstanceRole + :keyword role_change_type: The type of the role change, can be Planned or Forced. Required. + Known values are: "Forced" and "Planned". + :paramtype role_change_type: str or ~azure.mgmt.sql.models.RoleChangeType + """ + super().__init__(**kwargs) + self.instance_role = instance_role + self.role_change_type = role_change_type + + +class DistributedAvailabilityGroupsFailoverRequest(_serialization.Model): # pylint: disable=name-too-long + """Distributed availability group failover. + + All required parameters must be populated in order to send to server. + + :ivar failover_type: The failover type, can be ForcedAllowDataLoss or Planned. Required. Known + values are: "ForcedAllowDataLoss" and "Planned". + :vartype failover_type: str or ~azure.mgmt.sql.models.FailoverType + """ + + _validation = { + "failover_type": {"required": True}, + } + + _attribute_map = { + "failover_type": {"key": "failoverType", "type": "str"}, + } + + def __init__(self, *, failover_type: Union[str, "_models.FailoverType"], **kwargs: Any) -> None: + """ + :keyword failover_type: The failover type, can be ForcedAllowDataLoss or Planned. Required. + Known values are: "ForcedAllowDataLoss" and "Planned". + :paramtype failover_type: str or ~azure.mgmt.sql.models.FailoverType + """ + super().__init__(**kwargs) + self.failover_type = failover_type class DistributedAvailabilityGroupsListResult(_serialization.Model): diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/_sql_management_client_enums.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/_sql_management_client_enums.py index 19c4a7c86efe..b14dee5e0746 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/_sql_management_client_enums.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/_sql_management_client_enums.py @@ -518,6 +518,22 @@ class FailoverGroupReplicationRole(str, Enum, metaclass=CaseInsensitiveEnumMeta) SECONDARY = "Secondary" +class FailoverModeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The link failover mode - can be Manual if intended to be used for two-way failover with a + supported SQL Server, or None for one-way failover to Azure. + """ + + NONE = "None" + MANUAL = "Manual" + + +class FailoverType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The failover type, can be ForcedAllowDataLoss or Planned.""" + + FORCED_ALLOW_DATA_LOSS = "ForcedAllowDataLoss" + PLANNED = "Planned" + + class FreeLimitExhaustionBehavior(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the behavior when monthly free limits are exhausted for the free database. @@ -607,6 +623,13 @@ class InstancePoolLicenseType(str, Enum, metaclass=CaseInsensitiveEnumMeta): BASE_PRICE = "BasePrice" +class InstanceRole(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """New role of managed instance in a distributed availability group, can be Primary or Secondary.""" + + PRIMARY = "Primary" + SECONDARY = "Secondary" + + class IsRetryable(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets whether the error could be ignored and recommended action could be retried. Possible values are: Yes/No. @@ -696,6 +719,13 @@ class LedgerDigestUploadsState(str, Enum, metaclass=CaseInsensitiveEnumMeta): DISABLED = "Disabled" +class LinkRole(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """SQL server side link role.""" + + PRIMARY = "Primary" + SECONDARY = "Secondary" + + class LogSizeUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The units that the limit is expressed in.""" @@ -1026,6 +1056,21 @@ class RecommendedSensitivityLabelUpdateKind(str, Enum, metaclass=CaseInsensitive DISABLE = "disable" +class ReplicaConnectedState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Link connected state.""" + + DISCONNECTED = "DISCONNECTED" + CONNECTED = "CONNECTED" + + +class ReplicaSynchronizationHealth(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Link health state.""" + + NOT_HEALTHY = "NOT_HEALTHY" + PARTIALLY_HEALTHY = "PARTIALLY_HEALTHY" + HEALTHY = "HEALTHY" + + class ReplicationLinkType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Link type (GEO, NAMED, STANDBY). Update operation does not support NAMED.""" @@ -1034,10 +1079,8 @@ class ReplicationLinkType(str, Enum, metaclass=CaseInsensitiveEnumMeta): STANDBY = "STANDBY" -class ReplicationMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The replication mode of a distributed availability group. Parameter will be ignored during link - creation. - """ +class ReplicationModeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Replication mode of the link.""" ASYNC = "Async" SYNC = "Sync" @@ -1083,6 +1126,13 @@ class RestorePointType(str, Enum, metaclass=CaseInsensitiveEnumMeta): DISCRETE = "DISCRETE" +class RoleChangeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the role change, can be Planned or Forced.""" + + FORCED = "Forced" + PLANNED = "Planned" + + class RuleSeverity(str, Enum, metaclass=CaseInsensitiveEnumMeta): """SQL Vulnerability Assessment rule severity.""" @@ -1168,6 +1218,13 @@ class SecurityEventType(str, Enum, metaclass=CaseInsensitiveEnumMeta): SQL_INJECTION_EXPLOIT = "SqlInjectionExploit" +class SeedingModeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Database seeding mode – can be Automatic (default), or Manual for supported scenarios.""" + + AUTOMATIC = "Automatic" + MANUAL = "Manual" + + class SensitivityLabelRank(str, Enum, metaclass=CaseInsensitiveEnumMeta): """SensitivityLabelRank.""" diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_distributed_availability_groups_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_distributed_availability_groups_operations.py index 7544e82c40c5..7f3482eb516a 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_distributed_availability_groups_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_distributed_availability_groups_operations.py @@ -49,7 +49,7 @@ def build_list_by_instance_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -84,7 +84,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -122,7 +122,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -160,9 +160,12 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01-preview")) + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop( "template_url", @@ -182,7 +185,10 @@ def build_delete_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( @@ -195,7 +201,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -226,6 +232,100 @@ def build_update_request( return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) +def build_failover_request( + resource_group_name: str, + managed_instance_name: str, + distributed_availability_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/distributedAvailabilityGroups/{distributedAvailabilityGroupName}/failover", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url( + "managed_instance_name", + managed_instance_name, + "str", + max_length=63, + min_length=1, + pattern=r"^[a-z0-9]+(?:-[a-z0-9]+)*$", + ), + "distributedAvailabilityGroupName": _SERIALIZER.url( + "distributed_availability_group_name", + distributed_availability_group_name, + "str", + max_length=128, + min_length=1, + pattern=r"^[#a-zA-Z_][\w@#$]*$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # 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, **kwargs) + + +def build_set_role_request( + resource_group_name: str, + managed_instance_name: str, + distributed_availability_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/distributedAvailabilityGroups/{distributedAvailabilityGroupName}/setRole", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + "distributedAvailabilityGroupName": _SERIALIZER.url( + "distributed_availability_group_name", distributed_availability_group_name, "str" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # 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, **kwargs) + + class DistributedAvailabilityGroupsOperations: """ .. warning:: @@ -264,7 +364,7 @@ def list_by_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01-preview")) cls: ClsType[_models.DistributedAvailabilityGroupsListResult] = kwargs.pop("cls", None) error_map: MutableMapping[int, Type[HttpResponseError]] = { @@ -312,7 +412,8 @@ def get_next(next_link=None): 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response @@ -350,7 +451,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01-preview")) cls: ClsType[_models.DistributedAvailabilityGroup] = kwargs.pop("cls", None) _request = build_get_request( @@ -373,7 +474,8 @@ def get( 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("DistributedAvailabilityGroup", pipeline_response.http_response) @@ -401,7 +503,7 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) @@ -441,7 +543,8 @@ def _create_or_update_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -541,7 +644,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DistributedAvailabilityGroup] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -604,7 +707,7 @@ def _delete_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01-preview")) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( @@ -632,7 +735,8 @@ def _delete_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -665,7 +769,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01-preview")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -722,7 +826,7 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) @@ -762,7 +866,8 @@ def _update_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -862,7 +967,7 @@ def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DistributedAvailabilityGroup] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -906,3 +1011,422 @@ def get_long_running_output(pipeline_response): return LROPoller[_models.DistributedAvailabilityGroup]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) + + def _failover_initial( + self, + resource_group_name: str, + managed_instance_name: str, + distributed_availability_group_name: str, + parameters: Union[_models.DistributedAvailabilityGroupsFailoverRequest, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DistributedAvailabilityGroupsFailoverRequest") + + _request = build_failover_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + distributed_availability_group_name=distributed_availability_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_failover( + self, + resource_group_name: str, + managed_instance_name: str, + distributed_availability_group_name: str, + parameters: _models.DistributedAvailabilityGroupsFailoverRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DistributedAvailabilityGroup]: + """Performs requested failover type in this distributed availability group. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param distributed_availability_group_name: The distributed availability group name. Required. + :type distributed_availability_group_name: str + :param parameters: The distributed availability group failover request parameters. Required. + :type parameters: ~azure.mgmt.sql.models.DistributedAvailabilityGroupsFailoverRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either DistributedAvailabilityGroup or the + result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.DistributedAvailabilityGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_failover( + self, + resource_group_name: str, + managed_instance_name: str, + distributed_availability_group_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DistributedAvailabilityGroup]: + """Performs requested failover type in this distributed availability group. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param distributed_availability_group_name: The distributed availability group name. Required. + :type distributed_availability_group_name: str + :param parameters: The distributed availability group failover request parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either DistributedAvailabilityGroup or the + result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.DistributedAvailabilityGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_failover( + self, + resource_group_name: str, + managed_instance_name: str, + distributed_availability_group_name: str, + parameters: Union[_models.DistributedAvailabilityGroupsFailoverRequest, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.DistributedAvailabilityGroup]: + """Performs requested failover type in this distributed availability group. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param distributed_availability_group_name: The distributed availability group name. Required. + :type distributed_availability_group_name: str + :param parameters: The distributed availability group failover request parameters. Is either a + DistributedAvailabilityGroupsFailoverRequest type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.sql.models.DistributedAvailabilityGroupsFailoverRequest or + IO[bytes] + :return: An instance of LROPoller that returns either DistributedAvailabilityGroup or the + result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.DistributedAvailabilityGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DistributedAvailabilityGroup] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._failover_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + distributed_availability_group_name=distributed_availability_group_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DistributedAvailabilityGroup", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.DistributedAvailabilityGroup].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.DistributedAvailabilityGroup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _set_role_initial( + self, + resource_group_name: str, + managed_instance_name: str, + distributed_availability_group_name: str, + parameters: Union[_models.DistributedAvailabilityGroupSetRole, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DistributedAvailabilityGroupSetRole") + + _request = build_set_role_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + distributed_availability_group_name=distributed_availability_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_set_role( + self, + resource_group_name: str, + managed_instance_name: str, + distributed_availability_group_name: str, + parameters: _models.DistributedAvailabilityGroupSetRole, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DistributedAvailabilityGroup]: + """Sets the role for managed instance in a distributed availability group. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param distributed_availability_group_name: The distributed availability group name. Required. + :type distributed_availability_group_name: str + :param parameters: The distributed availability group set role request parameters. Required. + :type parameters: ~azure.mgmt.sql.models.DistributedAvailabilityGroupSetRole + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either DistributedAvailabilityGroup or the + result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.DistributedAvailabilityGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_set_role( + self, + resource_group_name: str, + managed_instance_name: str, + distributed_availability_group_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DistributedAvailabilityGroup]: + """Sets the role for managed instance in a distributed availability group. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param distributed_availability_group_name: The distributed availability group name. Required. + :type distributed_availability_group_name: str + :param parameters: The distributed availability group set role request parameters. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either DistributedAvailabilityGroup or the + result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.DistributedAvailabilityGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_set_role( + self, + resource_group_name: str, + managed_instance_name: str, + distributed_availability_group_name: str, + parameters: Union[_models.DistributedAvailabilityGroupSetRole, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.DistributedAvailabilityGroup]: + """Sets the role for managed instance in a distributed availability group. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param distributed_availability_group_name: The distributed availability group name. Required. + :type distributed_availability_group_name: str + :param parameters: The distributed availability group set role request parameters. Is either a + DistributedAvailabilityGroupSetRole type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.sql.models.DistributedAvailabilityGroupSetRole or IO[bytes] + :return: An instance of LROPoller that returns either DistributedAvailabilityGroup or the + result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.DistributedAvailabilityGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DistributedAvailabilityGroup] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._set_role_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + distributed_availability_group_name=distributed_availability_group_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DistributedAvailabilityGroup", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.DistributedAvailabilityGroup].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.DistributedAvailabilityGroup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_create_max.py b/sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_create_max.py new file mode 100644 index 000000000000..be967c1f7b67 --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_create_max.py @@ -0,0 +1,54 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.sql import SqlManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-sql +# USAGE + python distributed_availability_groups_create_max.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SqlManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-1111-2222-3333-444444444444", + ) + + response = client.distributed_availability_groups.begin_create_or_update( + resource_group_name="testrg", + managed_instance_name="testcl", + distributed_availability_group_name="dag", + parameters={ + "properties": { + "databases": [{"databaseName": "testdb"}], + "failoverMode": "None", + "instanceAvailabilityGroupName": "testcl", + "instanceLinkRole": "Primary", + "partnerAvailabilityGroupName": "BoxLocalAg1", + "partnerEndpoint": "TCP://SERVER:7022", + "seedingMode": "Automatic", + } + }, + ).result() + print(response) + + +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-08-01-preview/examples/DistributedAvailabilityGroupsCreateMax.json +if __name__ == "__main__": + main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_create.py b/sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_create_min.py similarity index 80% rename from sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_create.py rename to sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_create_min.py index eaaab62f4d19..8d68965d0195 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_create.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_create_min.py @@ -15,7 +15,7 @@ pip install azure-identity pip install azure-mgmt-sql # USAGE - python distributed_availability_groups_create.py + python distributed_availability_groups_create_min.py Before run the sample, please set the values of the client ID, tenant ID and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, @@ -36,16 +36,16 @@ def main(): distributed_availability_group_name="dag", parameters={ "properties": { - "primaryAvailabilityGroupName": "BoxLocalAg1", - "secondaryAvailabilityGroupName": "testcl", - "sourceEndpoint": "TCP://SERVER:7022", - "targetDatabase": "testdb", + "databases": [{"databaseName": "testdb"}], + "instanceAvailabilityGroupName": "testcl", + "partnerAvailabilityGroupName": "BoxLocalAg1", + "partnerEndpoint": "TCP://SERVER:7022", } }, ).result() print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/DistributedAvailabilityGroupsCreate.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-08-01-preview/examples/DistributedAvailabilityGroupsCreateMin.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_delete.py b/sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_delete.py index ba3e4beb412f..6b1b9baa83fa 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_delete.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_delete.py @@ -27,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="f2669dff-5f08-45dd-b857-b2a60b72cdc9", + subscription_id="00000000-1111-2222-3333-444444444444", ) client.distributed_availability_groups.begin_delete( @@ -37,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/DistributedAvailabilityGroupsDelete.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-08-01-preview/examples/DistributedAvailabilityGroupsDelete.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_failover.py b/sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_failover.py new file mode 100644 index 000000000000..c4de78c5231b --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_failover.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.sql import SqlManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-sql +# USAGE + python distributed_availability_groups_failover.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SqlManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-1111-2222-3333-444444444444", + ) + + response = client.distributed_availability_groups.begin_failover( + resource_group_name="testrg", + managed_instance_name="testcl", + distributed_availability_group_name="dag", + parameters={"failoverType": "ForcedAllowDataLoss"}, + ).result() + print(response) + + +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-08-01-preview/examples/DistributedAvailabilityGroupsFailover.json +if __name__ == "__main__": + main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_get.py index 8b4f0c38b1e8..bd3f94df18f0 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_get.py @@ -27,7 +27,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="f2669dff-5f08-45dd-b857-b2a60b72cdc9", + subscription_id="00000000-1111-2222-3333-444444444444", ) response = client.distributed_availability_groups.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/DistributedAvailabilityGroupsGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-08-01-preview/examples/DistributedAvailabilityGroupsGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_list_by_instance.py b/sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_list_by_instance.py index 6a72d6419afd..46fcf2d932fb 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_list_by_instance.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_list_by_instance.py @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/DistributedAvailabilityGroupsListByInstance.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-08-01-preview/examples/DistributedAvailabilityGroupsListByInstance.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_set_role.py b/sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_set_role.py new file mode 100644 index 000000000000..a6276f470215 --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_set_role.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.sql import SqlManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-sql +# USAGE + python distributed_availability_groups_set_role.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SqlManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-1111-2222-3333-444444444444", + ) + + response = client.distributed_availability_groups.begin_set_role( + resource_group_name="testrg", + managed_instance_name="testcl", + distributed_availability_group_name="dag", + parameters={"instanceRole": "Primary", "roleChangeType": "Forced"}, + ).result() + print(response) + + +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-08-01-preview/examples/DistributedAvailabilityGroupsSetRole.json +if __name__ == "__main__": + main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_update.py b/sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_update.py index 94e94309b10d..3baf46ac1950 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_update.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_update.py @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/DistributedAvailabilityGroupsUpdate.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-08-01-preview/examples/DistributedAvailabilityGroupsUpdate.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/update_managed_short_term_retention_policy.py b/sdk/sql/azure-mgmt-sql/generated_samples/update_managed_short_term_retention_policy.py index 97c24c1ad254..85f9267ee8aa 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/update_managed_short_term_retention_policy.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/update_managed_short_term_retention_policy.py @@ -9,6 +9,7 @@ from azure.identity import DefaultAzureCredential from azure.mgmt.sql import SqlManagementClient + """ # PREREQUISITES pip install azure-identity @@ -21,22 +22,24 @@ AZURE_CLIENT_SECRET. For more info about how to get the value, please see: https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal """ + + def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.managed_backup_short_term_retention_policies.begin_update( - resource_group_name='resourceGroup', - managed_instance_name='testsvr', - database_name='testdb', - policy_name='default', - parameters={'properties': {'retentionDays': 14}}, + response = client.managed_backup_short_term_retention_policies.begin_create_or_update( + resource_group_name="resourceGroup", + managed_instance_name="testsvr", + database_name="testdb", + policy_name="default", + parameters={"properties": {"retentionDays": 14}}, ).result() print(response) + # x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/UpdateManagedShortTermRetentionPolicy.json if __name__ == "__main__": main() - main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/update_short_term_retention_policy.py b/sdk/sql/azure-mgmt-sql/generated_samples/update_short_term_retention_policy.py index b45b1175c0ea..81c97fe71a54 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/update_short_term_retention_policy.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/update_short_term_retention_policy.py @@ -9,7 +9,6 @@ from azure.identity import DefaultAzureCredential from azure.mgmt.sql import SqlManagementClient - """ # PREREQUISITES pip install azure-identity @@ -22,24 +21,22 @@ AZURE_CLIENT_SECRET. For more info about how to get the value, please see: https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal """ - - def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.backup_short_term_retention_policies.begin_create_or_update( - resource_group_name="resourceGroup", - server_name="testsvr", - database_name="testdb", - policy_name="default", - parameters={"properties": {"diffBackupIntervalInHours": 24, "retentionDays": 7}}, + response = client.backup_short_term_retention_policies.begin_update( + resource_group_name='resourceGroup', + server_name='testsvr', + database_name='testdb', + policy_name='default', + parameters={'properties': {'diffBackupIntervalInHours': 24, 'retentionDays': 7}}, ).result() print(response) - # x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-02-01-preview/examples/UpdateShortTermRetentionPolicy.json if __name__ == "__main__": main() + main() diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_distributed_availability_groups_operations.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_distributed_availability_groups_operations.py index ee1b19863442..5e35f4e8872e 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_distributed_availability_groups_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_distributed_availability_groups_operations.py @@ -24,7 +24,7 @@ def test_list_by_instance(self, resource_group): response = self.client.distributed_availability_groups.list_by_instance( resource_group_name=resource_group.name, managed_instance_name="str", - api_version="2021-11-01-preview", + api_version="2023-08-01-preview", ) result = [r for r in response] # please add some check logic here by yourself @@ -37,7 +37,7 @@ def test_get(self, resource_group): resource_group_name=resource_group.name, managed_instance_name="str", distributed_availability_group_name="str", - api_version="2021-11-01-preview", + api_version="2023-08-01-preview", ) # please add some check logic here by yourself @@ -51,21 +51,46 @@ def test_begin_create_or_update(self, resource_group): managed_instance_name="str", distributed_availability_group_name="str", parameters={ + "databases": [ + { + "connectedState": "str", + "databaseName": "str", + "instanceRedoReplicationLagSeconds": 0, + "instanceReplicaId": "str", + "instanceSendReplicationLagSeconds": 0, + "lastBackupLsn": "str", + "lastBackupTime": "2020-02-20 00:00:00", + "lastCommitLsn": "str", + "lastCommitTime": "2020-02-20 00:00:00", + "lastHardenedLsn": "str", + "lastHardenedTime": "2020-02-20 00:00:00", + "lastReceivedLsn": "str", + "lastReceivedTime": "2020-02-20 00:00:00", + "lastSentLsn": "str", + "lastSentTime": "2020-02-20 00:00:00", + "mostRecentLinkError": "str", + "partnerAuthCertValidity": {"certificateName": "str", "expiryDate": "2020-02-20 00:00:00"}, + "partnerReplicaId": "str", + "replicaState": "str", + "seedingProgress": "str", + "synchronizationHealth": "str", + } + ], "distributedAvailabilityGroupId": "str", + "distributedAvailabilityGroupName": "str", + "failoverMode": "str", "id": "str", - "lastHardenedLsn": "str", - "linkState": "str", + "instanceAvailabilityGroupName": "str", + "instanceLinkRole": "str", "name": "str", - "primaryAvailabilityGroupName": "str", + "partnerAvailabilityGroupName": "str", + "partnerEndpoint": "str", + "partnerLinkRole": "str", "replicationMode": "str", - "secondaryAvailabilityGroupName": "str", - "sourceEndpoint": "str", - "sourceReplicaId": "str", - "targetDatabase": "str", - "targetReplicaId": "str", + "seedingMode": "str", "type": "str", }, - api_version="2021-11-01-preview", + api_version="2023-08-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -78,7 +103,7 @@ def test_begin_delete(self, resource_group): resource_group_name=resource_group.name, managed_instance_name="str", distributed_availability_group_name="str", - api_version="2021-11-01-preview", + api_version="2023-08-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -92,21 +117,74 @@ def test_begin_update(self, resource_group): managed_instance_name="str", distributed_availability_group_name="str", parameters={ + "databases": [ + { + "connectedState": "str", + "databaseName": "str", + "instanceRedoReplicationLagSeconds": 0, + "instanceReplicaId": "str", + "instanceSendReplicationLagSeconds": 0, + "lastBackupLsn": "str", + "lastBackupTime": "2020-02-20 00:00:00", + "lastCommitLsn": "str", + "lastCommitTime": "2020-02-20 00:00:00", + "lastHardenedLsn": "str", + "lastHardenedTime": "2020-02-20 00:00:00", + "lastReceivedLsn": "str", + "lastReceivedTime": "2020-02-20 00:00:00", + "lastSentLsn": "str", + "lastSentTime": "2020-02-20 00:00:00", + "mostRecentLinkError": "str", + "partnerAuthCertValidity": {"certificateName": "str", "expiryDate": "2020-02-20 00:00:00"}, + "partnerReplicaId": "str", + "replicaState": "str", + "seedingProgress": "str", + "synchronizationHealth": "str", + } + ], "distributedAvailabilityGroupId": "str", + "distributedAvailabilityGroupName": "str", + "failoverMode": "str", "id": "str", - "lastHardenedLsn": "str", - "linkState": "str", + "instanceAvailabilityGroupName": "str", + "instanceLinkRole": "str", "name": "str", - "primaryAvailabilityGroupName": "str", + "partnerAvailabilityGroupName": "str", + "partnerEndpoint": "str", + "partnerLinkRole": "str", "replicationMode": "str", - "secondaryAvailabilityGroupName": "str", - "sourceEndpoint": "str", - "sourceReplicaId": "str", - "targetDatabase": "str", - "targetReplicaId": "str", + "seedingMode": "str", "type": "str", }, - api_version="2021-11-01-preview", + api_version="2023-08-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_failover(self, resource_group): + response = self.client.distributed_availability_groups.begin_failover( + resource_group_name=resource_group.name, + managed_instance_name="str", + distributed_availability_group_name="str", + parameters={"failoverType": "str"}, + api_version="2023-08-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_set_role(self, resource_group): + response = self.client.distributed_availability_groups.begin_set_role( + resource_group_name=resource_group.name, + managed_instance_name="str", + distributed_availability_group_name="str", + parameters={"instanceRole": "str", "roleChangeType": "str"}, + api_version="2023-08-01-preview", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself diff --git a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_distributed_availability_groups_operations_async.py b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_distributed_availability_groups_operations_async.py index f6a075746429..9429711cf38e 100644 --- a/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_distributed_availability_groups_operations_async.py +++ b/sdk/sql/azure-mgmt-sql/generated_tests/test_sql_management_distributed_availability_groups_operations_async.py @@ -25,7 +25,7 @@ async def test_list_by_instance(self, resource_group): response = self.client.distributed_availability_groups.list_by_instance( resource_group_name=resource_group.name, managed_instance_name="str", - api_version="2021-11-01-preview", + api_version="2023-08-01-preview", ) result = [r async for r in response] # please add some check logic here by yourself @@ -38,7 +38,7 @@ async def test_get(self, resource_group): resource_group_name=resource_group.name, managed_instance_name="str", distributed_availability_group_name="str", - api_version="2021-11-01-preview", + api_version="2023-08-01-preview", ) # please add some check logic here by yourself @@ -53,21 +53,46 @@ async def test_begin_create_or_update(self, resource_group): managed_instance_name="str", distributed_availability_group_name="str", parameters={ + "databases": [ + { + "connectedState": "str", + "databaseName": "str", + "instanceRedoReplicationLagSeconds": 0, + "instanceReplicaId": "str", + "instanceSendReplicationLagSeconds": 0, + "lastBackupLsn": "str", + "lastBackupTime": "2020-02-20 00:00:00", + "lastCommitLsn": "str", + "lastCommitTime": "2020-02-20 00:00:00", + "lastHardenedLsn": "str", + "lastHardenedTime": "2020-02-20 00:00:00", + "lastReceivedLsn": "str", + "lastReceivedTime": "2020-02-20 00:00:00", + "lastSentLsn": "str", + "lastSentTime": "2020-02-20 00:00:00", + "mostRecentLinkError": "str", + "partnerAuthCertValidity": {"certificateName": "str", "expiryDate": "2020-02-20 00:00:00"}, + "partnerReplicaId": "str", + "replicaState": "str", + "seedingProgress": "str", + "synchronizationHealth": "str", + } + ], "distributedAvailabilityGroupId": "str", + "distributedAvailabilityGroupName": "str", + "failoverMode": "str", "id": "str", - "lastHardenedLsn": "str", - "linkState": "str", + "instanceAvailabilityGroupName": "str", + "instanceLinkRole": "str", "name": "str", - "primaryAvailabilityGroupName": "str", + "partnerAvailabilityGroupName": "str", + "partnerEndpoint": "str", + "partnerLinkRole": "str", "replicationMode": "str", - "secondaryAvailabilityGroupName": "str", - "sourceEndpoint": "str", - "sourceReplicaId": "str", - "targetDatabase": "str", - "targetReplicaId": "str", + "seedingMode": "str", "type": "str", }, - api_version="2021-11-01-preview", + api_version="2023-08-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -82,7 +107,7 @@ async def test_begin_delete(self, resource_group): resource_group_name=resource_group.name, managed_instance_name="str", distributed_availability_group_name="str", - api_version="2021-11-01-preview", + api_version="2023-08-01-preview", ) ).result() # call '.result()' to poll until service return final result @@ -98,21 +123,78 @@ async def test_begin_update(self, resource_group): managed_instance_name="str", distributed_availability_group_name="str", parameters={ + "databases": [ + { + "connectedState": "str", + "databaseName": "str", + "instanceRedoReplicationLagSeconds": 0, + "instanceReplicaId": "str", + "instanceSendReplicationLagSeconds": 0, + "lastBackupLsn": "str", + "lastBackupTime": "2020-02-20 00:00:00", + "lastCommitLsn": "str", + "lastCommitTime": "2020-02-20 00:00:00", + "lastHardenedLsn": "str", + "lastHardenedTime": "2020-02-20 00:00:00", + "lastReceivedLsn": "str", + "lastReceivedTime": "2020-02-20 00:00:00", + "lastSentLsn": "str", + "lastSentTime": "2020-02-20 00:00:00", + "mostRecentLinkError": "str", + "partnerAuthCertValidity": {"certificateName": "str", "expiryDate": "2020-02-20 00:00:00"}, + "partnerReplicaId": "str", + "replicaState": "str", + "seedingProgress": "str", + "synchronizationHealth": "str", + } + ], "distributedAvailabilityGroupId": "str", + "distributedAvailabilityGroupName": "str", + "failoverMode": "str", "id": "str", - "lastHardenedLsn": "str", - "linkState": "str", + "instanceAvailabilityGroupName": "str", + "instanceLinkRole": "str", "name": "str", - "primaryAvailabilityGroupName": "str", + "partnerAvailabilityGroupName": "str", + "partnerEndpoint": "str", + "partnerLinkRole": "str", "replicationMode": "str", - "secondaryAvailabilityGroupName": "str", - "sourceEndpoint": "str", - "sourceReplicaId": "str", - "targetDatabase": "str", - "targetReplicaId": "str", + "seedingMode": "str", "type": "str", }, - api_version="2021-11-01-preview", + api_version="2023-08-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_failover(self, resource_group): + response = await ( + await self.client.distributed_availability_groups.begin_failover( + resource_group_name=resource_group.name, + managed_instance_name="str", + distributed_availability_group_name="str", + parameters={"failoverType": "str"}, + api_version="2023-08-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_set_role(self, resource_group): + response = await ( + await self.client.distributed_availability_groups.begin_set_role( + resource_group_name=resource_group.name, + managed_instance_name="str", + distributed_availability_group_name="str", + parameters={"instanceRole": "str", "roleChangeType": "str"}, + api_version="2023-08-01-preview", ) ).result() # call '.result()' to poll until service return final result