Skip to content
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
6 changes: 6 additions & 0 deletions azure-mgmt-sql/azure/mgmt/sql/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -173,6 +175,7 @@
SyncGroupState,
SyncDirection,
SyncMemberState,
ManagementOperationState,
)

__all__ = [
Expand Down Expand Up @@ -257,6 +260,7 @@
'SyncGroup',
'SyncMember',
'VirtualNetworkRule',
'DatabaseOperation',
'RestorePointPaged',
'RecoverableDatabasePaged',
'RestorableDroppedDatabasePaged',
Expand Down Expand Up @@ -292,6 +296,7 @@
'SyncGroupPaged',
'SyncMemberPaged',
'VirtualNetworkRulePaged',
'DatabaseOperationPaged',
'BackupLongTermRetentionPolicyState',
'RestorePointType',
'CapabilityStatus',
Expand Down Expand Up @@ -339,4 +344,5 @@
'SyncGroupState',
'SyncDirection',
'SyncMemberState',
'ManagementOperationState',
]
100 changes: 100 additions & 0 deletions azure-mgmt-sql/azure/mgmt/sql/models/database_operation.py
Original file line number Diff line number Diff line change
@@ -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
<azure.mgmt.sql.models.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
27 changes: 27 additions & 0 deletions azure-mgmt-sql/azure/mgmt/sql/models/database_operation_paged.py
Original file line number Diff line number Diff line change
@@ -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 <azure.mgmt.sql.models.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)
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 2 additions & 0 deletions azure-mgmt-sql/azure/mgmt/sql/operations/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -83,4 +84,5 @@
'SyncGroupsOperations',
'SyncMembersOperations',
'VirtualNetworkRulesOperations',
'DatabaseOperations',
]
176 changes: 176 additions & 0 deletions azure-mgmt-sql/azure/mgmt/sql/operations/database_operations.py
Original file line number Diff line number Diff line change
@@ -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<msrest:optionsforoperations>`.
:return: None or
:class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if
raw=true
:rtype: None or
:class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`
:raises: :class:`CloudError<msrestazure.azure_exceptions.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<msrest:optionsforoperations>`.
:return: An iterator like instance of :class:`DatabaseOperation
<azure.mgmt.sql.models.DatabaseOperation>`
:rtype: :class:`DatabaseOperationPaged
<azure.mgmt.sql.models.DatabaseOperationPaged>`
:raises: :class:`CloudError<msrestazure.azure_exceptions.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
Loading