From c560c66e1927782886a48b3fbe05836fb7ea2b2e Mon Sep 17 00:00:00 2001 From: SDK Automation Date: Wed, 1 Apr 2020 23:46:30 +0000 Subject: [PATCH] Generated from c86d57b97fd2eaae90672eeb2b067b0c138a2890 Adding decription of unlink action to Replication Link Swagger --- .../azure/mgmt/sql/models/__init__.py | 3 + .../azure/mgmt/sql/models/_models.py | 17 +++ .../azure/mgmt/sql/models/_models_py3.py | 17 +++ .../_replication_links_operations.py | 100 ++++++++++++++++++ 4 files changed, 137 insertions(+) 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 e72bde3586c6..5d5b1c99d9f5 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 @@ -177,6 +177,7 @@ from ._models_py3 import TrackedResource from ._models_py3 import TransparentDataEncryption from ._models_py3 import TransparentDataEncryptionActivity + from ._models_py3 import UnlinkParameters from ._models_py3 import Usage from ._models_py3 import VirtualCluster from ._models_py3 import VirtualClusterUpdate @@ -354,6 +355,7 @@ from ._models import TrackedResource from ._models import TransparentDataEncryption from ._models import TransparentDataEncryptionActivity + from ._models import UnlinkParameters from ._models import Usage from ._models import VirtualCluster from ._models import VirtualClusterUpdate @@ -705,6 +707,7 @@ 'TrackedResource', 'TransparentDataEncryption', 'TransparentDataEncryptionActivity', + 'UnlinkParameters', 'Usage', 'VirtualCluster', 'VirtualClusterUpdate', diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/_models.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/_models.py index 153ccd9289e9..deb46f504fca 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/_models.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/_models.py @@ -9609,6 +9609,23 @@ def __init__(self, **kwargs): self.percent_complete = None +class UnlinkParameters(Model): + """Represents the parameters for Unlink Replication Link request. + + :param forced_termination: Determines whether link will be terminated in a + forced or a friendly way. + :type forced_termination: bool + """ + + _attribute_map = { + 'forced_termination': {'key': 'forcedTermination', 'type': 'bool'}, + } + + def __init__(self, **kwargs): + super(UnlinkParameters, self).__init__(**kwargs) + self.forced_termination = kwargs.get('forced_termination', None) + + class Usage(Model): """ARM usage. 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 70e81e62ae62..213dcd911c9d 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 @@ -9609,6 +9609,23 @@ def __init__(self, **kwargs) -> None: self.percent_complete = None +class UnlinkParameters(Model): + """Represents the parameters for Unlink Replication Link request. + + :param forced_termination: Determines whether link will be terminated in a + forced or a friendly way. + :type forced_termination: bool + """ + + _attribute_map = { + 'forced_termination': {'key': 'forcedTermination', 'type': 'bool'}, + } + + def __init__(self, *, forced_termination: bool=None, **kwargs) -> None: + super(UnlinkParameters, self).__init__(**kwargs) + self.forced_termination = forced_termination + + class Usage(Model): """ARM usage. diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_replication_links_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_replication_links_operations.py index bebd9d62e04d..7cb1cad8ec04 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_replication_links_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_replication_links_operations.py @@ -354,6 +354,106 @@ def get_long_running_output(response): return LROPoller(self._client, raw_result, get_long_running_output, polling_method) failover_allow_data_loss.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/replicationLinks/{linkId}/forceFailoverAllowDataLoss'} + + def _unlink_initial( + self, resource_group_name, server_name, database_name, link_id, forced_termination=None, custom_headers=None, raw=False, **operation_config): + parameters = models.UnlinkParameters(forced_termination=forced_termination) + + # Construct URL + url = self.unlink.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serverName': self._serialize.url("server_name", server_name, 'str'), + 'databaseName': self._serialize.url("database_name", database_name, 'str'), + 'linkId': self._serialize.url("link_id", link_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct body + body_content = self._serialize.body(parameters, 'UnlinkParameters') + + # Construct and send request + request = self._client.post(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [202, 204]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + + def unlink( + self, resource_group_name, server_name, database_name, link_id, forced_termination=None, custom_headers=None, raw=False, polling=True, **operation_config): + """Deletes a database replication link in forced or friendly way. + + :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. + :type resource_group_name: str + :param server_name: The name of the server. + :type server_name: str + :param database_name: The name of the database that has the + replication link to be failed over. + :type database_name: str + :param link_id: The ID of the replication link to be failed over. + :type link_id: str + :param forced_termination: Determines whether link will be terminated + in a forced or a friendly way. + :type forced_termination: bool + :param dict custom_headers: headers that will be added to the request + :param bool raw: The poller return type is ClientRawResponse, the + direct response alongside the deserialized response + :param polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :return: An instance of LROPoller that returns None or + ClientRawResponse if raw==True + :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or + ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] + :raises: :class:`CloudError` + """ + raw_result = self._unlink_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + link_id=link_id, + forced_termination=forced_termination, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + + def get_long_running_output(response): + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + + lro_delay = operation_config.get( + 'long_running_operation_timeout', + self.config.long_running_operation_timeout) + if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + unlink.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/replicationLinks/{linkId}/unlink'} + def list_by_database( self, resource_group_name, server_name, database_name, custom_headers=None, raw=False, **operation_config): """Lists a database's replication links.