diff --git a/azure-mgmt-sql/azure/mgmt/sql/models/__init__.py b/azure-mgmt-sql/azure/mgmt/sql/models/__init__.py index 16910dc2a694..3f95069c098b 100755 --- a/azure-mgmt-sql/azure/mgmt/sql/models/__init__.py +++ b/azure-mgmt-sql/azure/mgmt/sql/models/__init__.py @@ -50,6 +50,10 @@ from .transparent_data_encryption_activity import TransparentDataEncryptionActivity from .database_security_alert_policy import DatabaseSecurityAlertPolicy from .database_blob_auditing_policy import DatabaseBlobAuditingPolicy +from .failover_group_read_write_endpoint import FailoverGroupReadWriteEndpoint +from .failover_group_read_only_endpoint import FailoverGroupReadOnlyEndpoint +from .partner_info import PartnerInfo +from .failover_group import FailoverGroup from .restore_point_paged import RestorePointPaged from .replication_link_paged import ReplicationLinkPaged from .database_paged import DatabasePaged @@ -65,6 +69,7 @@ from .elastic_pool_database_activity_paged import ElasticPoolDatabaseActivityPaged from .recommended_elastic_pool_paged import RecommendedElasticPoolPaged from .recommended_elastic_pool_metric_paged import RecommendedElasticPoolMetricPaged +from .failover_group_paged import FailoverGroupPaged from .sql_management_client_enums import ( RestorePointTypes, CapabilityStatus, @@ -92,6 +97,9 @@ SecurityAlertPolicyEmailAccountAdmins, SecurityAlertPolicyUseServerDefault, BlobAuditingPolicyState, + ReadWriteEndpointFailoverPolicy, + ReadOnlyEndpointFailoverPolicy, + FailoverGroupReplicationRole, ) __all__ = [ @@ -136,6 +144,10 @@ 'TransparentDataEncryptionActivity', 'DatabaseSecurityAlertPolicy', 'DatabaseBlobAuditingPolicy', + 'FailoverGroupReadWriteEndpoint', + 'FailoverGroupReadOnlyEndpoint', + 'PartnerInfo', + 'FailoverGroup', 'RestorePointPaged', 'ReplicationLinkPaged', 'DatabasePaged', @@ -151,6 +163,7 @@ 'ElasticPoolDatabaseActivityPaged', 'RecommendedElasticPoolPaged', 'RecommendedElasticPoolMetricPaged', + 'FailoverGroupPaged', 'RestorePointTypes', 'CapabilityStatus', 'MaxSizeUnits', @@ -177,4 +190,7 @@ 'SecurityAlertPolicyEmailAccountAdmins', 'SecurityAlertPolicyUseServerDefault', 'BlobAuditingPolicyState', + 'ReadWriteEndpointFailoverPolicy', + 'ReadOnlyEndpointFailoverPolicy', + 'FailoverGroupReplicationRole', ] diff --git a/azure-mgmt-sql/azure/mgmt/sql/models/database.py b/azure-mgmt-sql/azure/mgmt/sql/models/database.py index 65072ed6f124..8cc31f71e538 100755 --- a/azure-mgmt-sql/azure/mgmt/sql/models/database.py +++ b/azure-mgmt-sql/azure/mgmt/sql/models/database.py @@ -166,8 +166,8 @@ class Database(TrackedResource): :ivar recommended_index: The recommended indices for this database. :vartype recommended_index: list of :class:`RecommendedIndex ` - :ivar failover_group_id: The id indicating the failover group containing - this database. + :ivar failover_group_id: The resource identifier of the failover group + containing this database. :vartype failover_group_id: str :param read_scale: Conditional. If the database is a geo-secondary, readScale indicates whether read-only connections are allowed to this diff --git a/azure-mgmt-sql/azure/mgmt/sql/models/failover_group.py b/azure-mgmt-sql/azure/mgmt/sql/models/failover_group.py new file mode 100755 index 000000000000..b2a70b6c07f0 --- /dev/null +++ b/azure-mgmt-sql/azure/mgmt/sql/models/failover_group.py @@ -0,0 +1,85 @@ +# 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 .proxy_resource import ProxyResource + + +class FailoverGroup(ProxyResource): + """A failover group. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :param tags: Resource tags. + :type tags: dict + :param read_write_endpoint: Read-write endpoint of the failover group + instance. + :type read_write_endpoint: :class:`FailoverGroupReadWriteEndpoint + ` + :param read_only_endpoint: Read-only endpoint of the failover group + instance. + :type read_only_endpoint: :class:`FailoverGroupReadOnlyEndpoint + ` + :ivar replication_role: Local replication role of the failover group + instance. Possible values include: 'Primary', 'Secondary' + :vartype replication_role: str or :class:`FailoverGroupReplicationRole + ` + :ivar replication_state: Replication state of the failover group instance. + :vartype replication_state: str + :param partner_servers: List of partner server information for the + failover group. + :type partner_servers: list of :class:`PartnerInfo + ` + :param databases: List of databases in the failover group. + :type databases: list of str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'location': {'readonly': True}, + 'replication_role': {'readonly': True}, + 'replication_state': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'read_write_endpoint': {'key': 'properties.readWriteEndpoint', 'type': 'FailoverGroupReadWriteEndpoint'}, + 'read_only_endpoint': {'key': 'properties.readOnlyEndpoint', 'type': 'FailoverGroupReadOnlyEndpoint'}, + 'replication_role': {'key': 'properties.replicationRole', 'type': 'str'}, + 'replication_state': {'key': 'properties.replicationState', 'type': 'str'}, + 'partner_servers': {'key': 'properties.partnerServers', 'type': '[PartnerInfo]'}, + 'databases': {'key': 'properties.databases', 'type': '[str]'}, + } + + def __init__(self, tags=None, read_write_endpoint=None, read_only_endpoint=None, partner_servers=None, databases=None): + super(FailoverGroup, self).__init__() + self.location = None + self.tags = tags + self.read_write_endpoint = read_write_endpoint + self.read_only_endpoint = read_only_endpoint + self.replication_role = None + self.replication_state = None + self.partner_servers = partner_servers + self.databases = databases diff --git a/azure-mgmt-sql/azure/mgmt/sql/models/failover_group_paged.py b/azure-mgmt-sql/azure/mgmt/sql/models/failover_group_paged.py new file mode 100755 index 000000000000..739bc93f915a --- /dev/null +++ b/azure-mgmt-sql/azure/mgmt/sql/models/failover_group_paged.py @@ -0,0 +1,27 @@ +# 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 msrest.paging import Paged + + +class FailoverGroupPaged(Paged): + """ + A paging container for iterating over a list of FailoverGroup object + """ + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'current_page': {'key': 'value', 'type': '[FailoverGroup]'} + } + + def __init__(self, *args, **kwargs): + + super(FailoverGroupPaged, self).__init__(*args, **kwargs) diff --git a/azure-mgmt-sql/azure/mgmt/sql/models/failover_group_read_only_endpoint.py b/azure-mgmt-sql/azure/mgmt/sql/models/failover_group_read_only_endpoint.py new file mode 100755 index 000000000000..49b78627232c --- /dev/null +++ b/azure-mgmt-sql/azure/mgmt/sql/models/failover_group_read_only_endpoint.py @@ -0,0 +1,29 @@ +# 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 msrest.serialization import Model + + +class FailoverGroupReadOnlyEndpoint(Model): + """Read-only endpoint of the failover group instance. + + :param failover_policy: Failover policy of the read-only endpoint for the + failover group. Possible values include: 'Disabled', 'Enabled' + :type failover_policy: str or :class:`ReadOnlyEndpointFailoverPolicy + ` + """ + + _attribute_map = { + 'failover_policy': {'key': 'failoverPolicy', 'type': 'str'}, + } + + def __init__(self, failover_policy=None): + self.failover_policy = failover_policy diff --git a/azure-mgmt-sql/azure/mgmt/sql/models/failover_group_read_write_endpoint.py b/azure-mgmt-sql/azure/mgmt/sql/models/failover_group_read_write_endpoint.py new file mode 100755 index 000000000000..d71732ca8146 --- /dev/null +++ b/azure-mgmt-sql/azure/mgmt/sql/models/failover_group_read_write_endpoint.py @@ -0,0 +1,34 @@ +# 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 msrest.serialization import Model + + +class FailoverGroupReadWriteEndpoint(Model): + """Read-write endpoint of the failover group instance. + + :param failover_policy: Failover policy of the read-write endpoint for the + failover group. Possible values include: 'Manual', 'Automatic' + :type failover_policy: str or :class:`ReadWriteEndpointFailoverPolicy + ` + :param failover_with_data_loss_grace_period_minutes: Grace period before + failover with data loss is attempted for the read-write endpoint. + :type failover_with_data_loss_grace_period_minutes: int + """ + + _attribute_map = { + 'failover_policy': {'key': 'failoverPolicy', 'type': 'str'}, + 'failover_with_data_loss_grace_period_minutes': {'key': 'failoverWithDataLossGracePeriodMinutes', 'type': 'int'}, + } + + def __init__(self, failover_policy=None, failover_with_data_loss_grace_period_minutes=None): + self.failover_policy = failover_policy + self.failover_with_data_loss_grace_period_minutes = failover_with_data_loss_grace_period_minutes diff --git a/azure-mgmt-sql/azure/mgmt/sql/models/partner_info.py b/azure-mgmt-sql/azure/mgmt/sql/models/partner_info.py new file mode 100755 index 000000000000..64fe959d1bd7 --- /dev/null +++ b/azure-mgmt-sql/azure/mgmt/sql/models/partner_info.py @@ -0,0 +1,45 @@ +# 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 msrest.serialization import Model + + +class PartnerInfo(Model): + """Partner server information for the failover group. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :param id: Resource identifier of the partner server. + :type id: str + :ivar location: Geo location of the partner server. + :vartype location: str + :ivar replication_role: Replication role of the partner server. Possible + values include: 'Primary', 'Secondary' + :vartype replication_role: str or :class:`FailoverGroupReplicationRole + ` + """ + + _validation = { + 'location': {'readonly': True}, + 'replication_role': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'replication_role': {'key': 'replicationRole', 'type': 'str'}, + } + + def __init__(self, id=None): + self.id = id + self.location = None + self.replication_role = None diff --git a/azure-mgmt-sql/azure/mgmt/sql/models/sql_management_client_enums.py b/azure-mgmt-sql/azure/mgmt/sql/models/sql_management_client_enums.py index 3033853a654e..6747f2675967 100755 --- a/azure-mgmt-sql/azure/mgmt/sql/models/sql_management_client_enums.py +++ b/azure-mgmt-sql/azure/mgmt/sql/models/sql_management_client_enums.py @@ -215,3 +215,21 @@ class BlobAuditingPolicyState(Enum): enabled = "Enabled" disabled = "Disabled" + + +class ReadWriteEndpointFailoverPolicy(Enum): + + manual = "Manual" + automatic = "Automatic" + + +class ReadOnlyEndpointFailoverPolicy(Enum): + + disabled = "Disabled" + enabled = "Enabled" + + +class FailoverGroupReplicationRole(Enum): + + primary = "Primary" + secondary = "Secondary" diff --git a/azure-mgmt-sql/azure/mgmt/sql/operations/__init__.py b/azure-mgmt-sql/azure/mgmt/sql/operations/__init__.py index a310f0741e1b..a26bd8099d36 100755 --- a/azure-mgmt-sql/azure/mgmt/sql/operations/__init__.py +++ b/azure-mgmt-sql/azure/mgmt/sql/operations/__init__.py @@ -16,6 +16,7 @@ from .servers_operations import ServersOperations from .elastic_pools_operations import ElasticPoolsOperations from .recommended_elastic_pools_operations import RecommendedElasticPoolsOperations +from .failover_groups_operations import FailoverGroupsOperations __all__ = [ 'DatabasesOperations', @@ -25,4 +26,5 @@ 'ServersOperations', 'ElasticPoolsOperations', 'RecommendedElasticPoolsOperations', + 'FailoverGroupsOperations', ] diff --git a/azure-mgmt-sql/azure/mgmt/sql/operations/failover_groups_operations.py b/azure-mgmt-sql/azure/mgmt/sql/operations/failover_groups_operations.py new file mode 100755 index 000000000000..a1bbbda8bf8b --- /dev/null +++ b/azure-mgmt-sql/azure/mgmt/sql/operations/failover_groups_operations.py @@ -0,0 +1,640 @@ +# 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 msrest.pipeline import ClientRawResponse +from msrestazure.azure_exceptions import CloudError +from msrestazure.azure_operation import AzureOperationPoller +import uuid + +from .. import models + + +class FailoverGroupsOperations(object): + """FailoverGroupsOperations operations. + + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An objec model deserializer. + :ivar api_version: The API version to use for the request. Constant value: "2015-05-01-preview". + """ + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self.api_version = "2015-05-01-preview" + + self.config = config + + def get( + self, resource_group_name, server_name, failover_group_name, custom_headers=None, raw=False, **operation_config): + """Gets a failover 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. + :type resource_group_name: str + :param server_name: The name of the server containing the failover + group. + :type server_name: str + :param failover_group_name: The name of the failover group. + :type failover_group_name: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :rtype: :class:`FailoverGroup ` + :rtype: :class:`ClientRawResponse` + if raw=true + :raises: :class:`CloudError` + """ + # Construct URL + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}' + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serverName': self._serialize.url("server_name", server_name, 'str'), + 'failoverGroupName': self._serialize.url("failover_group_name", failover_group_name, 'str'), + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + 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 and send request + request = self._client.get(url, query_parameters) + response = self._client.send(request, header_parameters, **operation_config) + + if response.status_code not in [200]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('FailoverGroup', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + def create_or_update( + self, resource_group_name, server_name, failover_group_name, parameters, custom_headers=None, raw=False, **operation_config): + """Creates or updates a failover 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. + :type resource_group_name: str + :param server_name: The name of the server containing the failover + group. + :type server_name: str + :param failover_group_name: The name of the failover group. + :type failover_group_name: str + :param parameters: The failover group parameters. + :type parameters: :class:`FailoverGroup + ` + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :rtype: + :class:`AzureOperationPoller` + instance that returns :class:`FailoverGroup + ` + :rtype: :class:`ClientRawResponse` + if raw=true + :raises: :class:`CloudError` + """ + # Construct URL + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}' + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serverName': self._serialize.url("server_name", server_name, 'str'), + 'failoverGroupName': self._serialize.url("failover_group_name", failover_group_name, 'str'), + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + 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, 'FailoverGroup') + + # Construct and send request + def long_running_send(): + + request = self._client.put(url, query_parameters) + return self._client.send( + request, header_parameters, body_content, **operation_config) + + def get_long_running_status(status_link, headers=None): + + request = self._client.get(status_link) + if headers: + request.headers.update(headers) + return self._client.send( + request, header_parameters, **operation_config) + + def get_long_running_output(response): + + if response.status_code not in [200, 202, 201]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('FailoverGroup', response) + if response.status_code == 201: + deserialized = self._deserialize('FailoverGroup', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + if raw: + response = long_running_send() + return get_long_running_output(response) + + long_running_operation_timeout = operation_config.get( + 'long_running_operation_timeout', + self.config.long_running_operation_timeout) + return AzureOperationPoller( + long_running_send, get_long_running_output, + get_long_running_status, long_running_operation_timeout) + + def delete( + self, resource_group_name, server_name, failover_group_name, custom_headers=None, raw=False, **operation_config): + """Deletes a failover 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. + :type resource_group_name: str + :param server_name: The name of the server containing the failover + group. + :type server_name: str + :param failover_group_name: The name of the failover group. + :type failover_group_name: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :rtype: + :class:`AzureOperationPoller` + instance that returns None + :rtype: :class:`ClientRawResponse` + if raw=true + :raises: :class:`CloudError` + """ + # Construct URL + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}' + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serverName': self._serialize.url("server_name", server_name, 'str'), + 'failoverGroupName': self._serialize.url("failover_group_name", failover_group_name, 'str'), + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + 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 and send request + def long_running_send(): + + request = self._client.delete(url, query_parameters) + return self._client.send(request, header_parameters, **operation_config) + + def get_long_running_status(status_link, headers=None): + + request = self._client.get(status_link) + if headers: + request.headers.update(headers) + return self._client.send( + request, header_parameters, **operation_config) + + def get_long_running_output(response): + + if response.status_code not in [200, 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 + + if raw: + response = long_running_send() + return get_long_running_output(response) + + long_running_operation_timeout = operation_config.get( + 'long_running_operation_timeout', + self.config.long_running_operation_timeout) + return AzureOperationPoller( + long_running_send, get_long_running_output, + get_long_running_status, long_running_operation_timeout) + + def update( + self, resource_group_name, server_name, failover_group_name, parameters, custom_headers=None, raw=False, **operation_config): + """Updates a failover 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. + :type resource_group_name: str + :param server_name: The name of the server containing the failover + group. + :type server_name: str + :param failover_group_name: The name of the failover group. + :type failover_group_name: str + :param parameters: The failover group parameters. + :type parameters: :class:`FailoverGroup + ` + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :rtype: + :class:`AzureOperationPoller` + instance that returns :class:`FailoverGroup + ` + :rtype: :class:`ClientRawResponse` + if raw=true + :raises: :class:`CloudError` + """ + # Construct URL + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}' + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serverName': self._serialize.url("server_name", server_name, 'str'), + 'failoverGroupName': self._serialize.url("failover_group_name", failover_group_name, 'str'), + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + 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, 'FailoverGroup') + + # Construct and send request + def long_running_send(): + + request = self._client.patch(url, query_parameters) + return self._client.send( + request, header_parameters, body_content, **operation_config) + + def get_long_running_status(status_link, headers=None): + + request = self._client.get(status_link) + if headers: + request.headers.update(headers) + return self._client.send( + request, header_parameters, **operation_config) + + def get_long_running_output(response): + + if response.status_code not in [200, 202]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('FailoverGroup', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + if raw: + response = long_running_send() + return get_long_running_output(response) + + long_running_operation_timeout = operation_config.get( + 'long_running_operation_timeout', + self.config.long_running_operation_timeout) + return AzureOperationPoller( + long_running_send, get_long_running_output, + get_long_running_status, long_running_operation_timeout) + + def list_by_server( + self, resource_group_name, server_name, custom_headers=None, raw=False, **operation_config): + """Lists the failover groups in a server. + + :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 containing the failover + group. + :type server_name: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :rtype: :class:`FailoverGroupPaged + ` + :raises: :class:`CloudError` + """ + def internal_paging(next_link=None, raw=False): + + if not next_link: + # Construct URL + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups' + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serverName': self._serialize.url("server_name", server_name, 'str'), + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + else: + url = next_link + query_parameters = {} + + # 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 and send request + request = self._client.get(url, query_parameters) + response = self._client.send( + request, header_parameters, **operation_config) + + if response.status_code not in [200]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + return response + + # Deserialize response + deserialized = models.FailoverGroupPaged(internal_paging, self._deserialize.dependencies) + + if raw: + header_dict = {} + client_raw_response = models.FailoverGroupPaged(internal_paging, self._deserialize.dependencies, header_dict) + return client_raw_response + + return deserialized + + def failover( + self, resource_group_name, server_name, failover_group_name, custom_headers=None, raw=False, **operation_config): + """Fails over from the current primary server to this server. + + :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 containing the failover + group. + :type server_name: str + :param failover_group_name: The name of the failover group. + :type failover_group_name: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :rtype: + :class:`AzureOperationPoller` + instance that returns :class:`FailoverGroup + ` + :rtype: :class:`ClientRawResponse` + if raw=true + :raises: :class:`CloudError` + """ + # Construct URL + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}/failover' + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serverName': self._serialize.url("server_name", server_name, 'str'), + 'failoverGroupName': self._serialize.url("failover_group_name", failover_group_name, 'str'), + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + 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 and send request + def long_running_send(): + + request = self._client.post(url, query_parameters) + return self._client.send(request, header_parameters, **operation_config) + + def get_long_running_status(status_link, headers=None): + + request = self._client.get(status_link) + if headers: + request.headers.update(headers) + return self._client.send( + request, header_parameters, **operation_config) + + def get_long_running_output(response): + + if response.status_code not in [200, 202]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('FailoverGroup', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + if raw: + response = long_running_send() + return get_long_running_output(response) + + long_running_operation_timeout = operation_config.get( + 'long_running_operation_timeout', + self.config.long_running_operation_timeout) + return AzureOperationPoller( + long_running_send, get_long_running_output, + get_long_running_status, long_running_operation_timeout) + + def force_failover_allow_data_loss( + self, resource_group_name, server_name, failover_group_name, custom_headers=None, raw=False, **operation_config): + """Fails over from the current primary server to this server. This + operation might result in data loss. + + :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 containing the failover + group. + :type server_name: str + :param failover_group_name: The name of the failover group. + :type failover_group_name: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :rtype: + :class:`AzureOperationPoller` + instance that returns :class:`FailoverGroup + ` + :rtype: :class:`ClientRawResponse` + if raw=true + :raises: :class:`CloudError` + """ + # Construct URL + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}/forceFailoverAllowDataLoss' + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serverName': self._serialize.url("server_name", server_name, 'str'), + 'failoverGroupName': self._serialize.url("failover_group_name", failover_group_name, 'str'), + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + 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 and send request + def long_running_send(): + + request = self._client.post(url, query_parameters) + return self._client.send(request, header_parameters, **operation_config) + + def get_long_running_status(status_link, headers=None): + + request = self._client.get(status_link) + if headers: + request.headers.update(headers) + return self._client.send( + request, header_parameters, **operation_config) + + def get_long_running_output(response): + + if response.status_code not in [200, 202]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('FailoverGroup', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + if raw: + response = long_running_send() + return get_long_running_output(response) + + long_running_operation_timeout = operation_config.get( + 'long_running_operation_timeout', + self.config.long_running_operation_timeout) + return AzureOperationPoller( + long_running_send, get_long_running_output, + get_long_running_status, long_running_operation_timeout) diff --git a/azure-mgmt-sql/azure/mgmt/sql/sql_management_client.py b/azure-mgmt-sql/azure/mgmt/sql/sql_management_client.py index ddea0bf519ce..de15011252ac 100755 --- a/azure-mgmt-sql/azure/mgmt/sql/sql_management_client.py +++ b/azure-mgmt-sql/azure/mgmt/sql/sql_management_client.py @@ -20,6 +20,7 @@ from .operations.servers_operations import ServersOperations from .operations.elastic_pools_operations import ElasticPoolsOperations from .operations.recommended_elastic_pools_operations import RecommendedElasticPoolsOperations +from .operations.failover_groups_operations import FailoverGroupsOperations from . import models @@ -65,19 +66,21 @@ class SqlManagementClient(object): :vartype config: SqlManagementClientConfiguration :ivar databases: Databases operations - :vartype databases: .operations.DatabasesOperations + :vartype databases: azure.mgmt.sql.operations.DatabasesOperations :ivar capabilities: Capabilities operations - :vartype capabilities: .operations.CapabilitiesOperations + :vartype capabilities: azure.mgmt.sql.operations.CapabilitiesOperations :ivar firewall_rules: FirewallRules operations - :vartype firewall_rules: .operations.FirewallRulesOperations + :vartype firewall_rules: azure.mgmt.sql.operations.FirewallRulesOperations :ivar operations: Operations operations - :vartype operations: .operations.Operations + :vartype operations: azure.mgmt.sql.operations.Operations :ivar servers: Servers operations - :vartype servers: .operations.ServersOperations + :vartype servers: azure.mgmt.sql.operations.ServersOperations :ivar elastic_pools: ElasticPools operations - :vartype elastic_pools: .operations.ElasticPoolsOperations + :vartype elastic_pools: azure.mgmt.sql.operations.ElasticPoolsOperations :ivar recommended_elastic_pools: RecommendedElasticPools operations - :vartype recommended_elastic_pools: .operations.RecommendedElasticPoolsOperations + :vartype recommended_elastic_pools: azure.mgmt.sql.operations.RecommendedElasticPoolsOperations + :ivar failover_groups: FailoverGroups operations + :vartype failover_groups: azure.mgmt.sql.operations.FailoverGroupsOperations :param credentials: Credentials needed for the client to connect to Azure. :type credentials: :mod:`A msrestazure Credentials @@ -112,3 +115,5 @@ def __init__( self._client, self.config, self._serialize, self._deserialize) self.recommended_elastic_pools = RecommendedElasticPoolsOperations( self._client, self.config, self._serialize, self._deserialize) + self.failover_groups = FailoverGroupsOperations( + self._client, self.config, self._serialize, self._deserialize) diff --git a/azure-mgmt-sql/azure/mgmt/sql/version.py b/azure-mgmt-sql/azure/mgmt/sql/version.py index c9fea7678df4..266f5a486d79 100755 --- a/azure-mgmt-sql/azure/mgmt/sql/version.py +++ b/azure-mgmt-sql/azure/mgmt/sql/version.py @@ -9,5 +9,5 @@ # regenerated. # -------------------------------------------------------------------------- -VERSION = "0.5.1" +VERSION = "0.5.0"