Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AutoPR sql/resource-manager] Failover Database Readable Secondary #7747

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,7 @@
VulnerabilityAssessmentPolicyBaselineName,
SensitivityLabelSource,
CapabilityGroup,
ReplicaType,
)

__all__ = [
Expand Down Expand Up @@ -807,4 +808,5 @@
'VulnerabilityAssessmentPolicyBaselineName',
'SensitivityLabelSource',
'CapabilityGroup',
'ReplicaType',
]
Original file line number Diff line number Diff line change
Expand Up @@ -710,3 +710,9 @@ class CapabilityGroup(str, Enum):
supported_editions = "supportedEditions"
supported_elastic_pool_editions = "supportedElasticPoolEditions"
supported_managed_instance_versions = "supportedManagedInstanceVersions"


class ReplicaType(str, Enum):

primary = "Primary"
readable_secondary = "ReadableSecondary"
Original file line number Diff line number Diff line change
Expand Up @@ -1414,7 +1414,7 @@ def rename(


def _failover_initial(
self, resource_group_name, server_name, database_name, custom_headers=None, raw=False, **operation_config):
self, resource_group_name, server_name, database_name, replica_type=None, custom_headers=None, raw=False, **operation_config):
api_version = "2018-06-01-preview"

# Construct URL
Expand All @@ -1429,6 +1429,8 @@ def _failover_initial(

# Construct parameters
query_parameters = {}
if replica_type is not None:
query_parameters['replicaType'] = self._serialize.query("replica_type", replica_type, 'str')
query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')

# Construct headers
Expand All @@ -1454,7 +1456,7 @@ def _failover_initial(
return client_raw_response

def failover(
self, resource_group_name, server_name, database_name, custom_headers=None, raw=False, polling=True, **operation_config):
self, resource_group_name, server_name, database_name, replica_type=None, custom_headers=None, raw=False, polling=True, **operation_config):
"""Failovers a database.

:param resource_group_name: The name of the resource group that
Expand All @@ -1465,6 +1467,9 @@ def failover(
:type server_name: str
:param database_name: The name of the database to failover.
:type database_name: str
:param replica_type: The type of replica to be failed over. Possible
values include: 'Primary', 'ReadableSecondary'
:type replica_type: str or ~azure.mgmt.sql.models.ReplicaType
: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
Expand All @@ -1480,6 +1485,7 @@ def failover(
resource_group_name=resource_group_name,
server_name=server_name,
database_name=database_name,
replica_type=replica_type,
custom_headers=custom_headers,
raw=True,
**operation_config
Expand Down