diff --git a/azure-mgmt-sql/azure/mgmt/sql/models/__init__.py b/azure-mgmt-sql/azure/mgmt/sql/models/__init__.py index b683f26122c0..e303eff3d57a 100644 --- a/azure-mgmt-sql/azure/mgmt/sql/models/__init__.py +++ b/azure-mgmt-sql/azure/mgmt/sql/models/__init__.py @@ -90,6 +90,7 @@ from .sync_group import SyncGroup from .sync_member import SyncMember from .virtual_network_rule import VirtualNetworkRule +from .database_operation import DatabaseOperation from .restore_point_paged import RestorePointPaged from .recoverable_database_paged import RecoverableDatabasePaged from .restorable_dropped_database_paged import RestorableDroppedDatabasePaged @@ -125,6 +126,7 @@ from .sync_group_paged import SyncGroupPaged from .sync_member_paged import SyncMemberPaged from .virtual_network_rule_paged import VirtualNetworkRulePaged +from .database_operation_paged import DatabaseOperationPaged from .sql_management_client_enums import ( BackupLongTermRetentionPolicyState, RestorePointType, @@ -173,6 +175,7 @@ SyncGroupState, SyncDirection, SyncMemberState, + ManagementOperationState, ) __all__ = [ @@ -257,6 +260,7 @@ 'SyncGroup', 'SyncMember', 'VirtualNetworkRule', + 'DatabaseOperation', 'RestorePointPaged', 'RecoverableDatabasePaged', 'RestorableDroppedDatabasePaged', @@ -292,6 +296,7 @@ 'SyncGroupPaged', 'SyncMemberPaged', 'VirtualNetworkRulePaged', + 'DatabaseOperationPaged', 'BackupLongTermRetentionPolicyState', 'RestorePointType', 'CapabilityStatus', @@ -339,4 +344,5 @@ 'SyncGroupState', 'SyncDirection', 'SyncMemberState', + 'ManagementOperationState', ] diff --git a/azure-mgmt-sql/azure/mgmt/sql/models/database_operation.py b/azure-mgmt-sql/azure/mgmt/sql/models/database_operation.py new file mode 100644 index 000000000000..4899a902e6cf --- /dev/null +++ b/azure-mgmt-sql/azure/mgmt/sql/models/database_operation.py @@ -0,0 +1,100 @@ +# 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 DatabaseOperation(ProxyResource): + """A database operation. + + 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 database_name: The name of the database the operation is being + performed on. + :vartype database_name: str + :ivar operation: The name of operation. + :vartype operation: str + :ivar operation_friendly_name: The friendly name of operation. + :vartype operation_friendly_name: str + :ivar percent_complete: The percentage of the operation completed. + :vartype percent_complete: int + :ivar server_name: The name of the server. + :vartype server_name: str + :ivar start_time: The operation start time. + :vartype start_time: datetime + :ivar state: The operation state. Possible values include: 'Pending', + 'InProgress', 'Succeeded', 'Failed', 'CancelInProgress', 'Cancelled' + :vartype state: str or :class:`ManagementOperationState + ` + :ivar error_code: The operation error code. + :vartype error_code: int + :ivar error_description: The operation error description. + :vartype error_description: str + :ivar error_severity: The operation error severity. + :vartype error_severity: int + :ivar is_user_error: Whether or not the error is a user error. + :vartype is_user_error: bool + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'database_name': {'readonly': True}, + 'operation': {'readonly': True}, + 'operation_friendly_name': {'readonly': True}, + 'percent_complete': {'readonly': True}, + 'server_name': {'readonly': True}, + 'start_time': {'readonly': True}, + 'state': {'readonly': True}, + 'error_code': {'readonly': True}, + 'error_description': {'readonly': True}, + 'error_severity': {'readonly': True}, + 'is_user_error': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'database_name': {'key': 'properties.databaseName', 'type': 'str'}, + 'operation': {'key': 'properties.operation', 'type': 'str'}, + 'operation_friendly_name': {'key': 'properties.operationFriendlyName', 'type': 'str'}, + 'percent_complete': {'key': 'properties.percentComplete', 'type': 'int'}, + 'server_name': {'key': 'properties.serverName', 'type': 'str'}, + 'start_time': {'key': 'properties.startTime', 'type': 'iso-8601'}, + 'state': {'key': 'properties.state', 'type': 'str'}, + 'error_code': {'key': 'properties.errorCode', 'type': 'int'}, + 'error_description': {'key': 'properties.errorDescription', 'type': 'str'}, + 'error_severity': {'key': 'properties.errorSeverity', 'type': 'int'}, + 'is_user_error': {'key': 'properties.isUserError', 'type': 'bool'}, + } + + def __init__(self): + super(DatabaseOperation, self).__init__() + self.database_name = None + self.operation = None + self.operation_friendly_name = None + self.percent_complete = None + self.server_name = None + self.start_time = None + self.state = None + self.error_code = None + self.error_description = None + self.error_severity = None + self.is_user_error = None diff --git a/azure-mgmt-sql/azure/mgmt/sql/models/database_operation_paged.py b/azure-mgmt-sql/azure/mgmt/sql/models/database_operation_paged.py new file mode 100644 index 000000000000..4c22372df877 --- /dev/null +++ b/azure-mgmt-sql/azure/mgmt/sql/models/database_operation_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 DatabaseOperationPaged(Paged): + """ + A paging container for iterating over a list of :class:`DatabaseOperation ` object + """ + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'current_page': {'key': 'value', 'type': '[DatabaseOperation]'} + } + + def __init__(self, *args, **kwargs): + + super(DatabaseOperationPaged, self).__init__(*args, **kwargs) 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 cef70b122865..7b9000534919 100644 --- 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 @@ -380,3 +380,13 @@ class SyncMemberState(Enum): reprovisioning = "Reprovisioning" reprovision_failed = "ReprovisionFailed" un_reprovisioned = "UnReprovisioned" + + +class ManagementOperationState(Enum): + + pending = "Pending" + in_progress = "InProgress" + succeeded = "Succeeded" + failed = "Failed" + cancel_in_progress = "CancelInProgress" + cancelled = "Cancelled" diff --git a/azure-mgmt-sql/azure/mgmt/sql/operations/__init__.py b/azure-mgmt-sql/azure/mgmt/sql/operations/__init__.py index a0e1137352a9..f81063dbdd09 100644 --- a/azure-mgmt-sql/azure/mgmt/sql/operations/__init__.py +++ b/azure-mgmt-sql/azure/mgmt/sql/operations/__init__.py @@ -45,6 +45,7 @@ from .sync_groups_operations import SyncGroupsOperations from .sync_members_operations import SyncMembersOperations from .virtual_network_rules_operations import VirtualNetworkRulesOperations +from .database_operations import DatabaseOperations __all__ = [ 'BackupLongTermRetentionPoliciesOperations', @@ -83,4 +84,5 @@ 'SyncGroupsOperations', 'SyncMembersOperations', 'VirtualNetworkRulesOperations', + 'DatabaseOperations', ] diff --git a/azure-mgmt-sql/azure/mgmt/sql/operations/database_operations.py b/azure-mgmt-sql/azure/mgmt/sql/operations/database_operations.py new file mode 100644 index 000000000000..584a68750db1 --- /dev/null +++ b/azure-mgmt-sql/azure/mgmt/sql/operations/database_operations.py @@ -0,0 +1,176 @@ +# 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. +# -------------------------------------------------------------------------- + +import uuid +from msrest.pipeline import ClientRawResponse +from msrestazure.azure_exceptions import CloudError + +from .. import models + + +class DatabaseOperations(object): + """DatabaseOperations 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: "2017-03-01-preview". + """ + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self.api_version = "2017-03-01-preview" + + self.config = config + + def cancel( + self, resource_group_name, server_name, database_name, operation_id, custom_headers=None, raw=False, **operation_config): + """Cancels the asynchronous operation on the database. + + :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. + :type database_name: str + :param operation_id: The operation identifier. + :type operation_id: 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`. + :return: None or + :class:`ClientRawResponse` if + raw=true + :rtype: None or + :class:`ClientRawResponse` + :raises: :class:`CloudError` + """ + # Construct URL + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/operations/{operationId}/cancel' + path_format_arguments = { + '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'), + 'operationId': self._serialize.url("operation_id", operation_id, '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.post(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 + + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + + def list_by_database( + self, resource_group_name, server_name, database_name, custom_headers=None, raw=False, **operation_config): + """Gets a list of operations performed on the database. + + :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. + :type database_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`. + :return: An iterator like instance of :class:`DatabaseOperation + ` + :rtype: :class:`DatabaseOperationPaged + ` + :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}/databases/{databaseName}/operations' + path_format_arguments = { + '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'), + '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.DatabaseOperationPaged(internal_paging, self._deserialize.dependencies) + + if raw: + header_dict = {} + client_raw_response = models.DatabaseOperationPaged(internal_paging, self._deserialize.dependencies, header_dict) + return client_raw_response + + return deserialized 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 8bae1240c724..fdeae37afe23 100644 --- a/azure-mgmt-sql/azure/mgmt/sql/sql_management_client.py +++ b/azure-mgmt-sql/azure/mgmt/sql/sql_management_client.py @@ -49,6 +49,7 @@ from .operations.sync_groups_operations import SyncGroupsOperations from .operations.sync_members_operations import SyncMembersOperations from .operations.virtual_network_rules_operations import VirtualNetworkRulesOperations +from .operations.database_operations import DatabaseOperations from . import models @@ -165,6 +166,8 @@ class SqlManagementClient(object): :vartype sync_members: azure.mgmt.sql.operations.SyncMembersOperations :ivar virtual_network_rules: VirtualNetworkRules operations :vartype virtual_network_rules: azure.mgmt.sql.operations.VirtualNetworkRulesOperations + :ivar database_operations: DatabaseOperations operations + :vartype database_operations: azure.mgmt.sql.operations.DatabaseOperations :param credentials: Credentials needed for the client to connect to Azure. :type credentials: :mod:`A msrestazure Credentials @@ -257,3 +260,5 @@ def __init__( self._client, self.config, self._serialize, self._deserialize) self.virtual_network_rules = VirtualNetworkRulesOperations( self._client, self.config, self._serialize, self._deserialize) + self.database_operations = DatabaseOperations( + 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 e4f3d5055303..d473b389a956 100644 --- 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.8.0" +VERSION = "0.7.1" diff --git a/azure-mgmt-sql/build.json b/azure-mgmt-sql/build.json index 95a2196b68c4..18c59aa14475 100644 --- a/azure-mgmt-sql/build.json +++ b/azure-mgmt-sql/build.json @@ -1 +1 @@ -{"autorest": "1.2.2", "date": "2017-08-29T02:02:12Z", "version": ""} \ No newline at end of file +{"autorest": "1.2.2", "date": "2017-09-18T20:12:57Z", "version": ""} \ No newline at end of file