diff --git a/azure-mgmt-sql/azure/mgmt/sql/models/__init__.py b/azure-mgmt-sql/azure/mgmt/sql/models/__init__.py index 531a679a81b5..1cce5da1a400 100644 --- a/azure-mgmt-sql/azure/mgmt/sql/models/__init__.py +++ b/azure-mgmt-sql/azure/mgmt/sql/models/__init__.py @@ -26,10 +26,26 @@ from .elastic_pool_edition_capability import ElasticPoolEditionCapability from .server_version_capability import ServerVersionCapability from .location_capabilities import LocationCapabilities +from .check_name_availability_request import CheckNameAvailabilityRequest +from .check_name_availability_response import CheckNameAvailabilityResponse from .server_connection_policy import ServerConnectionPolicy +from .slo_usage_metric import SloUsageMetric +from .service_tier_advisor import ServiceTierAdvisor +from .transparent_data_encryption import TransparentDataEncryption +from .operation_impact import OperationImpact +from .recommended_index import RecommendedIndex +from .database import Database +from .database_update import DatabaseUpdate +from .transparent_data_encryption_activity import TransparentDataEncryptionActivity +from .elastic_pool_database_activity import ElasticPoolDatabaseActivity +from .elastic_pool_activity import ElasticPoolActivity +from .recommended_elastic_pool_metric import RecommendedElasticPoolMetric +from .recommended_elastic_pool import RecommendedElasticPool from .database_security_alert_policy import DatabaseSecurityAlertPolicy from .data_masking_policy import DataMaskingPolicy from .data_masking_rule import DataMaskingRule +from .elastic_pool import ElasticPool +from .elastic_pool_update import ElasticPoolUpdate from .firewall_rule import FirewallRule from .geo_backup_policy import GeoBackupPolicy from .import_extension_request import ImportExtensionRequest @@ -45,25 +61,11 @@ from .server_azure_ad_administrator import ServerAzureADAdministrator from .server_communication_link import ServerCommunicationLink from .service_objective import ServiceObjective -from .check_name_availability_request import CheckNameAvailabilityRequest -from .check_name_availability_response import CheckNameAvailabilityResponse -from .recommended_elastic_pool_metric import RecommendedElasticPoolMetric -from .slo_usage_metric import SloUsageMetric -from .service_tier_advisor import ServiceTierAdvisor -from .transparent_data_encryption import TransparentDataEncryption -from .operation_impact import OperationImpact -from .recommended_index import RecommendedIndex -from .database import Database -from .recommended_elastic_pool import RecommendedElasticPool -from .elastic_pool import ElasticPool -from .elastic_pool_update import ElasticPoolUpdate -from .elastic_pool_activity import ElasticPoolActivity -from .elastic_pool_database_activity import ElasticPoolDatabaseActivity -from .database_update import DatabaseUpdate -from .transparent_data_encryption_activity import TransparentDataEncryptionActivity from .server_usage import ServerUsage from .database_usage import DatabaseUsage from .database_blob_auditing_policy import DatabaseBlobAuditingPolicy +from .automatic_tuning_options import AutomaticTuningOptions +from .database_automatic_tuning import DatabaseAutomaticTuning from .encryption_protector import EncryptionProtector from .failover_group_read_write_endpoint import FailoverGroupReadWriteEndpoint from .failover_group_read_only_endpoint import FailoverGroupReadOnlyEndpoint @@ -93,6 +95,8 @@ from .virtual_network_rule import VirtualNetworkRule from .database_operation import DatabaseOperation from .resource_move_definition import ResourceMoveDefinition +from .automatic_tuning_server_options import AutomaticTuningServerOptions +from .server_automatic_tuning import ServerAutomaticTuning from .server_dns_alias import ServerDnsAlias from .server_dns_alias_acquisition import ServerDnsAliasAcquisition from .backup_long_term_retention_policy_paged import BackupLongTermRetentionPolicyPaged @@ -100,18 +104,18 @@ from .restore_point_paged import RestorePointPaged from .recoverable_database_paged import RecoverableDatabasePaged from .restorable_dropped_database_paged import RestorableDroppedDatabasePaged -from .data_masking_rule_paged import DataMaskingRulePaged -from .firewall_rule_paged import FirewallRulePaged -from .geo_backup_policy_paged import GeoBackupPolicyPaged +from .server_paged import ServerPaged +from .database_paged import DatabasePaged from .metric_paged import MetricPaged from .metric_definition_paged import MetricDefinitionPaged -from .database_paged import DatabasePaged +from .data_masking_rule_paged import DataMaskingRulePaged from .elastic_pool_paged import ElasticPoolPaged +from .firewall_rule_paged import FirewallRulePaged +from .geo_backup_policy_paged import GeoBackupPolicyPaged from .replication_link_paged import ReplicationLinkPaged from .server_azure_ad_administrator_paged import ServerAzureADAdministratorPaged from .server_communication_link_paged import ServerCommunicationLinkPaged from .service_objective_paged import ServiceObjectivePaged -from .server_paged import ServerPaged from .elastic_pool_activity_paged import ElasticPoolActivityPaged from .elastic_pool_database_activity_paged import ElasticPoolDatabaseActivityPaged from .recommended_elastic_pool_paged import RecommendedElasticPoolPaged @@ -141,16 +145,27 @@ CapabilityStatus, MaxSizeUnits, PerformanceLevelUnit, + CheckNameAvailabilityReason, ServerConnectionType, + CreateMode, + DatabaseEdition, + ServiceObjectiveName, + TransparentDataEncryptionStatus, + RecommendedIndexAction, + RecommendedIndexState, + RecommendedIndexType, + ReadScale, + SampleName, + TransparentDataEncryptionActivityStatus, + ElasticPoolEdition, SecurityAlertPolicyState, SecurityAlertPolicyEmailAccountAdmins, SecurityAlertPolicyUseServerDefault, DataMaskingState, DataMaskingRuleState, DataMaskingFunction, + ElasticPoolState, GeoBackupPolicyState, - DatabaseEdition, - ServiceObjectiveName, StorageKeyType, AuthenticationType, UnitType, @@ -158,18 +173,11 @@ UnitDefinitionType, ReplicationRole, ReplicationState, - CheckNameAvailabilityReason, - ElasticPoolEdition, - CreateMode, - TransparentDataEncryptionStatus, - RecommendedIndexAction, - RecommendedIndexState, - RecommendedIndexType, - ReadScale, - SampleName, - ElasticPoolState, - TransparentDataEncryptionActivityStatus, BlobAuditingPolicyState, + AutomaticTuningMode, + AutomaticTuningOptionModeDesired, + AutomaticTuningOptionModeActual, + AutomaticTuningDisabledReason, ServerKeyType, ReadWriteEndpointFailoverPolicy, ReadOnlyEndpointFailoverPolicy, @@ -185,6 +193,8 @@ SyncMemberState, VirtualNetworkRuleState, ManagementOperationState, + AutomaticTuningServerMode, + AutomaticTuningServerReason, ) __all__ = [ @@ -205,10 +215,26 @@ 'ElasticPoolEditionCapability', 'ServerVersionCapability', 'LocationCapabilities', + 'CheckNameAvailabilityRequest', + 'CheckNameAvailabilityResponse', 'ServerConnectionPolicy', + 'SloUsageMetric', + 'ServiceTierAdvisor', + 'TransparentDataEncryption', + 'OperationImpact', + 'RecommendedIndex', + 'Database', + 'DatabaseUpdate', + 'TransparentDataEncryptionActivity', + 'ElasticPoolDatabaseActivity', + 'ElasticPoolActivity', + 'RecommendedElasticPoolMetric', + 'RecommendedElasticPool', 'DatabaseSecurityAlertPolicy', 'DataMaskingPolicy', 'DataMaskingRule', + 'ElasticPool', + 'ElasticPoolUpdate', 'FirewallRule', 'GeoBackupPolicy', 'ImportExtensionRequest', @@ -224,25 +250,11 @@ 'ServerAzureADAdministrator', 'ServerCommunicationLink', 'ServiceObjective', - 'CheckNameAvailabilityRequest', - 'CheckNameAvailabilityResponse', - 'RecommendedElasticPoolMetric', - 'SloUsageMetric', - 'ServiceTierAdvisor', - 'TransparentDataEncryption', - 'OperationImpact', - 'RecommendedIndex', - 'Database', - 'RecommendedElasticPool', - 'ElasticPool', - 'ElasticPoolUpdate', - 'ElasticPoolActivity', - 'ElasticPoolDatabaseActivity', - 'DatabaseUpdate', - 'TransparentDataEncryptionActivity', 'ServerUsage', 'DatabaseUsage', 'DatabaseBlobAuditingPolicy', + 'AutomaticTuningOptions', + 'DatabaseAutomaticTuning', 'EncryptionProtector', 'FailoverGroupReadWriteEndpoint', 'FailoverGroupReadOnlyEndpoint', @@ -272,6 +284,8 @@ 'VirtualNetworkRule', 'DatabaseOperation', 'ResourceMoveDefinition', + 'AutomaticTuningServerOptions', + 'ServerAutomaticTuning', 'ServerDnsAlias', 'ServerDnsAliasAcquisition', 'BackupLongTermRetentionPolicyPaged', @@ -279,18 +293,18 @@ 'RestorePointPaged', 'RecoverableDatabasePaged', 'RestorableDroppedDatabasePaged', - 'DataMaskingRulePaged', - 'FirewallRulePaged', - 'GeoBackupPolicyPaged', + 'ServerPaged', + 'DatabasePaged', 'MetricPaged', 'MetricDefinitionPaged', - 'DatabasePaged', + 'DataMaskingRulePaged', 'ElasticPoolPaged', + 'FirewallRulePaged', + 'GeoBackupPolicyPaged', 'ReplicationLinkPaged', 'ServerAzureADAdministratorPaged', 'ServerCommunicationLinkPaged', 'ServiceObjectivePaged', - 'ServerPaged', 'ElasticPoolActivityPaged', 'ElasticPoolDatabaseActivityPaged', 'RecommendedElasticPoolPaged', @@ -319,16 +333,27 @@ 'CapabilityStatus', 'MaxSizeUnits', 'PerformanceLevelUnit', + 'CheckNameAvailabilityReason', 'ServerConnectionType', + 'CreateMode', + 'DatabaseEdition', + 'ServiceObjectiveName', + 'TransparentDataEncryptionStatus', + 'RecommendedIndexAction', + 'RecommendedIndexState', + 'RecommendedIndexType', + 'ReadScale', + 'SampleName', + 'TransparentDataEncryptionActivityStatus', + 'ElasticPoolEdition', 'SecurityAlertPolicyState', 'SecurityAlertPolicyEmailAccountAdmins', 'SecurityAlertPolicyUseServerDefault', 'DataMaskingState', 'DataMaskingRuleState', 'DataMaskingFunction', + 'ElasticPoolState', 'GeoBackupPolicyState', - 'DatabaseEdition', - 'ServiceObjectiveName', 'StorageKeyType', 'AuthenticationType', 'UnitType', @@ -336,18 +361,11 @@ 'UnitDefinitionType', 'ReplicationRole', 'ReplicationState', - 'CheckNameAvailabilityReason', - 'ElasticPoolEdition', - 'CreateMode', - 'TransparentDataEncryptionStatus', - 'RecommendedIndexAction', - 'RecommendedIndexState', - 'RecommendedIndexType', - 'ReadScale', - 'SampleName', - 'ElasticPoolState', - 'TransparentDataEncryptionActivityStatus', 'BlobAuditingPolicyState', + 'AutomaticTuningMode', + 'AutomaticTuningOptionModeDesired', + 'AutomaticTuningOptionModeActual', + 'AutomaticTuningDisabledReason', 'ServerKeyType', 'ReadWriteEndpointFailoverPolicy', 'ReadOnlyEndpointFailoverPolicy', @@ -363,4 +381,6 @@ 'SyncMemberState', 'VirtualNetworkRuleState', 'ManagementOperationState', + 'AutomaticTuningServerMode', + 'AutomaticTuningServerReason', ] diff --git a/azure-mgmt-sql/azure/mgmt/sql/models/automatic_tuning_options.py b/azure-mgmt-sql/azure/mgmt/sql/models/automatic_tuning_options.py new file mode 100644 index 000000000000..d51528905ca8 --- /dev/null +++ b/azure-mgmt-sql/azure/mgmt/sql/models/automatic_tuning_options.py @@ -0,0 +1,57 @@ +# 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 AutomaticTuningOptions(Model): + """Automatic tuning properties for individual advisors. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :param desired_state: Automatic tuning option desired state. Possible + values include: 'Off', 'On', 'Default' + :type desired_state: str or + ~azure.mgmt.sql.models.AutomaticTuningOptionModeDesired + :ivar actual_state: Automatic tuning option actual state. Possible values + include: 'Off', 'On' + :vartype actual_state: str or + ~azure.mgmt.sql.models.AutomaticTuningOptionModeActual + :ivar reason_code: Reason code if desired and actual state are different. + :vartype reason_code: int + :ivar reason_desc: Reason description if desired and actual state are + different. Possible values include: 'Default', 'Disabled', + 'AutoConfigured', 'InheritedFromServer', 'QueryStoreOff', + 'QueryStoreReadOnly', 'NotSupported' + :vartype reason_desc: str or + ~azure.mgmt.sql.models.AutomaticTuningDisabledReason + """ + + _validation = { + 'actual_state': {'readonly': True}, + 'reason_code': {'readonly': True}, + 'reason_desc': {'readonly': True}, + } + + _attribute_map = { + 'desired_state': {'key': 'desiredState', 'type': 'AutomaticTuningOptionModeDesired'}, + 'actual_state': {'key': 'actualState', 'type': 'AutomaticTuningOptionModeActual'}, + 'reason_code': {'key': 'reasonCode', 'type': 'int'}, + 'reason_desc': {'key': 'reasonDesc', 'type': 'AutomaticTuningDisabledReason'}, + } + + def __init__(self, desired_state=None): + super(AutomaticTuningOptions, self).__init__() + self.desired_state = desired_state + self.actual_state = None + self.reason_code = None + self.reason_desc = None diff --git a/azure-mgmt-sql/azure/mgmt/sql/models/automatic_tuning_server_options.py b/azure-mgmt-sql/azure/mgmt/sql/models/automatic_tuning_server_options.py new file mode 100644 index 000000000000..163fa8125cf1 --- /dev/null +++ b/azure-mgmt-sql/azure/mgmt/sql/models/automatic_tuning_server_options.py @@ -0,0 +1,56 @@ +# 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 AutomaticTuningServerOptions(Model): + """Automatic tuning properties for individual advisors. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :param desired_state: Automatic tuning option desired state. Possible + values include: 'Off', 'On', 'Default' + :type desired_state: str or + ~azure.mgmt.sql.models.AutomaticTuningOptionModeDesired + :ivar actual_state: Automatic tuning option actual state. Possible values + include: 'Off', 'On' + :vartype actual_state: str or + ~azure.mgmt.sql.models.AutomaticTuningOptionModeActual + :ivar reason_code: Reason code if desired and actual state are different. + :vartype reason_code: int + :ivar reason_desc: Reason description if desired and actual state are + different. Possible values include: 'Default', 'Disabled', + 'AutoConfigured' + :vartype reason_desc: str or + ~azure.mgmt.sql.models.AutomaticTuningServerReason + """ + + _validation = { + 'actual_state': {'readonly': True}, + 'reason_code': {'readonly': True}, + 'reason_desc': {'readonly': True}, + } + + _attribute_map = { + 'desired_state': {'key': 'desiredState', 'type': 'AutomaticTuningOptionModeDesired'}, + 'actual_state': {'key': 'actualState', 'type': 'AutomaticTuningOptionModeActual'}, + 'reason_code': {'key': 'reasonCode', 'type': 'int'}, + 'reason_desc': {'key': 'reasonDesc', 'type': 'AutomaticTuningServerReason'}, + } + + def __init__(self, desired_state=None): + super(AutomaticTuningServerOptions, self).__init__() + self.desired_state = desired_state + self.actual_state = None + self.reason_code = None + self.reason_desc = None diff --git a/azure-mgmt-sql/azure/mgmt/sql/models/database_automatic_tuning.py b/azure-mgmt-sql/azure/mgmt/sql/models/database_automatic_tuning.py new file mode 100644 index 000000000000..2bee39c6b0e6 --- /dev/null +++ b/azure-mgmt-sql/azure/mgmt/sql/models/database_automatic_tuning.py @@ -0,0 +1,57 @@ +# 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 DatabaseAutomaticTuning(ProxyResource): + """Database-level Automatic Tuning. + + 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 + :param desired_state: Automatic tuning desired state. Possible values + include: 'Inherit', 'Custom', 'Auto', 'Unspecified' + :type desired_state: str or ~azure.mgmt.sql.models.AutomaticTuningMode + :ivar actual_state: Automatic tuning actual state. Possible values + include: 'Inherit', 'Custom', 'Auto', 'Unspecified' + :vartype actual_state: str or ~azure.mgmt.sql.models.AutomaticTuningMode + :param options: Automatic tuning options definition. + :type options: dict[str, ~azure.mgmt.sql.models.AutomaticTuningOptions] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'actual_state': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'desired_state': {'key': 'properties.desiredState', 'type': 'AutomaticTuningMode'}, + 'actual_state': {'key': 'properties.actualState', 'type': 'AutomaticTuningMode'}, + 'options': {'key': 'properties.options', 'type': '{AutomaticTuningOptions}'}, + } + + def __init__(self, desired_state=None, options=None): + super(DatabaseAutomaticTuning, self).__init__() + self.desired_state = desired_state + self.actual_state = None + self.options = options diff --git a/azure-mgmt-sql/azure/mgmt/sql/models/server_automatic_tuning.py b/azure-mgmt-sql/azure/mgmt/sql/models/server_automatic_tuning.py new file mode 100644 index 000000000000..fd9963f37eab --- /dev/null +++ b/azure-mgmt-sql/azure/mgmt/sql/models/server_automatic_tuning.py @@ -0,0 +1,60 @@ +# 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 ServerAutomaticTuning(ProxyResource): + """Server-level Automatic Tuning. + + 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 + :param desired_state: Automatic tuning desired state. Possible values + include: 'Custom', 'Auto', 'Unspecified' + :type desired_state: str or + ~azure.mgmt.sql.models.AutomaticTuningServerMode + :ivar actual_state: Automatic tuning actual state. Possible values + include: 'Custom', 'Auto', 'Unspecified' + :vartype actual_state: str or + ~azure.mgmt.sql.models.AutomaticTuningServerMode + :param options: Automatic tuning options definition. + :type options: dict[str, + ~azure.mgmt.sql.models.AutomaticTuningServerOptions] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'actual_state': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'desired_state': {'key': 'properties.desiredState', 'type': 'AutomaticTuningServerMode'}, + 'actual_state': {'key': 'properties.actualState', 'type': 'AutomaticTuningServerMode'}, + 'options': {'key': 'properties.options', 'type': '{AutomaticTuningServerOptions}'}, + } + + def __init__(self, desired_state=None, options=None): + super(ServerAutomaticTuning, self).__init__() + self.desired_state = desired_state + self.actual_state = None + self.options = options 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 9a91fbb9da44..f6aba93bdcc6 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 @@ -45,6 +45,12 @@ class PerformanceLevelUnit(Enum): dtu = "DTU" +class CheckNameAvailabilityReason(Enum): + + invalid = "Invalid" + already_exists = "AlreadyExists" + + class ServerConnectionType(Enum): default = "Default" @@ -52,51 +58,16 @@ class ServerConnectionType(Enum): redirect = "Redirect" -class SecurityAlertPolicyState(Enum): - - new = "New" - enabled = "Enabled" - disabled = "Disabled" - - -class SecurityAlertPolicyEmailAccountAdmins(Enum): - - enabled = "Enabled" - disabled = "Disabled" - - -class SecurityAlertPolicyUseServerDefault(Enum): - - enabled = "Enabled" - disabled = "Disabled" - - -class DataMaskingState(Enum): - - disabled = "Disabled" - enabled = "Enabled" - - -class DataMaskingRuleState(Enum): - - disabled = "Disabled" - enabled = "Enabled" - - -class DataMaskingFunction(Enum): +class CreateMode(Enum): + copy = "Copy" default = "Default" - ccn = "CCN" - email = "Email" - number = "Number" - ssn = "SSN" - text = "Text" - - -class GeoBackupPolicyState(Enum): - - disabled = "Disabled" - enabled = "Enabled" + non_readable_secondary = "NonReadableSecondary" + online_secondary = "OnlineSecondary" + point_in_time_restore = "PointInTimeRestore" + recovery = "Recovery" + restore = "Restore" + restore_long_term_retention_backup = "RestoreLongTermRetentionBackup" class DatabaseEdition(Enum): @@ -183,6 +154,120 @@ class ServiceObjectiveName(Enum): elastic_pool = "ElasticPool" +class TransparentDataEncryptionStatus(Enum): + + enabled = "Enabled" + disabled = "Disabled" + + +class RecommendedIndexAction(Enum): + + create = "Create" + drop = "Drop" + rebuild = "Rebuild" + + +class RecommendedIndexState(Enum): + + active = "Active" + pending = "Pending" + executing = "Executing" + verifying = "Verifying" + pending_revert = "Pending Revert" + reverting = "Reverting" + reverted = "Reverted" + ignored = "Ignored" + expired = "Expired" + blocked = "Blocked" + success = "Success" + + +class RecommendedIndexType(Enum): + + clustered = "CLUSTERED" + nonclustered = "NONCLUSTERED" + columnstore = "COLUMNSTORE" + clusteredcolumnstore = "CLUSTERED COLUMNSTORE" + + +class ReadScale(Enum): + + enabled = "Enabled" + disabled = "Disabled" + + +class SampleName(Enum): + + adventure_works_lt = "AdventureWorksLT" + + +class TransparentDataEncryptionActivityStatus(Enum): + + encrypting = "Encrypting" + decrypting = "Decrypting" + + +class ElasticPoolEdition(Enum): + + basic = "Basic" + standard = "Standard" + premium = "Premium" + + +class SecurityAlertPolicyState(Enum): + + new = "New" + enabled = "Enabled" + disabled = "Disabled" + + +class SecurityAlertPolicyEmailAccountAdmins(Enum): + + enabled = "Enabled" + disabled = "Disabled" + + +class SecurityAlertPolicyUseServerDefault(Enum): + + enabled = "Enabled" + disabled = "Disabled" + + +class DataMaskingState(Enum): + + disabled = "Disabled" + enabled = "Enabled" + + +class DataMaskingRuleState(Enum): + + disabled = "Disabled" + enabled = "Enabled" + + +class DataMaskingFunction(Enum): + + default = "Default" + ccn = "CCN" + email = "Email" + number = "Number" + ssn = "SSN" + text = "Text" + + +class ElasticPoolState(Enum): + + creating = "Creating" + ready = "Ready" + disabled = "Disabled" + + +class GeoBackupPolicyState(Enum): + + disabled = "Disabled" + enabled = "Enabled" + + class StorageKeyType(Enum): storage_access_key = "StorageAccessKey" @@ -242,95 +327,42 @@ class ReplicationState(Enum): suspended = "SUSPENDED" -class CheckNameAvailabilityReason(Enum): - - invalid = "Invalid" - already_exists = "AlreadyExists" - - -class ElasticPoolEdition(Enum): - - basic = "Basic" - standard = "Standard" - premium = "Premium" - - -class CreateMode(Enum): - - copy = "Copy" - default = "Default" - non_readable_secondary = "NonReadableSecondary" - online_secondary = "OnlineSecondary" - point_in_time_restore = "PointInTimeRestore" - recovery = "Recovery" - restore = "Restore" - restore_long_term_retention_backup = "RestoreLongTermRetentionBackup" - - -class TransparentDataEncryptionStatus(Enum): - - enabled = "Enabled" - disabled = "Disabled" - - -class RecommendedIndexAction(Enum): - - create = "Create" - drop = "Drop" - rebuild = "Rebuild" - - -class RecommendedIndexState(Enum): - - active = "Active" - pending = "Pending" - executing = "Executing" - verifying = "Verifying" - pending_revert = "Pending Revert" - reverting = "Reverting" - reverted = "Reverted" - ignored = "Ignored" - expired = "Expired" - blocked = "Blocked" - success = "Success" - - -class RecommendedIndexType(Enum): - - clustered = "CLUSTERED" - nonclustered = "NONCLUSTERED" - columnstore = "COLUMNSTORE" - clusteredcolumnstore = "CLUSTERED COLUMNSTORE" - - -class ReadScale(Enum): +class BlobAuditingPolicyState(Enum): enabled = "Enabled" disabled = "Disabled" -class SampleName(Enum): +class AutomaticTuningMode(Enum): - adventure_works_lt = "AdventureWorksLT" + inherit = "Inherit" + custom = "Custom" + auto = "Auto" + unspecified = "Unspecified" -class ElasticPoolState(Enum): +class AutomaticTuningOptionModeDesired(Enum): - creating = "Creating" - ready = "Ready" - disabled = "Disabled" + off = "Off" + on = "On" + default = "Default" -class TransparentDataEncryptionActivityStatus(Enum): +class AutomaticTuningOptionModeActual(Enum): - encrypting = "Encrypting" - decrypting = "Decrypting" + off = "Off" + on = "On" -class BlobAuditingPolicyState(Enum): +class AutomaticTuningDisabledReason(Enum): - enabled = "Enabled" + default = "Default" disabled = "Disabled" + auto_configured = "AutoConfigured" + inherited_from_server = "InheritedFromServer" + query_store_off = "QueryStoreOff" + query_store_read_only = "QueryStoreReadOnly" + not_supported = "NotSupported" class ServerKeyType(Enum): @@ -450,3 +482,17 @@ class ManagementOperationState(Enum): failed = "Failed" cancel_in_progress = "CancelInProgress" cancelled = "Cancelled" + + +class AutomaticTuningServerMode(Enum): + + custom = "Custom" + auto = "Auto" + unspecified = "Unspecified" + + +class AutomaticTuningServerReason(Enum): + + default = "Default" + disabled = "Disabled" + auto_configured = "AutoConfigured" diff --git a/azure-mgmt-sql/azure/mgmt/sql/operations/__init__.py b/azure-mgmt-sql/azure/mgmt/sql/operations/__init__.py index 59b50f000e0a..0bd855b1dc22 100644 --- a/azure-mgmt-sql/azure/mgmt/sql/operations/__init__.py +++ b/azure-mgmt-sql/azure/mgmt/sql/operations/__init__.py @@ -15,19 +15,19 @@ from .recoverable_databases_operations import RecoverableDatabasesOperations from .restorable_dropped_databases_operations import RestorableDroppedDatabasesOperations from .capabilities_operations import CapabilitiesOperations +from .servers_operations import ServersOperations from .server_connection_policies_operations import ServerConnectionPoliciesOperations +from .databases_operations import DatabasesOperations from .database_threat_detection_policies_operations import DatabaseThreatDetectionPoliciesOperations from .data_masking_policies_operations import DataMaskingPoliciesOperations from .data_masking_rules_operations import DataMaskingRulesOperations +from .elastic_pools_operations import ElasticPoolsOperations from .firewall_rules_operations import FirewallRulesOperations from .geo_backup_policies_operations import GeoBackupPoliciesOperations -from .databases_operations import DatabasesOperations -from .elastic_pools_operations import ElasticPoolsOperations from .replication_links_operations import ReplicationLinksOperations from .server_azure_ad_administrators_operations import ServerAzureADAdministratorsOperations from .server_communication_links_operations import ServerCommunicationLinksOperations from .service_objectives_operations import ServiceObjectivesOperations -from .servers_operations import ServersOperations from .elastic_pool_activities_operations import ElasticPoolActivitiesOperations from .elastic_pool_database_activities_operations import ElasticPoolDatabaseActivitiesOperations from .recommended_elastic_pools_operations import RecommendedElasticPoolsOperations @@ -37,6 +37,7 @@ from .server_usages_operations import ServerUsagesOperations from .database_usages_operations import DatabaseUsagesOperations from .database_blob_auditing_policies_operations import DatabaseBlobAuditingPoliciesOperations +from .database_automatic_tuning_operations import DatabaseAutomaticTuningOperations from .encryption_protectors_operations import EncryptionProtectorsOperations from .failover_groups_operations import FailoverGroupsOperations from .operations import Operations @@ -47,6 +48,7 @@ from .subscription_usages_operations import SubscriptionUsagesOperations from .virtual_network_rules_operations import VirtualNetworkRulesOperations from .database_operations import DatabaseOperations +from .server_automatic_tuning_operations import ServerAutomaticTuningOperations from .server_dns_aliases_operations import ServerDnsAliasesOperations __all__ = [ @@ -56,19 +58,19 @@ 'RecoverableDatabasesOperations', 'RestorableDroppedDatabasesOperations', 'CapabilitiesOperations', + 'ServersOperations', 'ServerConnectionPoliciesOperations', + 'DatabasesOperations', 'DatabaseThreatDetectionPoliciesOperations', 'DataMaskingPoliciesOperations', 'DataMaskingRulesOperations', + 'ElasticPoolsOperations', 'FirewallRulesOperations', 'GeoBackupPoliciesOperations', - 'DatabasesOperations', - 'ElasticPoolsOperations', 'ReplicationLinksOperations', 'ServerAzureADAdministratorsOperations', 'ServerCommunicationLinksOperations', 'ServiceObjectivesOperations', - 'ServersOperations', 'ElasticPoolActivitiesOperations', 'ElasticPoolDatabaseActivitiesOperations', 'RecommendedElasticPoolsOperations', @@ -78,6 +80,7 @@ 'ServerUsagesOperations', 'DatabaseUsagesOperations', 'DatabaseBlobAuditingPoliciesOperations', + 'DatabaseAutomaticTuningOperations', 'EncryptionProtectorsOperations', 'FailoverGroupsOperations', 'Operations', @@ -88,5 +91,6 @@ 'SubscriptionUsagesOperations', 'VirtualNetworkRulesOperations', 'DatabaseOperations', + 'ServerAutomaticTuningOperations', 'ServerDnsAliasesOperations', ] diff --git a/azure-mgmt-sql/azure/mgmt/sql/operations/backup_long_term_retention_policies_operations.py b/azure-mgmt-sql/azure/mgmt/sql/operations/backup_long_term_retention_policies_operations.py index 7e9bd57ac0e7..88393489350a 100644 --- a/azure-mgmt-sql/azure/mgmt/sql/operations/backup_long_term_retention_policies_operations.py +++ b/azure-mgmt-sql/azure/mgmt/sql/operations/backup_long_term_retention_policies_operations.py @@ -12,6 +12,7 @@ import uuid from msrest.pipeline import ClientRawResponse from msrestazure.azure_exceptions import CloudError +from msrest.exceptions import DeserializationError from msrestazure.azure_operation import AzureOperationPoller from .. import models @@ -90,7 +91,7 @@ def get( # Construct and send request request = self._client.get(url, query_parameters) - response = self._client.send(request, header_parameters, **operation_config) + response = self._client.send(request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) @@ -108,35 +109,9 @@ def get( return deserialized - def create_or_update( - self, resource_group_name, server_name, database_name, state, recovery_services_backup_policy_resource_id, custom_headers=None, raw=False, **operation_config): - """Creates or updates a database backup long term retention policy. - :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 state: The status of the backup long term retention policy. - Possible values include: 'Disabled', 'Enabled' - :type state: str or - ~azure.mgmt.sql.models.BackupLongTermRetentionPolicyState - :param recovery_services_backup_policy_resource_id: The azure recovery - services backup protection policy resource id - :type recovery_services_backup_policy_resource_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 - :return: An instance of AzureOperationPoller that returns - BackupLongTermRetentionPolicy or ClientRawResponse if raw=true - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.sql.models.BackupLongTermRetentionPolicy] - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` - """ + def _create_or_update_initial( + self, resource_group_name, server_name, database_name, state, recovery_services_backup_policy_resource_id, custom_headers=None, raw=False, **operation_config): parameters = models.BackupLongTermRetentionPolicy(state=state, recovery_services_backup_policy_resource_id=recovery_services_backup_policy_resource_id) # Construct URL @@ -168,19 +143,83 @@ def create_or_update( body_content = self._serialize.body(parameters, 'BackupLongTermRetentionPolicy') # Construct and send request - def long_running_send(): + request = self._client.put(url, query_parameters) + response = self._client.send( + request, header_parameters, body_content, stream=False, **operation_config) - request = self._client.put(url, query_parameters) - return self._client.send( - request, header_parameters, body_content, **operation_config) + if response.status_code not in [200, 201, 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('BackupLongTermRetentionPolicy', response) + if response.status_code == 201: + deserialized = self._deserialize('BackupLongTermRetentionPolicy', 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, database_name, state, recovery_services_backup_policy_resource_id, custom_headers=None, raw=False, **operation_config): + """Creates or updates a database backup long term retention policy. + + :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 state: The status of the backup long term retention policy. + Possible values include: 'Disabled', 'Enabled' + :type state: str or + ~azure.mgmt.sql.models.BackupLongTermRetentionPolicyState + :param recovery_services_backup_policy_resource_id: The azure recovery + services backup protection policy resource id + :type recovery_services_backup_policy_resource_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 + :return: An instance of AzureOperationPoller that returns + BackupLongTermRetentionPolicy or ClientRawResponse if raw=true + :rtype: + ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.sql.models.BackupLongTermRetentionPolicy] + or ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + state=state, + recovery_services_backup_policy_resource_id=recovery_services_backup_policy_resource_id, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + if raw: + return raw_result + + # Construct and send request + def long_running_send(): + return raw_result.response def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) if headers: request.headers.update(headers) + header_parameters = {} + header_parameters['x-ms-client-request-id'] = raw_result.response.request.headers['x-ms-client-request-id'] return self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) def get_long_running_output(response): @@ -189,12 +228,7 @@ def get_long_running_output(response): exp.request_id = response.headers.get('x-ms-request-id') raise exp - deserialized = None - - if response.status_code == 200: - deserialized = self._deserialize('BackupLongTermRetentionPolicy', response) - if response.status_code == 201: - deserialized = self._deserialize('BackupLongTermRetentionPolicy', response) + deserialized = self._deserialize('BackupLongTermRetentionPolicy', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) @@ -202,10 +236,6 @@ def get_long_running_output(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) @@ -269,7 +299,7 @@ def internal_paging(next_link=None, raw=False): # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) diff --git a/azure-mgmt-sql/azure/mgmt/sql/operations/backup_long_term_retention_vaults_operations.py b/azure-mgmt-sql/azure/mgmt/sql/operations/backup_long_term_retention_vaults_operations.py index f8d54e622b8f..643317a5201c 100644 --- a/azure-mgmt-sql/azure/mgmt/sql/operations/backup_long_term_retention_vaults_operations.py +++ b/azure-mgmt-sql/azure/mgmt/sql/operations/backup_long_term_retention_vaults_operations.py @@ -12,6 +12,7 @@ import uuid from msrest.pipeline import ClientRawResponse from msrestazure.azure_exceptions import CloudError +from msrest.exceptions import DeserializationError from msrestazure.azure_operation import AzureOperationPoller from .. import models @@ -86,7 +87,7 @@ def get( # Construct and send request request = self._client.get(url, query_parameters) - response = self._client.send(request, header_parameters, **operation_config) + response = self._client.send(request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) @@ -104,29 +105,9 @@ def get( return deserialized - def create_or_update( - self, resource_group_name, server_name, recovery_services_vault_resource_id, custom_headers=None, raw=False, **operation_config): - """Updates a server backup long term retention vault. - :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 recovery_services_vault_resource_id: The azure recovery - services vault resource id - :type recovery_services_vault_resource_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 - :return: An instance of AzureOperationPoller that returns - BackupLongTermRetentionVault or ClientRawResponse if raw=true - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.sql.models.BackupLongTermRetentionVault] - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` - """ + def _create_or_update_initial( + self, resource_group_name, server_name, recovery_services_vault_resource_id, custom_headers=None, raw=False, **operation_config): parameters = models.BackupLongTermRetentionVault(recovery_services_vault_resource_id=recovery_services_vault_resource_id) # Construct URL @@ -157,19 +138,75 @@ def create_or_update( body_content = self._serialize.body(parameters, 'BackupLongTermRetentionVault') # Construct and send request - def long_running_send(): + request = self._client.put(url, query_parameters) + response = self._client.send( + request, header_parameters, body_content, stream=False, **operation_config) - request = self._client.put(url, query_parameters) - return self._client.send( - request, header_parameters, body_content, **operation_config) + if response.status_code not in [200, 201, 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('BackupLongTermRetentionVault', response) + if response.status_code == 201: + deserialized = self._deserialize('BackupLongTermRetentionVault', 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, recovery_services_vault_resource_id, custom_headers=None, raw=False, **operation_config): + """Updates a server backup long term retention vault. + + :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 recovery_services_vault_resource_id: The azure recovery + services vault resource id + :type recovery_services_vault_resource_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 + :return: An instance of AzureOperationPoller that returns + BackupLongTermRetentionVault or ClientRawResponse if raw=true + :rtype: + ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.sql.models.BackupLongTermRetentionVault] + or ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + server_name=server_name, + recovery_services_vault_resource_id=recovery_services_vault_resource_id, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + if raw: + return raw_result + + # Construct and send request + def long_running_send(): + return raw_result.response def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) if headers: request.headers.update(headers) + header_parameters = {} + header_parameters['x-ms-client-request-id'] = raw_result.response.request.headers['x-ms-client-request-id'] return self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) def get_long_running_output(response): @@ -178,12 +215,7 @@ def get_long_running_output(response): exp.request_id = response.headers.get('x-ms-request-id') raise exp - deserialized = None - - if response.status_code == 200: - deserialized = self._deserialize('BackupLongTermRetentionVault', response) - if response.status_code == 201: - deserialized = self._deserialize('BackupLongTermRetentionVault', response) + deserialized = self._deserialize('BackupLongTermRetentionVault', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) @@ -191,10 +223,6 @@ def get_long_running_output(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) @@ -255,7 +283,7 @@ def internal_paging(next_link=None, raw=False): # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) diff --git a/azure-mgmt-sql/azure/mgmt/sql/operations/capabilities_operations.py b/azure-mgmt-sql/azure/mgmt/sql/operations/capabilities_operations.py index d9eaf1875d80..fd3384b788eb 100644 --- a/azure-mgmt-sql/azure/mgmt/sql/operations/capabilities_operations.py +++ b/azure-mgmt-sql/azure/mgmt/sql/operations/capabilities_operations.py @@ -77,7 +77,7 @@ def list_by_location( # Construct and send request request = self._client.get(url, query_parameters) - response = self._client.send(request, header_parameters, **operation_config) + response = self._client.send(request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) diff --git a/azure-mgmt-sql/azure/mgmt/sql/operations/data_masking_policies_operations.py b/azure-mgmt-sql/azure/mgmt/sql/operations/data_masking_policies_operations.py index ecc0d06a1860..ae84e8595721 100644 --- a/azure-mgmt-sql/azure/mgmt/sql/operations/data_masking_policies_operations.py +++ b/azure-mgmt-sql/azure/mgmt/sql/operations/data_masking_policies_operations.py @@ -103,7 +103,7 @@ def create_or_update( # Construct and send request request = self._client.put(url, query_parameters) response = self._client.send( - request, header_parameters, body_content, **operation_config) + request, header_parameters, body_content, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) @@ -170,7 +170,7 @@ def get( # Construct and send request request = self._client.get(url, query_parameters) - response = self._client.send(request, header_parameters, **operation_config) + response = self._client.send(request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) diff --git a/azure-mgmt-sql/azure/mgmt/sql/operations/data_masking_rules_operations.py b/azure-mgmt-sql/azure/mgmt/sql/operations/data_masking_rules_operations.py index 2d1b9549a56c..d1acc61f6fba 100644 --- a/azure-mgmt-sql/azure/mgmt/sql/operations/data_masking_rules_operations.py +++ b/azure-mgmt-sql/azure/mgmt/sql/operations/data_masking_rules_operations.py @@ -98,7 +98,7 @@ def create_or_update( # Construct and send request request = self._client.put(url, query_parameters) response = self._client.send( - request, header_parameters, body_content, **operation_config) + request, header_parameters, body_content, stream=False, **operation_config) if response.status_code not in [200, 201]: exp = CloudError(response) @@ -175,7 +175,7 @@ def internal_paging(next_link=None, raw=False): # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) diff --git a/azure-mgmt-sql/azure/mgmt/sql/operations/database_automatic_tuning_operations.py b/azure-mgmt-sql/azure/mgmt/sql/operations/database_automatic_tuning_operations.py new file mode 100644 index 000000000000..006b4bbf630b --- /dev/null +++ b/azure-mgmt-sql/azure/mgmt/sql/operations/database_automatic_tuning_operations.py @@ -0,0 +1,182 @@ +# 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 DatabaseAutomaticTuningOperations(object): + """DatabaseAutomaticTuningOperations 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". + """ + + models = models + + 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, database_name, custom_headers=None, raw=False, **operation_config): + """Gets a database's automatic tuning. + + :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: DatabaseAutomaticTuning or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.sql.models.DatabaseAutomaticTuning or + ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + # Construct URL + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/automaticTuning/current' + 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') + + # 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, stream=False, **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('DatabaseAutomaticTuning', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + def update( + self, resource_group_name, server_name, database_name, desired_state=None, options=None, custom_headers=None, raw=False, **operation_config): + """Update automatic tuning properties for target 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 desired_state: Automatic tuning desired state. Possible values + include: 'Inherit', 'Custom', 'Auto', 'Unspecified' + :type desired_state: str or ~azure.mgmt.sql.models.AutomaticTuningMode + :param options: Automatic tuning options definition. + :type options: dict[str, + ~azure.mgmt.sql.models.AutomaticTuningOptions] + :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: DatabaseAutomaticTuning or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.sql.models.DatabaseAutomaticTuning or + ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + parameters = models.DatabaseAutomaticTuning(desired_state=desired_state, options=options) + + # Construct URL + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/automaticTuning/current' + 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') + + # 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, 'DatabaseAutomaticTuning') + + # Construct and send request + request = self._client.patch(url, query_parameters) + response = self._client.send( + request, header_parameters, body_content, stream=False, **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('DatabaseAutomaticTuning', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized diff --git a/azure-mgmt-sql/azure/mgmt/sql/operations/database_blob_auditing_policies_operations.py b/azure-mgmt-sql/azure/mgmt/sql/operations/database_blob_auditing_policies_operations.py index 4c88d85cfb83..6e59884297e3 100644 --- a/azure-mgmt-sql/azure/mgmt/sql/operations/database_blob_auditing_policies_operations.py +++ b/azure-mgmt-sql/azure/mgmt/sql/operations/database_blob_auditing_policies_operations.py @@ -89,7 +89,7 @@ def get( # Construct and send request request = self._client.get(url, query_parameters) - response = self._client.send(request, header_parameters, **operation_config) + response = self._client.send(request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) @@ -163,7 +163,7 @@ def create_or_update( # Construct and send request request = self._client.put(url, query_parameters) response = self._client.send( - request, header_parameters, body_content, **operation_config) + request, header_parameters, body_content, stream=False, **operation_config) if response.status_code not in [200, 201]: exp = CloudError(response) diff --git a/azure-mgmt-sql/azure/mgmt/sql/operations/database_operations.py b/azure-mgmt-sql/azure/mgmt/sql/operations/database_operations.py index 1a86839a893d..72d8b47a341d 100644 --- a/azure-mgmt-sql/azure/mgmt/sql/operations/database_operations.py +++ b/azure-mgmt-sql/azure/mgmt/sql/operations/database_operations.py @@ -87,7 +87,7 @@ def cancel( # Construct and send request request = self._client.post(url, query_parameters) - response = self._client.send(request, header_parameters, **operation_config) + response = self._client.send(request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) @@ -154,7 +154,7 @@ def internal_paging(next_link=None, raw=False): # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) diff --git a/azure-mgmt-sql/azure/mgmt/sql/operations/database_threat_detection_policies_operations.py b/azure-mgmt-sql/azure/mgmt/sql/operations/database_threat_detection_policies_operations.py index a66f523450a1..64a79fda1606 100644 --- a/azure-mgmt-sql/azure/mgmt/sql/operations/database_threat_detection_policies_operations.py +++ b/azure-mgmt-sql/azure/mgmt/sql/operations/database_threat_detection_policies_operations.py @@ -89,7 +89,7 @@ def get( # Construct and send request request = self._client.get(url, query_parameters) - response = self._client.send(request, header_parameters, **operation_config) + response = self._client.send(request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) @@ -163,7 +163,7 @@ def create_or_update( # Construct and send request request = self._client.put(url, query_parameters) response = self._client.send( - request, header_parameters, body_content, **operation_config) + request, header_parameters, body_content, stream=False, **operation_config) if response.status_code not in [200, 201]: exp = CloudError(response) diff --git a/azure-mgmt-sql/azure/mgmt/sql/operations/database_usages_operations.py b/azure-mgmt-sql/azure/mgmt/sql/operations/database_usages_operations.py index 5667c93847af..312436098cb5 100644 --- a/azure-mgmt-sql/azure/mgmt/sql/operations/database_usages_operations.py +++ b/azure-mgmt-sql/azure/mgmt/sql/operations/database_usages_operations.py @@ -93,7 +93,7 @@ def internal_paging(next_link=None, raw=False): # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) diff --git a/azure-mgmt-sql/azure/mgmt/sql/operations/databases_operations.py b/azure-mgmt-sql/azure/mgmt/sql/operations/databases_operations.py index d6401857ce61..7548052ffbb8 100644 --- a/azure-mgmt-sql/azure/mgmt/sql/operations/databases_operations.py +++ b/azure-mgmt-sql/azure/mgmt/sql/operations/databases_operations.py @@ -12,6 +12,7 @@ import uuid from msrest.pipeline import ClientRawResponse from msrestazure.azure_exceptions import CloudError +from msrest.exceptions import DeserializationError from msrestazure.azure_operation import AzureOperationPoller from .. import models @@ -38,37 +39,18 @@ def __init__(self, client, config, serializer, deserializer): self.config = config - def import_method( - self, resource_group_name, server_name, parameters, custom_headers=None, raw=False, **operation_config): - """Imports a bacpac into a new 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 parameters: The required parameters for importing a Bacpac into - a database. - :type parameters: ~azure.mgmt.sql.models.ImportRequest - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :return: An instance of AzureOperationPoller that returns - ImportExportResponse or ClientRawResponse if raw=true - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.sql.models.ImportExportResponse] - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` - """ + def _pause_initial( + self, resource_group_name, server_name, database_name, custom_headers=None, raw=False, **operation_config): api_version = "2014-04-01" # Construct URL - url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/import' + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/pause' 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') + 'serverName': self._serialize.url("server_name", server_name, 'str'), + 'databaseName': self._serialize.url("database_name", database_name, 'str') } url = self._client.format_url(url, **path_format_arguments) @@ -86,23 +68,64 @@ def import_method( 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, 'ImportRequest') + # Construct and send request + request = self._client.post(url, query_parameters) + response = self._client.send(request, header_parameters, stream=False, **operation_config) + + if response.status_code not in [200, 202]: + 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 pause( + self, resource_group_name, server_name, database_name, custom_headers=None, raw=False, **operation_config): + """Pauses a data warehouse. + + :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 data warehouse to pause. + :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 + :return: An instance of AzureOperationPoller that returns None or + ClientRawResponse if raw=true + :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or + ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + raw_result = self._pause_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + if raw: + return raw_result # Construct and send request def long_running_send(): - - request = self._client.post(url, query_parameters) - return self._client.send( - request, header_parameters, body_content, **operation_config) + return raw_result.response def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) if headers: request.headers.update(headers) + header_parameters = {} + header_parameters['x-ms-client-request-id'] = raw_result.response.request.headers['x-ms-client-request-id'] return self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) def get_long_running_output(response): @@ -111,21 +134,10 @@ def get_long_running_output(response): exp.request_id = response.headers.get('x-ms-request-id') raise exp - deserialized = None - - if response.status_code == 200: - deserialized = self._deserialize('ImportExportResponse', response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) + client_raw_response = ClientRawResponse(None, 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) @@ -133,42 +145,18 @@ def get_long_running_output(response): long_running_send, get_long_running_output, get_long_running_status, long_running_operation_timeout) - def create_import_operation( - self, resource_group_name, server_name, database_name, parameters, custom_headers=None, raw=False, **operation_config): - """Creates an import operation that imports a bacpac into an existing - database. The existing database must be empty. - :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 to import into - :type database_name: str - :param parameters: The required parameters for importing a Bacpac into - a database. - :type parameters: ~azure.mgmt.sql.models.ImportExtensionRequest - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :return: An instance of AzureOperationPoller that returns - ImportExportResponse or ClientRawResponse if raw=true - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.sql.models.ImportExportResponse] - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` - """ + def _resume_initial( + self, resource_group_name, server_name, database_name, custom_headers=None, raw=False, **operation_config): api_version = "2014-04-01" # Construct URL - url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/extensions/{extensionName}' + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/resume' 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'), - 'extensionName': self._serialize.url("self.extension_name", self.extension_name, 'str') + 'databaseName': self._serialize.url("database_name", database_name, 'str') } url = self._client.format_url(url, **path_format_arguments) @@ -186,46 +174,76 @@ def create_import_operation( 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, 'ImportExtensionRequest') + # Construct and send request + request = self._client.post(url, query_parameters) + response = self._client.send(request, header_parameters, stream=False, **operation_config) + + if response.status_code not in [200, 202]: + 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 resume( + self, resource_group_name, server_name, database_name, custom_headers=None, raw=False, **operation_config): + """Resumes a data warehouse. + + :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 data warehouse to resume. + :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 + :return: An instance of AzureOperationPoller that returns None or + ClientRawResponse if raw=true + :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or + ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + raw_result = self._resume_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + if raw: + return raw_result # 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) + return raw_result.response def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) if headers: request.headers.update(headers) + header_parameters = {} + header_parameters['x-ms-client-request-id'] = raw_result.response.request.headers['x-ms-client-request-id'] return self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) def get_long_running_output(response): - if response.status_code not in [201, 202]: + 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 == 201: - deserialized = self._deserialize('ImportExportResponse', response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) + client_raw_response = ClientRawResponse(None, 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) @@ -233,34 +251,13 @@ def get_long_running_output(response): long_running_send, get_long_running_output, get_long_running_status, long_running_operation_timeout) - def export( - self, resource_group_name, server_name, database_name, parameters, custom_headers=None, raw=False, **operation_config): - """Exports a database to a bacpac. - :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 to be exported. - :type database_name: str - :param parameters: The required parameters for exporting a database. - :type parameters: ~azure.mgmt.sql.models.ExportRequest - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :return: An instance of AzureOperationPoller that returns - ImportExportResponse or ClientRawResponse if raw=true - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.sql.models.ImportExportResponse] - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` - """ + def _create_or_update_initial( + self, resource_group_name, server_name, database_name, parameters, custom_headers=None, raw=False, **operation_config): api_version = "2014-04-01" # Construct URL - url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/export' + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}' 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'), @@ -284,34 +281,91 @@ def export( header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct body - body_content = self._serialize.body(parameters, 'ExportRequest') + body_content = self._serialize.body(parameters, 'Database') # Construct and send request - def long_running_send(): + request = self._client.put(url, query_parameters) + response = self._client.send( + request, header_parameters, body_content, stream=False, **operation_config) - request = self._client.post(url, query_parameters) - return self._client.send( - request, header_parameters, body_content, **operation_config) + if response.status_code not in [200, 201, 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('Database', response) + if response.status_code == 201: + deserialized = self._deserialize('Database', 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, database_name, parameters, custom_headers=None, raw=False, **operation_config): + """Creates a new database or updates an existing 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 to be operated on + (updated or created). + :type database_name: str + :param parameters: The required parameters for creating or updating a + database. + :type parameters: ~azure.mgmt.sql.models.Database + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :return: An instance of AzureOperationPoller that returns Database or + ClientRawResponse if raw=true + :rtype: + ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.sql.models.Database] + or ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + parameters=parameters, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + if raw: + return raw_result + + # Construct and send request + def long_running_send(): + return raw_result.response def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) if headers: request.headers.update(headers) + header_parameters = {} + header_parameters['x-ms-client-request-id'] = raw_result.response.request.headers['x-ms-client-request-id'] return self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) def get_long_running_output(response): - if response.status_code not in [200, 202]: + if response.status_code not in [200, 201, 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('ImportExportResponse', response) + deserialized = self._deserialize('Database', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) @@ -319,10 +373,6 @@ def get_long_running_output(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) @@ -330,90 +380,62 @@ def get_long_running_output(response): long_running_send, get_long_running_output, get_long_running_status, long_running_operation_timeout) - def list_metrics( - self, resource_group_name, server_name, database_name, filter, custom_headers=None, raw=False, **operation_config): - """Returns database metrics. - :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 filter: An OData filter expression that describes a subset of - metrics to return. - :type filter: 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 Metric - :rtype: - ~azure.mgmt.sql.models.MetricPaged[~azure.mgmt.sql.models.Metric] - :raises: :class:`CloudError` - """ + def _update_initial( + self, resource_group_name, server_name, database_name, parameters, custom_headers=None, raw=False, **operation_config): api_version = "2014-04-01" - 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}/metrics' - 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') - } - url = self._client.format_url(url, **path_format_arguments) + # Construct URL + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}' + 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') + } + url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("api_version", 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 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, 'DatabaseUpdate') - # Construct and send request - request = self._client.get(url, query_parameters) - response = self._client.send( - request, header_parameters, **operation_config) + # Construct and send request + request = self._client.patch(url, query_parameters) + response = self._client.send( + request, header_parameters, body_content, stream=False, **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 response.status_code not in [200, 202]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp - return response + deserialized = None - # Deserialize response - deserialized = models.MetricPaged(internal_paging, self._deserialize.dependencies) + if response.status_code == 200: + deserialized = self._deserialize('Database', response) if raw: - header_dict = {} - client_raw_response = models.MetricPaged(internal_paging, self._deserialize.dependencies, header_dict) + client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized - def list_metric_definitions( - self, resource_group_name, server_name, database_name, custom_headers=None, raw=False, **operation_config): - """Returns database metric definitions. + def update( + self, resource_group_name, server_name, database_name, parameters, custom_headers=None, raw=False, **operation_config): + """Updates an existing database. :param resource_group_name: The name of the resource group that contains the resource. You can obtain this value from the Azure @@ -421,76 +443,71 @@ def list_metric_definitions( :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. + :param database_name: The name of the database to be updated. :type database_name: str + :param parameters: The required parameters for updating a database. + :type parameters: ~azure.mgmt.sql.models.DatabaseUpdate :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 MetricDefinition + :return: An instance of AzureOperationPoller that returns Database or + ClientRawResponse if raw=true :rtype: - ~azure.mgmt.sql.models.MetricDefinitionPaged[~azure.mgmt.sql.models.MetricDefinition] + ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.sql.models.Database] + or ~msrest.pipeline.ClientRawResponse :raises: :class:`CloudError` """ - api_version = "2014-04-01" - - 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}/metricDefinitions' - 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') - } - url = self._client.format_url(url, **path_format_arguments) + raw_result = self._update_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + parameters=parameters, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + if raw: + return raw_result - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + # Construct and send request + def long_running_send(): + return raw_result.response - else: - url = next_link - query_parameters = {} + def get_long_running_status(status_link, headers=None): - # Construct headers + request = self._client.get(status_link) + if headers: + request.headers.update(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') + header_parameters['x-ms-client-request-id'] = raw_result.response.request.headers['x-ms-client-request-id'] + return self._client.send( + request, header_parameters, stream=False, **operation_config) - # Construct and send request - request = self._client.get(url, query_parameters) - response = self._client.send( - request, header_parameters, **operation_config) + def get_long_running_output(response): - if response.status_code not in [200]: + if response.status_code not in [200, 202]: exp = CloudError(response) exp.request_id = response.headers.get('x-ms-request-id') raise exp - return response + deserialized = self._deserialize('Database', response) - # Deserialize response - deserialized = models.MetricDefinitionPaged(internal_paging, self._deserialize.dependencies) + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response - if raw: - header_dict = {} - client_raw_response = models.MetricDefinitionPaged(internal_paging, self._deserialize.dependencies, header_dict) - return client_raw_response + return deserialized - return deserialized + 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 pause( + def delete( self, resource_group_name, server_name, database_name, custom_headers=None, raw=False, **operation_config): - """Pauses a data warehouse. + """Deletes a database. :param resource_group_name: The name of the resource group that contains the resource. You can obtain this value from the Azure @@ -498,21 +515,21 @@ def pause( :type resource_group_name: str :param server_name: The name of the server. :type server_name: str - :param database_name: The name of the data warehouse to pause. + :param database_name: The name of the database to be deleted. :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 - :return: An instance of AzureOperationPoller that returns None or - ClientRawResponse if raw=true - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrest.pipeline.ClientRawResponse + :param operation_config: :ref:`Operation configuration + overrides`. + :return: None or ClientRawResponse if raw=true + :rtype: None or ~msrest.pipeline.ClientRawResponse :raises: :class:`CloudError` """ api_version = "2014-04-01" # Construct URL - url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/pause' + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}' 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'), @@ -536,44 +553,21 @@ def pause( 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 + request = self._client.delete(url, query_parameters) + response = self._client.send(request, header_parameters, stream=False, **operation_config) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + if response.status_code not in [200, 204]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp 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) + client_raw_response = ClientRawResponse(None, response) + return client_raw_response - def resume( - self, resource_group_name, server_name, database_name, custom_headers=None, raw=False, **operation_config): - """Resumes a data warehouse. + def get( + self, resource_group_name, server_name, database_name, expand=None, custom_headers=None, raw=False, **operation_config): + """Gets a database. :param resource_group_name: The name of the resource group that contains the resource. You can obtain this value from the Azure @@ -581,21 +575,26 @@ def resume( :type resource_group_name: str :param server_name: The name of the server. :type server_name: str - :param database_name: The name of the data warehouse to resume. + :param database_name: The name of the database to be retrieved. :type database_name: str + :param expand: A comma separated list of child objects to expand in + the response. Possible properties: serviceTierAdvisors, + transparentDataEncryption. + :type expand: str :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response - :return: An instance of AzureOperationPoller that returns None or - ClientRawResponse if raw=true - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or + :param operation_config: :ref:`Operation configuration + overrides`. + :return: Database or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.sql.models.Database or ~msrest.pipeline.ClientRawResponse :raises: :class:`CloudError` """ api_version = "2014-04-01" # Construct URL - url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/resume' + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}' 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'), @@ -607,6 +606,8 @@ def resume( # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if expand is not None: + query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') # Construct headers header_parameters = {} @@ -619,44 +620,28 @@ def resume( 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) + request = self._client.get(url, query_parameters) + response = self._client.send(request, header_parameters, stream=False, **operation_config) - def get_long_running_output(response): + if response.status_code not in [200]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp - 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 raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + if response.status_code == 200: + deserialized = self._deserialize('Database', response) if raw: - response = long_running_send() - return get_long_running_output(response) + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_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) + return deserialized - def create_or_update( - self, resource_group_name, server_name, database_name, parameters, custom_headers=None, raw=False, **operation_config): - """Creates a new database or updates an existing database. + def list_by_server( + self, resource_group_name, server_name, expand=None, filter=None, custom_headers=None, raw=False, **operation_config): + """Returns a list of databases 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 @@ -664,100 +649,84 @@ def create_or_update( :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 to be operated on - (updated or created). - :type database_name: str - :param parameters: The required parameters for creating or updating a - database. - :type parameters: ~azure.mgmt.sql.models.Database + :param expand: A comma separated list of child objects to expand in + the response. Possible properties: serviceTierAdvisors, + transparentDataEncryption. + :type expand: str + :param filter: An OData filter expression that describes a subset of + databases to return. + :type filter: str :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response - :return: An instance of AzureOperationPoller that returns Database or - ClientRawResponse if raw=true + :param operation_config: :ref:`Operation configuration + overrides`. + :return: An iterator like instance of Database :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.sql.models.Database] - or ~msrest.pipeline.ClientRawResponse + ~azure.mgmt.sql.models.DatabasePaged[~azure.mgmt.sql.models.Database] :raises: :class:`CloudError` """ api_version = "2014-04-01" - # Construct URL - url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}' - 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') - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("api_version", 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, 'Database') + def internal_paging(next_link=None, raw=False): - # Construct and send request - def long_running_send(): + if not next_link: + # Construct URL + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases' + 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') + } + url = self._client.format_url(url, **path_format_arguments) - request = self._client.put(url, query_parameters) - return self._client.send( - request, header_parameters, body_content, **operation_config) + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if expand is not None: + query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - def get_long_running_status(status_link, headers=None): + else: + url = next_link + query_parameters = {} - request = self._client.get(status_link) - if headers: - request.headers.update(headers) - return self._client.send( - request, header_parameters, **operation_config) + # 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') - def get_long_running_output(response): + # Construct and send request + request = self._client.get(url, query_parameters) + response = self._client.send( + request, header_parameters, stream=False, **operation_config) - if response.status_code not in [200, 201, 202]: + 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('Database', response) - if response.status_code == 201: - deserialized = self._deserialize('Database', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + return response - return deserialized + # Deserialize response + deserialized = models.DatabasePaged(internal_paging, self._deserialize.dependencies) if raw: - response = long_running_send() - return get_long_running_output(response) + header_dict = {} + client_raw_response = models.DatabasePaged(internal_paging, self._deserialize.dependencies, header_dict) + return client_raw_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) + return deserialized - def update( - self, resource_group_name, server_name, database_name, parameters, custom_headers=None, raw=False, **operation_config): - """Updates an existing database. + def get_by_elastic_pool( + self, resource_group_name, server_name, elastic_pool_name, database_name, custom_headers=None, raw=False, **operation_config): + """Gets a database inside of an elastic pool. :param resource_group_name: The name of the resource group that contains the resource. You can obtain this value from the Azure @@ -765,28 +734,30 @@ def update( :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 to be updated. + :param elastic_pool_name: The name of the elastic pool to be + retrieved. + :type elastic_pool_name: str + :param database_name: The name of the database to be retrieved. :type database_name: str - :param parameters: The required parameters for updating a database. - :type parameters: ~azure.mgmt.sql.models.DatabaseUpdate :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response - :return: An instance of AzureOperationPoller that returns Database or - ClientRawResponse if raw=true - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.sql.models.Database] - or ~msrest.pipeline.ClientRawResponse + :param operation_config: :ref:`Operation configuration + overrides`. + :return: Database or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.sql.models.Database or + ~msrest.pipeline.ClientRawResponse :raises: :class:`CloudError` """ api_version = "2014-04-01" # Construct URL - url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}' + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/databases/{databaseName}' 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'), + 'elasticPoolName': self._serialize.url("elastic_pool_name", elastic_pool_name, 'str'), 'databaseName': self._serialize.url("database_name", database_name, 'str') } url = self._client.format_url(url, **path_format_arguments) @@ -805,56 +776,29 @@ def update( 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, 'DatabaseUpdate') - # 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 + request = self._client.get(url, query_parameters) + response = self._client.send(request, header_parameters, stream=False, **operation_config) - if response.status_code == 200: - deserialized = self._deserialize('Database', response) + 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(deserialized, response) - return client_raw_response + deserialized = None - return deserialized + if response.status_code == 200: + deserialized = self._deserialize('Database', response) if raw: - response = long_running_send() - return get_long_running_output(response) + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_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) + return deserialized - def delete( - self, resource_group_name, server_name, database_name, custom_headers=None, raw=False, **operation_config): - """Deletes a database. + def list_by_elastic_pool( + self, resource_group_name, server_name, elastic_pool_name, custom_headers=None, raw=False, **operation_config): + """Returns a list of databases in an elastic pool. :param resource_group_name: The name of the resource group that contains the resource. You can obtain this value from the Azure @@ -862,59 +806,77 @@ def delete( :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 to be deleted. - :type database_name: str + :param elastic_pool_name: The name of the elastic pool to be + retrieved. + :type elastic_pool_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: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse + :return: An iterator like instance of Database + :rtype: + ~azure.mgmt.sql.models.DatabasePaged[~azure.mgmt.sql.models.Database] :raises: :class:`CloudError` """ api_version = "2014-04-01" - # Construct URL - url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}' - 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') - } - url = self._client.format_url(url, **path_format_arguments) + def internal_paging(next_link=None, raw=False): - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if not next_link: + # Construct URL + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/databases' + 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'), + 'elasticPoolName': self._serialize.url("elastic_pool_name", elastic_pool_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) - # 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 parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct and send request - request = self._client.delete(url, query_parameters) - response = self._client.send(request, header_parameters, **operation_config) + else: + url = next_link + query_parameters = {} - if response.status_code not in [200, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + # 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, stream=False, **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.DatabasePaged(internal_paging, self._deserialize.dependencies) if raw: - client_raw_response = ClientRawResponse(None, response) + header_dict = {} + client_raw_response = models.DatabasePaged(internal_paging, self._deserialize.dependencies, header_dict) return client_raw_response - def get( - self, resource_group_name, server_name, database_name, expand=None, custom_headers=None, raw=False, **operation_config): - """Gets a database. + return deserialized + + def get_by_recommended_elastic_pool( + self, resource_group_name, server_name, recommended_elastic_pool_name, database_name, custom_headers=None, raw=False, **operation_config): + """Gets a database inside of a recommented elastic pool. :param resource_group_name: The name of the resource group that contains the resource. You can obtain this value from the Azure @@ -922,12 +884,11 @@ def get( :type resource_group_name: str :param server_name: The name of the server. :type server_name: str + :param recommended_elastic_pool_name: The name of the elastic pool to + be retrieved. + :type recommended_elastic_pool_name: str :param database_name: The name of the database to be retrieved. :type database_name: str - :param expand: A comma separated list of child objects to expand in - the response. Possible properties: serviceTierAdvisors, - transparentDataEncryption. - :type expand: str :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response @@ -941,11 +902,12 @@ def get( api_version = "2014-04-01" # Construct URL - url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}' + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/recommendedElasticPools/{recommendedElasticPoolName}/databases/{databaseName}' 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'), + 'recommendedElasticPoolName': self._serialize.url("recommended_elastic_pool_name", recommended_elastic_pool_name, 'str'), 'databaseName': self._serialize.url("database_name", database_name, 'str') } url = self._client.format_url(url, **path_format_arguments) @@ -953,8 +915,6 @@ def get( # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') # Construct headers header_parameters = {} @@ -968,7 +928,7 @@ def get( # Construct and send request request = self._client.get(url, query_parameters) - response = self._client.send(request, header_parameters, **operation_config) + response = self._client.send(request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) @@ -986,9 +946,9 @@ def get( return deserialized - def list_by_server( - self, resource_group_name, server_name, expand=None, filter=None, custom_headers=None, raw=False, **operation_config): - """Returns a list of databases in a server. + def list_by_recommended_elastic_pool( + self, resource_group_name, server_name, recommended_elastic_pool_name, custom_headers=None, raw=False, **operation_config): + """Returns a list of databases inside a recommented elastic pool. :param resource_group_name: The name of the resource group that contains the resource. You can obtain this value from the Azure @@ -996,13 +956,9 @@ def list_by_server( :type resource_group_name: str :param server_name: The name of the server. :type server_name: str - :param expand: A comma separated list of child objects to expand in - the response. Possible properties: serviceTierAdvisors, - transparentDataEncryption. - :type expand: str - :param filter: An OData filter expression that describes a subset of - databases to return. - :type filter: str + :param recommended_elastic_pool_name: The name of the recommended + elastic pool to be retrieved. + :type recommended_elastic_pool_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 @@ -1019,21 +975,18 @@ 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' + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/recommendedElasticPools/{recommendedElasticPoolName}/databases' 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') + 'serverName': self._serialize.url("server_name", server_name, 'str'), + 'recommendedElasticPoolName': self._serialize.url("recommended_elastic_pool_name", recommended_elastic_pool_name, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') else: url = next_link @@ -1052,28 +1005,205 @@ def internal_paging(next_link=None, raw=False): # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **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 + return response + + # Deserialize response + deserialized = models.DatabasePaged(internal_paging, self._deserialize.dependencies) + + if raw: + header_dict = {} + client_raw_response = models.DatabasePaged(internal_paging, self._deserialize.dependencies, header_dict) + return client_raw_response + + return deserialized + + + def _import_method_initial( + self, resource_group_name, server_name, parameters, custom_headers=None, raw=False, **operation_config): + api_version = "2014-04-01" + + # Construct URL + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/import' + 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') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("api_version", 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, 'ImportRequest') + + # Construct and send request + request = self._client.post(url, query_parameters) + response = self._client.send( + request, header_parameters, body_content, stream=False, **operation_config) + + 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('ImportExportResponse', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + def import_method( + self, resource_group_name, server_name, parameters, custom_headers=None, raw=False, **operation_config): + """Imports a bacpac into a new 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 parameters: The required parameters for importing a Bacpac into + a database. + :type parameters: ~azure.mgmt.sql.models.ImportRequest + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :return: An instance of AzureOperationPoller that returns + ImportExportResponse or ClientRawResponse if raw=true + :rtype: + ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.sql.models.ImportExportResponse] + or ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + raw_result = self._import_method_initial( + resource_group_name=resource_group_name, + server_name=server_name, + parameters=parameters, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + if raw: + return raw_result + + # Construct and send request + def long_running_send(): + return raw_result.response + + def get_long_running_status(status_link, headers=None): + + request = self._client.get(status_link) + if headers: + request.headers.update(headers) + header_parameters = {} + header_parameters['x-ms-client-request-id'] = raw_result.response.request.headers['x-ms-client-request-id'] + return self._client.send( + request, header_parameters, stream=False, **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 = self._deserialize('ImportExportResponse', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + 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 _create_import_operation_initial( + self, resource_group_name, server_name, database_name, parameters, custom_headers=None, raw=False, **operation_config): + api_version = "2014-04-01" + + # Construct URL + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/extensions/{extensionName}' + 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'), + 'extensionName': self._serialize.url("self.extension_name", self.extension_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("api_version", 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, 'ImportExtensionRequest') + + # Construct and send request + request = self._client.put(url, query_parameters) + response = self._client.send( + request, header_parameters, body_content, stream=False, **operation_config) + + if response.status_code not in [201, 202]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + deserialized = None - # Deserialize response - deserialized = models.DatabasePaged(internal_paging, self._deserialize.dependencies) + if response.status_code == 201: + deserialized = self._deserialize('ImportExportResponse', response) if raw: - header_dict = {} - client_raw_response = models.DatabasePaged(internal_paging, self._deserialize.dependencies, header_dict) + client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized - def get_by_elastic_pool( - self, resource_group_name, server_name, elastic_pool_name, database_name, custom_headers=None, raw=False, **operation_config): - """Gets a database inside of an elastic pool. + def create_import_operation( + self, resource_group_name, server_name, database_name, parameters, custom_headers=None, raw=False, **operation_config): + """Creates an import operation that imports a bacpac into an existing + database. The existing database must be empty. :param resource_group_name: The name of the resource group that contains the resource. You can obtain this value from the Azure @@ -1081,30 +1211,80 @@ def get_by_elastic_pool( :type resource_group_name: str :param server_name: The name of the server. :type server_name: str - :param elastic_pool_name: The name of the elastic pool to be - retrieved. - :type elastic_pool_name: str - :param database_name: The name of the database to be retrieved. + :param database_name: The name of the database to import into :type database_name: str + :param parameters: The required parameters for importing a Bacpac into + a database. + :type parameters: ~azure.mgmt.sql.models.ImportExtensionRequest :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: Database or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.sql.models.Database or - ~msrest.pipeline.ClientRawResponse + :return: An instance of AzureOperationPoller that returns + ImportExportResponse or ClientRawResponse if raw=true + :rtype: + ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.sql.models.ImportExportResponse] + or ~msrest.pipeline.ClientRawResponse :raises: :class:`CloudError` """ + raw_result = self._create_import_operation_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + parameters=parameters, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + if raw: + return raw_result + + # Construct and send request + def long_running_send(): + return raw_result.response + + def get_long_running_status(status_link, headers=None): + + request = self._client.get(status_link) + if headers: + request.headers.update(headers) + header_parameters = {} + header_parameters['x-ms-client-request-id'] = raw_result.response.request.headers['x-ms-client-request-id'] + return self._client.send( + request, header_parameters, stream=False, **operation_config) + + def get_long_running_output(response): + + if response.status_code not in [201, 202]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + deserialized = self._deserialize('ImportExportResponse', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + 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 _export_initial( + self, resource_group_name, server_name, database_name, parameters, custom_headers=None, raw=False, **operation_config): api_version = "2014-04-01" # Construct URL - url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/databases/{databaseName}' + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/export' 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'), - 'elasticPoolName': self._serialize.url("elastic_pool_name", elastic_pool_name, 'str'), 'databaseName': self._serialize.url("database_name", database_name, 'str') } url = self._client.format_url(url, **path_format_arguments) @@ -1123,11 +1303,15 @@ def get_by_elastic_pool( 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, 'ExportRequest') + # Construct and send request - request = self._client.get(url, query_parameters) - response = self._client.send(request, header_parameters, **operation_config) + request = self._client.post(url, query_parameters) + response = self._client.send( + request, header_parameters, body_content, stream=False, **operation_config) - if response.status_code not in [200]: + if response.status_code not in [200, 202]: exp = CloudError(response) exp.request_id = response.headers.get('x-ms-request-id') raise exp @@ -1135,7 +1319,7 @@ def get_by_elastic_pool( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Database', response) + deserialized = self._deserialize('ImportExportResponse', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) @@ -1143,9 +1327,9 @@ def get_by_elastic_pool( return deserialized - def list_by_elastic_pool( - self, resource_group_name, server_name, elastic_pool_name, custom_headers=None, raw=False, **operation_config): - """Returns a list of databases in an elastic pool. + def export( + self, resource_group_name, server_name, database_name, parameters, custom_headers=None, raw=False, **operation_config): + """Exports a database to a bacpac. :param resource_group_name: The name of the resource group that contains the resource. You can obtain this value from the Azure @@ -1153,17 +1337,91 @@ def list_by_elastic_pool( :type resource_group_name: str :param server_name: The name of the server. :type server_name: str - :param elastic_pool_name: The name of the elastic pool to be - retrieved. - :type elastic_pool_name: str + :param database_name: The name of the database to be exported. + :type database_name: str + :param parameters: The required parameters for exporting a database. + :type parameters: ~azure.mgmt.sql.models.ExportRequest + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :return: An instance of AzureOperationPoller that returns + ImportExportResponse or ClientRawResponse if raw=true + :rtype: + ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.sql.models.ImportExportResponse] + or ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + raw_result = self._export_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + parameters=parameters, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + if raw: + return raw_result + + # Construct and send request + def long_running_send(): + return raw_result.response + + def get_long_running_status(status_link, headers=None): + + request = self._client.get(status_link) + if headers: + request.headers.update(headers) + header_parameters = {} + header_parameters['x-ms-client-request-id'] = raw_result.response.request.headers['x-ms-client-request-id'] + return self._client.send( + request, header_parameters, stream=False, **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 = self._deserialize('ImportExportResponse', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + 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_metrics( + self, resource_group_name, server_name, database_name, filter, custom_headers=None, raw=False, **operation_config): + """Returns database metrics. + + :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 filter: An OData filter expression that describes a subset of + metrics to return. + :type filter: 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 Database + :return: An iterator like instance of Metric :rtype: - ~azure.mgmt.sql.models.DatabasePaged[~azure.mgmt.sql.models.Database] + ~azure.mgmt.sql.models.MetricPaged[~azure.mgmt.sql.models.Metric] :raises: :class:`CloudError` """ api_version = "2014-04-01" @@ -1172,18 +1430,19 @@ def internal_paging(next_link=None, raw=False): if not next_link: # Construct URL - url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/databases' + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/metrics' 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'), - 'elasticPoolName': self._serialize.url("elastic_pool_name", elastic_pool_name, 'str') + 'databaseName': self._serialize.url("database_name", database_name, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') else: url = next_link @@ -1202,7 +1461,7 @@ def internal_paging(next_link=None, raw=False): # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) @@ -1212,18 +1471,18 @@ def internal_paging(next_link=None, raw=False): return response # Deserialize response - deserialized = models.DatabasePaged(internal_paging, self._deserialize.dependencies) + deserialized = models.MetricPaged(internal_paging, self._deserialize.dependencies) if raw: header_dict = {} - client_raw_response = models.DatabasePaged(internal_paging, self._deserialize.dependencies, header_dict) + client_raw_response = models.MetricPaged(internal_paging, self._deserialize.dependencies, header_dict) return client_raw_response return deserialized - def get_by_recommended_elastic_pool( - self, resource_group_name, server_name, recommended_elastic_pool_name, database_name, custom_headers=None, raw=False, **operation_config): - """Gets a database inside of a recommented elastic pool. + def list_metric_definitions( + self, resource_group_name, server_name, database_name, custom_headers=None, raw=False, **operation_config): + """Returns database metric definitions. :param resource_group_name: The name of the resource group that contains the resource. You can obtain this value from the Azure @@ -1231,89 +1490,16 @@ def get_by_recommended_elastic_pool( :type resource_group_name: str :param server_name: The name of the server. :type server_name: str - :param recommended_elastic_pool_name: The name of the elastic pool to - be retrieved. - :type recommended_elastic_pool_name: str - :param database_name: The name of the database to be retrieved. + :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: Database or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.sql.models.Database or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` - """ - api_version = "2014-04-01" - - # Construct URL - url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/recommendedElasticPools/{recommendedElasticPoolName}/databases/{databaseName}' - 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'), - 'recommendedElasticPoolName': self._serialize.url("recommended_elastic_pool_name", recommended_elastic_pool_name, 'str'), - 'databaseName': self._serialize.url("database_name", database_name, 'str') - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("api_version", 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('Database', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - - return deserialized - - def list_by_recommended_elastic_pool( - self, resource_group_name, server_name, recommended_elastic_pool_name, custom_headers=None, raw=False, **operation_config): - """Returns a list of databases inside a recommented elastic pool. - - :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 recommended_elastic_pool_name: The name of the recommended - elastic pool to be retrieved. - :type recommended_elastic_pool_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 Database + :return: An iterator like instance of MetricDefinition :rtype: - ~azure.mgmt.sql.models.DatabasePaged[~azure.mgmt.sql.models.Database] + ~azure.mgmt.sql.models.MetricDefinitionPaged[~azure.mgmt.sql.models.MetricDefinition] :raises: :class:`CloudError` """ api_version = "2014-04-01" @@ -1322,12 +1508,12 @@ def internal_paging(next_link=None, raw=False): if not next_link: # Construct URL - url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/recommendedElasticPools/{recommendedElasticPoolName}/databases' + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/metricDefinitions' 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'), - 'recommendedElasticPoolName': self._serialize.url("recommended_elastic_pool_name", recommended_elastic_pool_name, 'str') + 'databaseName': self._serialize.url("database_name", database_name, 'str') } url = self._client.format_url(url, **path_format_arguments) @@ -1352,7 +1538,7 @@ def internal_paging(next_link=None, raw=False): # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) @@ -1362,11 +1548,11 @@ def internal_paging(next_link=None, raw=False): return response # Deserialize response - deserialized = models.DatabasePaged(internal_paging, self._deserialize.dependencies) + deserialized = models.MetricDefinitionPaged(internal_paging, self._deserialize.dependencies) if raw: header_dict = {} - client_raw_response = models.DatabasePaged(internal_paging, self._deserialize.dependencies, header_dict) + client_raw_response = models.MetricDefinitionPaged(internal_paging, self._deserialize.dependencies, header_dict) return client_raw_response return deserialized @@ -1428,7 +1614,7 @@ def rename( # Construct and send request request = self._client.post(url, query_parameters) response = self._client.send( - request, header_parameters, body_content, **operation_config) + request, header_parameters, body_content, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) diff --git a/azure-mgmt-sql/azure/mgmt/sql/operations/elastic_pool_activities_operations.py b/azure-mgmt-sql/azure/mgmt/sql/operations/elastic_pool_activities_operations.py index ffaa12964b74..bc31e1e43f0c 100644 --- a/azure-mgmt-sql/azure/mgmt/sql/operations/elastic_pool_activities_operations.py +++ b/azure-mgmt-sql/azure/mgmt/sql/operations/elastic_pool_activities_operations.py @@ -94,7 +94,7 @@ def internal_paging(next_link=None, raw=False): # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) diff --git a/azure-mgmt-sql/azure/mgmt/sql/operations/elastic_pool_database_activities_operations.py b/azure-mgmt-sql/azure/mgmt/sql/operations/elastic_pool_database_activities_operations.py index a42d8425b631..d5807e30537a 100644 --- a/azure-mgmt-sql/azure/mgmt/sql/operations/elastic_pool_database_activities_operations.py +++ b/azure-mgmt-sql/azure/mgmt/sql/operations/elastic_pool_database_activities_operations.py @@ -93,7 +93,7 @@ def internal_paging(next_link=None, raw=False): # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) diff --git a/azure-mgmt-sql/azure/mgmt/sql/operations/elastic_pools_operations.py b/azure-mgmt-sql/azure/mgmt/sql/operations/elastic_pools_operations.py index caed9d6e6da6..9ade5cac6fdf 100644 --- a/azure-mgmt-sql/azure/mgmt/sql/operations/elastic_pools_operations.py +++ b/azure-mgmt-sql/azure/mgmt/sql/operations/elastic_pools_operations.py @@ -12,6 +12,7 @@ import uuid from msrest.pipeline import ClientRawResponse from msrestazure.azure_exceptions import CloudError +from msrest.exceptions import DeserializationError from msrestazure.azure_operation import AzureOperationPoller from .. import models @@ -38,88 +39,62 @@ def __init__(self, client, config, serializer, deserializer): self.config = config - def list_metrics( - self, resource_group_name, server_name, elastic_pool_name, filter, custom_headers=None, raw=False, **operation_config): - """Returns elastic pool metrics. - :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 elastic_pool_name: The name of the elastic pool. - :type elastic_pool_name: str - :param filter: An OData filter expression that describes a subset of - metrics to return. - :type filter: 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 Metric - :rtype: - ~azure.mgmt.sql.models.MetricPaged[~azure.mgmt.sql.models.Metric] - :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}/elasticPools/{elasticPoolName}/metrics' - 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'), - 'elasticPoolName': self._serialize.url("elastic_pool_name", elastic_pool_name, 'str') - } - url = self._client.format_url(url, **path_format_arguments) + def _create_or_update_initial( + self, resource_group_name, server_name, elastic_pool_name, parameters, custom_headers=None, raw=False, **operation_config): + # Construct URL + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}' + 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'), + 'elasticPoolName': self._serialize.url("elastic_pool_name", elastic_pool_name, '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') - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + # 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 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, 'ElasticPool') - # Construct and send request - request = self._client.get(url, query_parameters) - response = self._client.send( - request, header_parameters, **operation_config) + # Construct and send request + request = self._client.put(url, query_parameters) + response = self._client.send( + request, header_parameters, body_content, stream=False, **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 response.status_code not in [200, 201, 202]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp - return response + deserialized = None - # Deserialize response - deserialized = models.MetricPaged(internal_paging, self._deserialize.dependencies) + if response.status_code == 200: + deserialized = self._deserialize('ElasticPool', response) + if response.status_code == 201: + deserialized = self._deserialize('ElasticPool', response) if raw: - header_dict = {} - client_raw_response = models.MetricPaged(internal_paging, self._deserialize.dependencies, header_dict) + client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized - def list_metric_definitions( - self, resource_group_name, server_name, elastic_pool_name, custom_headers=None, raw=False, **operation_config): - """Returns elastic pool metric definitions. + def create_or_update( + self, resource_group_name, server_name, elastic_pool_name, parameters, custom_headers=None, raw=False, **operation_config): + """Creates a new elastic pool or updates an existing elastic pool. :param resource_group_name: The name of the resource group that contains the resource. You can obtain this value from the Azure @@ -127,97 +102,73 @@ def list_metric_definitions( :type resource_group_name: str :param server_name: The name of the server. :type server_name: str - :param elastic_pool_name: The name of the elastic pool. + :param elastic_pool_name: The name of the elastic pool to be operated + on (updated or created). :type elastic_pool_name: str + :param parameters: The required parameters for creating or updating an + elastic pool. + :type parameters: ~azure.mgmt.sql.models.ElasticPool :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 MetricDefinition + :return: An instance of AzureOperationPoller that returns ElasticPool + or ClientRawResponse if raw=true :rtype: - ~azure.mgmt.sql.models.MetricDefinitionPaged[~azure.mgmt.sql.models.MetricDefinition] + ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.sql.models.ElasticPool] + or ~msrest.pipeline.ClientRawResponse :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}/elasticPools/{elasticPoolName}/metricDefinitions' - 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'), - 'elasticPoolName': self._serialize.url("elastic_pool_name", elastic_pool_name, 'str') - } - url = self._client.format_url(url, **path_format_arguments) + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + server_name=server_name, + elastic_pool_name=elastic_pool_name, + parameters=parameters, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + if raw: + return raw_result - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + # Construct and send request + def long_running_send(): + return raw_result.response - else: - url = next_link - query_parameters = {} + def get_long_running_status(status_link, headers=None): - # Construct headers + request = self._client.get(status_link) + if headers: + request.headers.update(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') + header_parameters['x-ms-client-request-id'] = raw_result.response.request.headers['x-ms-client-request-id'] + return self._client.send( + request, header_parameters, stream=False, **operation_config) - # Construct and send request - request = self._client.get(url, query_parameters) - response = self._client.send( - request, header_parameters, **operation_config) + def get_long_running_output(response): - if response.status_code not in [200]: + if response.status_code not in [200, 201, 202]: exp = CloudError(response) exp.request_id = response.headers.get('x-ms-request-id') raise exp - return response + deserialized = self._deserialize('ElasticPool', response) - # Deserialize response - deserialized = models.MetricDefinitionPaged(internal_paging, self._deserialize.dependencies) + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response - if raw: - header_dict = {} - client_raw_response = models.MetricDefinitionPaged(internal_paging, self._deserialize.dependencies, header_dict) - return client_raw_response + return deserialized - return deserialized + 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 create_or_update( - self, resource_group_name, server_name, elastic_pool_name, parameters, custom_headers=None, raw=False, **operation_config): - """Creates a new elastic pool or updates an existing elastic pool. - :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 elastic_pool_name: The name of the elastic pool to be operated - on (updated or created). - :type elastic_pool_name: str - :param parameters: The required parameters for creating or updating an - elastic pool. - :type parameters: ~azure.mgmt.sql.models.ElasticPool - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :return: An instance of AzureOperationPoller that returns ElasticPool - or ClientRawResponse if raw=true - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.sql.models.ElasticPool] - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` - """ + def _update_initial( + self, resource_group_name, server_name, elastic_pool_name, parameters, custom_headers=None, raw=False, **operation_config): # Construct URL url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}' path_format_arguments = { @@ -243,53 +194,28 @@ def create_or_update( header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct body - body_content = self._serialize.body(parameters, 'ElasticPool') + body_content = self._serialize.body(parameters, 'ElasticPoolUpdate') # 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) + request = self._client.patch(url, query_parameters) + response = self._client.send( + request, header_parameters, body_content, stream=False, **operation_config) - def get_long_running_output(response): - - if response.status_code not in [200, 201, 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('ElasticPool', response) - if response.status_code == 201: - deserialized = self._deserialize('ElasticPool', response) + if response.status_code not in [200, 202]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + deserialized = None - return deserialized + if response.status_code == 200: + deserialized = self._deserialize('ElasticPool', response) if raw: - response = long_running_send() - return get_long_running_output(response) + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_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) + return deserialized def update( self, resource_group_name, server_name, elastic_pool_name, parameters, custom_headers=None, raw=False, **operation_config): @@ -316,47 +242,31 @@ def update( or ~msrest.pipeline.ClientRawResponse :raises: :class:`CloudError` """ - # Construct URL - url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}' - 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'), - 'elasticPoolName': self._serialize.url("elastic_pool_name", elastic_pool_name, '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, 'ElasticPoolUpdate') + raw_result = self._update_initial( + resource_group_name=resource_group_name, + server_name=server_name, + elastic_pool_name=elastic_pool_name, + parameters=parameters, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + if raw: + return raw_result # 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) + return raw_result.response def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) if headers: request.headers.update(headers) + header_parameters = {} + header_parameters['x-ms-client-request-id'] = raw_result.response.request.headers['x-ms-client-request-id'] return self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) def get_long_running_output(response): @@ -365,10 +275,7 @@ def get_long_running_output(response): exp.request_id = response.headers.get('x-ms-request-id') raise exp - deserialized = None - - if response.status_code == 200: - deserialized = self._deserialize('ElasticPool', response) + deserialized = self._deserialize('ElasticPool', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) @@ -376,10 +283,6 @@ def get_long_running_output(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) @@ -434,7 +337,7 @@ def delete( # Construct and send request request = self._client.delete(url, query_parameters) - response = self._client.send(request, header_parameters, **operation_config) + response = self._client.send(request, header_parameters, stream=False, **operation_config) if response.status_code not in [200, 204]: exp = CloudError(response) @@ -494,7 +397,7 @@ def get( # Construct and send request request = self._client.get(url, query_parameters) - response = self._client.send(request, header_parameters, **operation_config) + response = self._client.send(request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) @@ -565,7 +468,7 @@ def internal_paging(next_link=None, raw=False): # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) @@ -583,3 +486,157 @@ def internal_paging(next_link=None, raw=False): return client_raw_response return deserialized + + def list_metrics( + self, resource_group_name, server_name, elastic_pool_name, filter, custom_headers=None, raw=False, **operation_config): + """Returns elastic pool metrics. + + :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 elastic_pool_name: The name of the elastic pool. + :type elastic_pool_name: str + :param filter: An OData filter expression that describes a subset of + metrics to return. + :type filter: 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 Metric + :rtype: + ~azure.mgmt.sql.models.MetricPaged[~azure.mgmt.sql.models.Metric] + :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}/elasticPools/{elasticPoolName}/metrics' + 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'), + 'elasticPoolName': self._serialize.url("elastic_pool_name", elastic_pool_name, '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') + query_parameters['$filter'] = self._serialize.query("filter", filter, '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, stream=False, **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.MetricPaged(internal_paging, self._deserialize.dependencies) + + if raw: + header_dict = {} + client_raw_response = models.MetricPaged(internal_paging, self._deserialize.dependencies, header_dict) + return client_raw_response + + return deserialized + + def list_metric_definitions( + self, resource_group_name, server_name, elastic_pool_name, custom_headers=None, raw=False, **operation_config): + """Returns elastic pool metric definitions. + + :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 elastic_pool_name: The name of the elastic pool. + :type elastic_pool_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 MetricDefinition + :rtype: + ~azure.mgmt.sql.models.MetricDefinitionPaged[~azure.mgmt.sql.models.MetricDefinition] + :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}/elasticPools/{elasticPoolName}/metricDefinitions' + 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'), + 'elasticPoolName': self._serialize.url("elastic_pool_name", elastic_pool_name, '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, stream=False, **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.MetricDefinitionPaged(internal_paging, self._deserialize.dependencies) + + if raw: + header_dict = {} + client_raw_response = models.MetricDefinitionPaged(internal_paging, self._deserialize.dependencies, header_dict) + return client_raw_response + + return deserialized diff --git a/azure-mgmt-sql/azure/mgmt/sql/operations/encryption_protectors_operations.py b/azure-mgmt-sql/azure/mgmt/sql/operations/encryption_protectors_operations.py index 5b1c4a3ab083..3d3cf99ba0ed 100644 --- a/azure-mgmt-sql/azure/mgmt/sql/operations/encryption_protectors_operations.py +++ b/azure-mgmt-sql/azure/mgmt/sql/operations/encryption_protectors_operations.py @@ -12,6 +12,7 @@ import uuid from msrest.pipeline import ClientRawResponse from msrestazure.azure_exceptions import CloudError +from msrest.exceptions import DeserializationError from msrestazure.azure_operation import AzureOperationPoller from .. import models @@ -93,7 +94,7 @@ def internal_paging(next_link=None, raw=False): # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) @@ -158,7 +159,7 @@ def get( # Construct and send request request = self._client.get(url, query_parameters) - response = self._client.send(request, header_parameters, **operation_config) + response = self._client.send(request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) @@ -176,28 +177,9 @@ def get( return deserialized - def create_or_update( - self, resource_group_name, server_name, parameters, custom_headers=None, raw=False, **operation_config): - """Updates an existing encryption protector. - :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 parameters: The requested encryption protector resource state. - :type parameters: ~azure.mgmt.sql.models.EncryptionProtector - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :return: An instance of AzureOperationPoller that returns - EncryptionProtector or ClientRawResponse if raw=true - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.sql.models.EncryptionProtector] - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` - """ + def _create_or_update_initial( + self, resource_group_name, server_name, parameters, custom_headers=None, raw=False, **operation_config): # Construct URL url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/encryptionProtector/{encryptionProtectorName}' path_format_arguments = { @@ -226,19 +208,72 @@ def create_or_update( body_content = self._serialize.body(parameters, 'EncryptionProtector') # Construct and send request - def long_running_send(): + request = self._client.put(url, query_parameters) + response = self._client.send( + request, header_parameters, body_content, stream=False, **operation_config) - request = self._client.put(url, query_parameters) - return self._client.send( - request, header_parameters, body_content, **operation_config) + 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('EncryptionProtector', 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, parameters, custom_headers=None, raw=False, **operation_config): + """Updates an existing encryption protector. + + :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 parameters: The requested encryption protector resource state. + :type parameters: ~azure.mgmt.sql.models.EncryptionProtector + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :return: An instance of AzureOperationPoller that returns + EncryptionProtector or ClientRawResponse if raw=true + :rtype: + ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.sql.models.EncryptionProtector] + or ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + server_name=server_name, + parameters=parameters, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + if raw: + return raw_result + + # Construct and send request + def long_running_send(): + return raw_result.response def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) if headers: request.headers.update(headers) + header_parameters = {} + header_parameters['x-ms-client-request-id'] = raw_result.response.request.headers['x-ms-client-request-id'] return self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) def get_long_running_output(response): @@ -247,10 +282,7 @@ def get_long_running_output(response): exp.request_id = response.headers.get('x-ms-request-id') raise exp - deserialized = None - - if response.status_code == 200: - deserialized = self._deserialize('EncryptionProtector', response) + deserialized = self._deserialize('EncryptionProtector', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) @@ -258,10 +290,6 @@ def get_long_running_output(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) 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 index 966f83bb68b5..b2e5dba8c39b 100644 --- a/azure-mgmt-sql/azure/mgmt/sql/operations/failover_groups_operations.py +++ b/azure-mgmt-sql/azure/mgmt/sql/operations/failover_groups_operations.py @@ -12,6 +12,7 @@ import uuid from msrest.pipeline import ClientRawResponse from msrestazure.azure_exceptions import CloudError +from msrest.exceptions import DeserializationError from msrestazure.azure_operation import AzureOperationPoller from .. import models @@ -87,7 +88,7 @@ def get( # Construct and send request request = self._client.get(url, query_parameters) - response = self._client.send(request, header_parameters, **operation_config) + response = self._client.send(request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) @@ -105,31 +106,9 @@ def get( 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: ~azure.mgmt.sql.models.FailoverGroup - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :return: An instance of AzureOperationPoller that returns - FailoverGroup or ClientRawResponse if raw=true - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.sql.models.FailoverGroup] - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` - """ + def _create_or_update_initial( + self, resource_group_name, server_name, failover_group_name, parameters, custom_headers=None, raw=False, **operation_config): # Construct URL url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}' path_format_arguments = { @@ -158,19 +137,78 @@ def create_or_update( body_content = self._serialize.body(parameters, 'FailoverGroup') # Construct and send request - def long_running_send(): + request = self._client.put(url, query_parameters) + response = self._client.send( + request, header_parameters, body_content, stream=False, **operation_config) - request = self._client.put(url, query_parameters) - return self._client.send( - request, header_parameters, body_content, **operation_config) + if response.status_code not in [200, 201, 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 response.status_code == 201: + 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: ~azure.mgmt.sql.models.FailoverGroup + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :return: An instance of AzureOperationPoller that returns + FailoverGroup or ClientRawResponse if raw=true + :rtype: + ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.sql.models.FailoverGroup] + or ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + server_name=server_name, + failover_group_name=failover_group_name, + parameters=parameters, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + if raw: + return raw_result + + # Construct and send request + def long_running_send(): + return raw_result.response def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) if headers: request.headers.update(headers) + header_parameters = {} + header_parameters['x-ms-client-request-id'] = raw_result.response.request.headers['x-ms-client-request-id'] return self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) def get_long_running_output(response): @@ -179,12 +217,7 @@ def get_long_running_output(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) + deserialized = self._deserialize('FailoverGroup', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) @@ -192,10 +225,6 @@ def get_long_running_output(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) @@ -203,28 +232,9 @@ def get_long_running_output(response): 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 - :return: An instance of AzureOperationPoller that returns None or - ClientRawResponse if raw=true - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` - """ + def _delete_initial( + self, resource_group_name, server_name, failover_group_name, custom_headers=None, raw=False, **operation_config): # Construct URL url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}' path_format_arguments = { @@ -250,18 +260,64 @@ def delete( 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) + response = self._client.send(request, header_parameters, stream=False, **operation_config) - request = self._client.delete(url, query_parameters) - return self._client.send(request, header_parameters, **operation_config) + 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 + + 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 + :return: An instance of AzureOperationPoller that returns None or + ClientRawResponse if raw=true + :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or + ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + server_name=server_name, + failover_group_name=failover_group_name, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + if raw: + return raw_result + + # Construct and send request + def long_running_send(): + return raw_result.response def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) if headers: request.headers.update(headers) + header_parameters = {} + header_parameters['x-ms-client-request-id'] = raw_result.response.request.headers['x-ms-client-request-id'] return self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) def get_long_running_output(response): @@ -274,10 +330,6 @@ def get_long_running_output(response): 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) @@ -285,31 +337,9 @@ def get_long_running_output(response): 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: ~azure.mgmt.sql.models.FailoverGroupUpdate - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :return: An instance of AzureOperationPoller that returns - FailoverGroup or ClientRawResponse if raw=true - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.sql.models.FailoverGroup] - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` - """ + def _update_initial( + self, resource_group_name, server_name, failover_group_name, parameters, custom_headers=None, raw=False, **operation_config): # Construct URL url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}' path_format_arguments = { @@ -338,19 +368,76 @@ def update( body_content = self._serialize.body(parameters, 'FailoverGroupUpdate') # Construct and send request - def long_running_send(): + request = self._client.patch(url, query_parameters) + response = self._client.send( + request, header_parameters, body_content, stream=False, **operation_config) - request = self._client.patch(url, query_parameters) - return self._client.send( - request, header_parameters, body_content, **operation_config) + 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 + + 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: ~azure.mgmt.sql.models.FailoverGroupUpdate + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :return: An instance of AzureOperationPoller that returns + FailoverGroup or ClientRawResponse if raw=true + :rtype: + ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.sql.models.FailoverGroup] + or ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + raw_result = self._update_initial( + resource_group_name=resource_group_name, + server_name=server_name, + failover_group_name=failover_group_name, + parameters=parameters, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + if raw: + return raw_result + + # Construct and send request + def long_running_send(): + return raw_result.response def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) if headers: request.headers.update(headers) + header_parameters = {} + header_parameters['x-ms-client-request-id'] = raw_result.response.request.headers['x-ms-client-request-id'] return self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) def get_long_running_output(response): @@ -359,10 +446,7 @@ def get_long_running_output(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) + deserialized = self._deserialize('FailoverGroup', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) @@ -370,10 +454,6 @@ def get_long_running_output(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) @@ -435,7 +515,7 @@ def internal_paging(next_link=None, raw=False): # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) @@ -454,29 +534,9 @@ def internal_paging(next_link=None, raw=False): 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 - :return: An instance of AzureOperationPoller that returns - FailoverGroup or ClientRawResponse if raw=true - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.sql.models.FailoverGroup] - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` - """ + def _failover_initial( + self, resource_group_name, server_name, failover_group_name, custom_headers=None, raw=False, **operation_config): # Construct URL url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}/failover' path_format_arguments = { @@ -502,18 +562,72 @@ def failover( 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) + response = self._client.send(request, header_parameters, stream=False, **operation_config) + + 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 + + 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 + :return: An instance of AzureOperationPoller that returns + FailoverGroup or ClientRawResponse if raw=true + :rtype: + ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.sql.models.FailoverGroup] + or ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + raw_result = self._failover_initial( + resource_group_name=resource_group_name, + server_name=server_name, + failover_group_name=failover_group_name, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + if raw: + return raw_result - request = self._client.post(url, query_parameters) - return self._client.send(request, header_parameters, **operation_config) + # Construct and send request + def long_running_send(): + return raw_result.response def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) if headers: request.headers.update(headers) + header_parameters = {} + header_parameters['x-ms-client-request-id'] = raw_result.response.request.headers['x-ms-client-request-id'] return self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) def get_long_running_output(response): @@ -522,10 +636,7 @@ def get_long_running_output(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) + deserialized = self._deserialize('FailoverGroup', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) @@ -533,10 +644,6 @@ def get_long_running_output(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) @@ -544,30 +651,9 @@ def get_long_running_output(response): 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 - :return: An instance of AzureOperationPoller that returns - FailoverGroup or ClientRawResponse if raw=true - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.sql.models.FailoverGroup] - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` - """ + def _force_failover_allow_data_loss_initial( + self, resource_group_name, server_name, failover_group_name, custom_headers=None, raw=False, **operation_config): # Construct URL url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}/forceFailoverAllowDataLoss' path_format_arguments = { @@ -593,18 +679,73 @@ def force_failover_allow_data_loss( 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) + response = self._client.send(request, header_parameters, stream=False, **operation_config) - request = self._client.post(url, query_parameters) - return self._client.send(request, header_parameters, **operation_config) + 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 + + 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 + :return: An instance of AzureOperationPoller that returns + FailoverGroup or ClientRawResponse if raw=true + :rtype: + ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.sql.models.FailoverGroup] + or ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + raw_result = self._force_failover_allow_data_loss_initial( + resource_group_name=resource_group_name, + server_name=server_name, + failover_group_name=failover_group_name, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + if raw: + return raw_result + + # Construct and send request + def long_running_send(): + return raw_result.response def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) if headers: request.headers.update(headers) + header_parameters = {} + header_parameters['x-ms-client-request-id'] = raw_result.response.request.headers['x-ms-client-request-id'] return self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) def get_long_running_output(response): @@ -613,10 +754,7 @@ def get_long_running_output(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) + deserialized = self._deserialize('FailoverGroup', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) @@ -624,10 +762,6 @@ def get_long_running_output(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) diff --git a/azure-mgmt-sql/azure/mgmt/sql/operations/firewall_rules_operations.py b/azure-mgmt-sql/azure/mgmt/sql/operations/firewall_rules_operations.py index 244ce10f1e76..9fb743feb379 100644 --- a/azure-mgmt-sql/azure/mgmt/sql/operations/firewall_rules_operations.py +++ b/azure-mgmt-sql/azure/mgmt/sql/operations/firewall_rules_operations.py @@ -99,7 +99,7 @@ def create_or_update( # Construct and send request request = self._client.put(url, query_parameters) response = self._client.send( - request, header_parameters, body_content, **operation_config) + request, header_parameters, body_content, stream=False, **operation_config) if response.status_code not in [200, 201]: exp = CloudError(response) @@ -166,7 +166,7 @@ def delete( # Construct and send request request = self._client.delete(url, query_parameters) - response = self._client.send(request, header_parameters, **operation_config) + response = self._client.send(request, header_parameters, stream=False, **operation_config) if response.status_code not in [200, 204]: exp = CloudError(response) @@ -225,7 +225,7 @@ def get( # Construct and send request request = self._client.get(url, query_parameters) - response = self._client.send(request, header_parameters, **operation_config) + response = self._client.send(request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) @@ -296,7 +296,7 @@ def internal_paging(next_link=None, raw=False): # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) diff --git a/azure-mgmt-sql/azure/mgmt/sql/operations/geo_backup_policies_operations.py b/azure-mgmt-sql/azure/mgmt/sql/operations/geo_backup_policies_operations.py index 6ae1a0f10865..62dedc77c992 100644 --- a/azure-mgmt-sql/azure/mgmt/sql/operations/geo_backup_policies_operations.py +++ b/azure-mgmt-sql/azure/mgmt/sql/operations/geo_backup_policies_operations.py @@ -97,7 +97,7 @@ def create_or_update( # Construct and send request request = self._client.put(url, query_parameters) response = self._client.send( - request, header_parameters, body_content, **operation_config) + request, header_parameters, body_content, stream=False, **operation_config) if response.status_code not in [200, 201]: exp = CloudError(response) @@ -166,7 +166,7 @@ def get( # Construct and send request request = self._client.get(url, query_parameters) - response = self._client.send(request, header_parameters, **operation_config) + response = self._client.send(request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) @@ -240,7 +240,7 @@ def internal_paging(next_link=None, raw=False): # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) diff --git a/azure-mgmt-sql/azure/mgmt/sql/operations/operations.py b/azure-mgmt-sql/azure/mgmt/sql/operations/operations.py index 33033408bf61..e841422f649d 100644 --- a/azure-mgmt-sql/azure/mgmt/sql/operations/operations.py +++ b/azure-mgmt-sql/azure/mgmt/sql/operations/operations.py @@ -78,7 +78,7 @@ def internal_paging(next_link=None, raw=False): # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) diff --git a/azure-mgmt-sql/azure/mgmt/sql/operations/recommended_elastic_pools_operations.py b/azure-mgmt-sql/azure/mgmt/sql/operations/recommended_elastic_pools_operations.py index a87c927f50a8..42f2ad653ac5 100644 --- a/azure-mgmt-sql/azure/mgmt/sql/operations/recommended_elastic_pools_operations.py +++ b/azure-mgmt-sql/azure/mgmt/sql/operations/recommended_elastic_pools_operations.py @@ -86,7 +86,7 @@ def get( # Construct and send request request = self._client.get(url, query_parameters) - response = self._client.send(request, header_parameters, **operation_config) + response = self._client.send(request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) @@ -157,7 +157,7 @@ def internal_paging(next_link=None, raw=False): # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) @@ -233,7 +233,7 @@ def internal_paging(next_link=None, raw=False): # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) diff --git a/azure-mgmt-sql/azure/mgmt/sql/operations/recoverable_databases_operations.py b/azure-mgmt-sql/azure/mgmt/sql/operations/recoverable_databases_operations.py index efbe6d1a0235..831eecf07511 100644 --- a/azure-mgmt-sql/azure/mgmt/sql/operations/recoverable_databases_operations.py +++ b/azure-mgmt-sql/azure/mgmt/sql/operations/recoverable_databases_operations.py @@ -86,7 +86,7 @@ def get( # Construct and send request request = self._client.get(url, query_parameters) - response = self._client.send(request, header_parameters, **operation_config) + response = self._client.send(request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) @@ -157,7 +157,7 @@ def internal_paging(next_link=None, raw=False): # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) diff --git a/azure-mgmt-sql/azure/mgmt/sql/operations/replication_links_operations.py b/azure-mgmt-sql/azure/mgmt/sql/operations/replication_links_operations.py index 311ba77bcd2e..1dc5b0c7e3eb 100644 --- a/azure-mgmt-sql/azure/mgmt/sql/operations/replication_links_operations.py +++ b/azure-mgmt-sql/azure/mgmt/sql/operations/replication_links_operations.py @@ -12,6 +12,7 @@ import uuid from msrest.pipeline import ClientRawResponse from msrestazure.azure_exceptions import CloudError +from msrest.exceptions import DeserializationError from msrestazure.azure_operation import AzureOperationPoller from .. import models @@ -89,7 +90,7 @@ def delete( # Construct and send request request = self._client.delete(url, query_parameters) - response = self._client.send(request, header_parameters, **operation_config) + response = self._client.send(request, header_parameters, stream=False, **operation_config) if response.status_code not in [200, 204]: exp = CloudError(response) @@ -151,7 +152,7 @@ def get( # Construct and send request request = self._client.get(url, query_parameters) - response = self._client.send(request, header_parameters, **operation_config) + response = self._client.send(request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) @@ -169,31 +170,9 @@ def get( return deserialized - def failover( - self, resource_group_name, server_name, database_name, link_id, custom_headers=None, raw=False, **operation_config): - """Sets which replica database is primary by failing over from the current - primary replica 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 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 dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :return: An instance of AzureOperationPoller that returns None or - ClientRawResponse if raw=true - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` - """ + def _failover_initial( + self, resource_group_name, server_name, database_name, link_id, custom_headers=None, raw=False, **operation_config): # Construct URL url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/replicationLinks/{linkId}/failover' path_format_arguments = { @@ -220,18 +199,68 @@ def failover( 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) + response = self._client.send(request, header_parameters, 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 - request = self._client.post(url, query_parameters) - return self._client.send(request, header_parameters, **operation_config) + def failover( + self, resource_group_name, server_name, database_name, link_id, custom_headers=None, raw=False, **operation_config): + """Sets which replica database is primary by failing over from the current + primary replica 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 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 dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :return: An instance of AzureOperationPoller that returns None or + ClientRawResponse if raw=true + :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or + ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + raw_result = self._failover_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + link_id=link_id, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + if raw: + return raw_result + + # Construct and send request + def long_running_send(): + return raw_result.response def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) if headers: request.headers.update(headers) + header_parameters = {} + header_parameters['x-ms-client-request-id'] = raw_result.response.request.headers['x-ms-client-request-id'] return self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) def get_long_running_output(response): @@ -244,10 +273,6 @@ def get_long_running_output(response): 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) @@ -255,31 +280,9 @@ def get_long_running_output(response): long_running_send, get_long_running_output, get_long_running_status, long_running_operation_timeout) - def failover_allow_data_loss( - self, resource_group_name, server_name, database_name, link_id, custom_headers=None, raw=False, **operation_config): - """Sets which replica database is primary by failing over from the current - primary replica database. 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. - :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 dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :return: An instance of AzureOperationPoller that returns None or - ClientRawResponse if raw=true - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` - """ + def _failover_allow_data_loss_initial( + self, resource_group_name, server_name, database_name, link_id, custom_headers=None, raw=False, **operation_config): # Construct URL url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/replicationLinks/{linkId}/forceFailoverAllowDataLoss' path_format_arguments = { @@ -306,18 +309,68 @@ def failover_allow_data_loss( 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) + response = self._client.send(request, header_parameters, 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 - request = self._client.post(url, query_parameters) - return self._client.send(request, header_parameters, **operation_config) + def failover_allow_data_loss( + self, resource_group_name, server_name, database_name, link_id, custom_headers=None, raw=False, **operation_config): + """Sets which replica database is primary by failing over from the current + primary replica database. 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. + :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 dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :return: An instance of AzureOperationPoller that returns None or + ClientRawResponse if raw=true + :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or + ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + raw_result = self._failover_allow_data_loss_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + link_id=link_id, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + if raw: + return raw_result + + # Construct and send request + def long_running_send(): + return raw_result.response def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) if headers: request.headers.update(headers) + header_parameters = {} + header_parameters['x-ms-client-request-id'] = raw_result.response.request.headers['x-ms-client-request-id'] return self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) def get_long_running_output(response): @@ -330,10 +383,6 @@ def get_long_running_output(response): 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) @@ -397,7 +446,7 @@ def internal_paging(next_link=None, raw=False): # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) diff --git a/azure-mgmt-sql/azure/mgmt/sql/operations/restorable_dropped_databases_operations.py b/azure-mgmt-sql/azure/mgmt/sql/operations/restorable_dropped_databases_operations.py index 5a09b1185033..8383803776bf 100644 --- a/azure-mgmt-sql/azure/mgmt/sql/operations/restorable_dropped_databases_operations.py +++ b/azure-mgmt-sql/azure/mgmt/sql/operations/restorable_dropped_databases_operations.py @@ -86,7 +86,7 @@ def get( # Construct and send request request = self._client.get(url, query_parameters) - response = self._client.send(request, header_parameters, **operation_config) + response = self._client.send(request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) @@ -157,7 +157,7 @@ def internal_paging(next_link=None, raw=False): # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) diff --git a/azure-mgmt-sql/azure/mgmt/sql/operations/restore_points_operations.py b/azure-mgmt-sql/azure/mgmt/sql/operations/restore_points_operations.py index 78027a869bc6..39053faa125c 100644 --- a/azure-mgmt-sql/azure/mgmt/sql/operations/restore_points_operations.py +++ b/azure-mgmt-sql/azure/mgmt/sql/operations/restore_points_operations.py @@ -94,7 +94,7 @@ def internal_paging(next_link=None, raw=False): # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) diff --git a/azure-mgmt-sql/azure/mgmt/sql/operations/server_automatic_tuning_operations.py b/azure-mgmt-sql/azure/mgmt/sql/operations/server_automatic_tuning_operations.py new file mode 100644 index 000000000000..532834124125 --- /dev/null +++ b/azure-mgmt-sql/azure/mgmt/sql/operations/server_automatic_tuning_operations.py @@ -0,0 +1,177 @@ +# 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 ServerAutomaticTuningOperations(object): + """ServerAutomaticTuningOperations 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". + """ + + models = models + + 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 get( + self, resource_group_name, server_name, custom_headers=None, raw=False, **operation_config): + """Retrieves server automatic tuning options. + + :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 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: ServerAutomaticTuning or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.sql.models.ServerAutomaticTuning or + ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + # Construct URL + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/automaticTuning/current' + 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') + + # 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, stream=False, **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('ServerAutomaticTuning', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + def update( + self, resource_group_name, server_name, desired_state=None, options=None, custom_headers=None, raw=False, **operation_config): + """Update automatic tuning options on 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. + :type server_name: str + :param desired_state: Automatic tuning desired state. Possible values + include: 'Custom', 'Auto', 'Unspecified' + :type desired_state: str or + ~azure.mgmt.sql.models.AutomaticTuningServerMode + :param options: Automatic tuning options definition. + :type options: dict[str, + ~azure.mgmt.sql.models.AutomaticTuningServerOptions] + :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: ServerAutomaticTuning or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.sql.models.ServerAutomaticTuning or + ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + parameters = models.ServerAutomaticTuning(desired_state=desired_state, options=options) + + # Construct URL + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/automaticTuning/current' + 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') + + # 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, 'ServerAutomaticTuning') + + # Construct and send request + request = self._client.patch(url, query_parameters) + response = self._client.send( + request, header_parameters, body_content, stream=False, **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('ServerAutomaticTuning', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized diff --git a/azure-mgmt-sql/azure/mgmt/sql/operations/server_azure_ad_administrators_operations.py b/azure-mgmt-sql/azure/mgmt/sql/operations/server_azure_ad_administrators_operations.py index c925b627a74d..ef10d7f725da 100644 --- a/azure-mgmt-sql/azure/mgmt/sql/operations/server_azure_ad_administrators_operations.py +++ b/azure-mgmt-sql/azure/mgmt/sql/operations/server_azure_ad_administrators_operations.py @@ -12,6 +12,7 @@ import uuid from msrest.pipeline import ClientRawResponse from msrestazure.azure_exceptions import CloudError +from msrest.exceptions import DeserializationError from msrestazure.azure_operation import AzureOperationPoller from .. import models @@ -40,30 +41,9 @@ def __init__(self, client, config, serializer, deserializer): self.config = config - def create_or_update( - self, resource_group_name, server_name, properties, custom_headers=None, raw=False, **operation_config): - """Creates a new Server Active Directory Administrator or updates an - existing server Active Directory Administrator. - :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 properties: The required parameters for creating or updating an - Active Directory Administrator. - :type properties: ~azure.mgmt.sql.models.ServerAzureADAdministrator - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :return: An instance of AzureOperationPoller that returns - ServerAzureADAdministrator or ClientRawResponse if raw=true - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.sql.models.ServerAzureADAdministrator] - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` - """ + def _create_or_update_initial( + self, resource_group_name, server_name, properties, custom_headers=None, raw=False, **operation_config): # Construct URL url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/administrators/{administratorName}' path_format_arguments = { @@ -92,19 +72,78 @@ def create_or_update( body_content = self._serialize.body(properties, 'ServerAzureADAdministrator') # Construct and send request - def long_running_send(): + request = self._client.put(url, query_parameters) + response = self._client.send( + request, header_parameters, body_content, stream=False, **operation_config) - request = self._client.put(url, query_parameters) - return self._client.send( - request, header_parameters, body_content, **operation_config) + if response.status_code not in [200, 201, 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('ServerAzureADAdministrator', response) + if response.status_code == 201: + deserialized = self._deserialize('ServerAzureADAdministrator', response) + if response.status_code == 202: + deserialized = self._deserialize('ServerAzureADAdministrator', 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, properties, custom_headers=None, raw=False, **operation_config): + """Creates a new Server Active Directory Administrator or updates an + existing server Active Directory Administrator. + + :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 properties: The required parameters for creating or updating an + Active Directory Administrator. + :type properties: ~azure.mgmt.sql.models.ServerAzureADAdministrator + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :return: An instance of AzureOperationPoller that returns + ServerAzureADAdministrator or ClientRawResponse if raw=true + :rtype: + ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.sql.models.ServerAzureADAdministrator] + or ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + server_name=server_name, + properties=properties, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + if raw: + return raw_result + + # Construct and send request + def long_running_send(): + return raw_result.response def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) if headers: request.headers.update(headers) + header_parameters = {} + header_parameters['x-ms-client-request-id'] = raw_result.response.request.headers['x-ms-client-request-id'] return self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) def get_long_running_output(response): @@ -113,14 +152,7 @@ def get_long_running_output(response): exp.request_id = response.headers.get('x-ms-request-id') raise exp - deserialized = None - - if response.status_code == 200: - deserialized = self._deserialize('ServerAzureADAdministrator', response) - if response.status_code == 201: - deserialized = self._deserialize('ServerAzureADAdministrator', response) - if response.status_code == 202: - deserialized = self._deserialize('ServerAzureADAdministrator', response) + deserialized = self._deserialize('ServerAzureADAdministrator', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) @@ -128,10 +160,6 @@ def get_long_running_output(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) @@ -139,26 +167,9 @@ def get_long_running_output(response): long_running_send, get_long_running_output, get_long_running_status, long_running_operation_timeout) - def delete( - self, resource_group_name, server_name, custom_headers=None, raw=False, **operation_config): - """Deletes an existing server Active Directory Administrator. - :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 dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :return: An instance of AzureOperationPoller that returns - ServerAzureADAdministrator or ClientRawResponse if raw=true - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.sql.models.ServerAzureADAdministrator] - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` - """ + def _delete_initial( + self, resource_group_name, server_name, custom_headers=None, raw=False, **operation_config): # Construct URL url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/administrators/{administratorName}' path_format_arguments = { @@ -184,18 +195,72 @@ def delete( 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) + response = self._client.send(request, header_parameters, stream=False, **operation_config) + + if response.status_code not in [200, 202, 204]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp - request = self._client.delete(url, query_parameters) - return self._client.send(request, header_parameters, **operation_config) + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('ServerAzureADAdministrator', response) + if response.status_code == 202: + deserialized = self._deserialize('ServerAzureADAdministrator', response) + if response.status_code == 204: + deserialized = self._deserialize('ServerAzureADAdministrator', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + def delete( + self, resource_group_name, server_name, custom_headers=None, raw=False, **operation_config): + """Deletes an existing server Active Directory Administrator. + + :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 dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :return: An instance of AzureOperationPoller that returns + ServerAzureADAdministrator or ClientRawResponse if raw=true + :rtype: + ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.sql.models.ServerAzureADAdministrator] + or ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + server_name=server_name, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + if raw: + return raw_result + + # Construct and send request + def long_running_send(): + return raw_result.response def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) if headers: request.headers.update(headers) + header_parameters = {} + header_parameters['x-ms-client-request-id'] = raw_result.response.request.headers['x-ms-client-request-id'] return self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) def get_long_running_output(response): @@ -204,14 +269,7 @@ def get_long_running_output(response): exp.request_id = response.headers.get('x-ms-request-id') raise exp - deserialized = None - - if response.status_code == 200: - deserialized = self._deserialize('ServerAzureADAdministrator', response) - if response.status_code == 202: - deserialized = self._deserialize('ServerAzureADAdministrator', response) - if response.status_code == 204: - deserialized = self._deserialize('ServerAzureADAdministrator', response) + deserialized = self._deserialize('ServerAzureADAdministrator', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) @@ -219,10 +277,6 @@ def get_long_running_output(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) @@ -276,7 +330,7 @@ def get( # Construct and send request request = self._client.get(url, query_parameters) - response = self._client.send(request, header_parameters, **operation_config) + response = self._client.send(request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) @@ -347,7 +401,7 @@ def internal_paging(next_link=None, raw=False): # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) diff --git a/azure-mgmt-sql/azure/mgmt/sql/operations/server_communication_links_operations.py b/azure-mgmt-sql/azure/mgmt/sql/operations/server_communication_links_operations.py index 2a3fd1c79213..6260d8de01b5 100644 --- a/azure-mgmt-sql/azure/mgmt/sql/operations/server_communication_links_operations.py +++ b/azure-mgmt-sql/azure/mgmt/sql/operations/server_communication_links_operations.py @@ -12,6 +12,7 @@ import uuid from msrest.pipeline import ClientRawResponse from msrestazure.azure_exceptions import CloudError +from msrest.exceptions import DeserializationError from msrestazure.azure_operation import AzureOperationPoller from .. import models @@ -86,7 +87,7 @@ def delete( # Construct and send request request = self._client.delete(url, query_parameters) - response = self._client.send(request, header_parameters, **operation_config) + response = self._client.send(request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) @@ -146,7 +147,7 @@ def get( # Construct and send request request = self._client.get(url, query_parameters) - response = self._client.send(request, header_parameters, **operation_config) + response = self._client.send(request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) @@ -164,31 +165,9 @@ def get( return deserialized - def create_or_update( - self, resource_group_name, server_name, communication_link_name, partner_server, custom_headers=None, raw=False, **operation_config): - """Creates a server communication link. - :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 communication_link_name: The name of the server communication - link. - :type communication_link_name: str - :param partner_server: The name of the partner server. - :type partner_server: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :return: An instance of AzureOperationPoller that returns - ServerCommunicationLink or ClientRawResponse if raw=true - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.sql.models.ServerCommunicationLink] - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` - """ + def _create_or_update_initial( + self, resource_group_name, server_name, communication_link_name, partner_server, custom_headers=None, raw=False, **operation_config): parameters = models.ServerCommunicationLink(partner_server=partner_server) # Construct URL @@ -219,19 +198,76 @@ def create_or_update( body_content = self._serialize.body(parameters, 'ServerCommunicationLink') # Construct and send request - def long_running_send(): + request = self._client.put(url, query_parameters) + response = self._client.send( + request, header_parameters, body_content, stream=False, **operation_config) - request = self._client.put(url, query_parameters) - return self._client.send( - request, header_parameters, body_content, **operation_config) + if response.status_code not in [201, 202]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + deserialized = None + + if response.status_code == 201: + deserialized = self._deserialize('ServerCommunicationLink', 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, communication_link_name, partner_server, custom_headers=None, raw=False, **operation_config): + """Creates a server communication link. + + :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 communication_link_name: The name of the server communication + link. + :type communication_link_name: str + :param partner_server: The name of the partner server. + :type partner_server: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :return: An instance of AzureOperationPoller that returns + ServerCommunicationLink or ClientRawResponse if raw=true + :rtype: + ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.sql.models.ServerCommunicationLink] + or ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + server_name=server_name, + communication_link_name=communication_link_name, + partner_server=partner_server, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + if raw: + return raw_result + + # Construct and send request + def long_running_send(): + return raw_result.response def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) if headers: request.headers.update(headers) + header_parameters = {} + header_parameters['x-ms-client-request-id'] = raw_result.response.request.headers['x-ms-client-request-id'] return self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) def get_long_running_output(response): @@ -240,10 +276,7 @@ def get_long_running_output(response): exp.request_id = response.headers.get('x-ms-request-id') raise exp - deserialized = None - - if response.status_code == 201: - deserialized = self._deserialize('ServerCommunicationLink', response) + deserialized = self._deserialize('ServerCommunicationLink', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) @@ -251,10 +284,6 @@ def get_long_running_output(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) @@ -315,7 +344,7 @@ def internal_paging(next_link=None, raw=False): # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) diff --git a/azure-mgmt-sql/azure/mgmt/sql/operations/server_connection_policies_operations.py b/azure-mgmt-sql/azure/mgmt/sql/operations/server_connection_policies_operations.py index 2e417e4e540c..9e173ca15ec0 100644 --- a/azure-mgmt-sql/azure/mgmt/sql/operations/server_connection_policies_operations.py +++ b/azure-mgmt-sql/azure/mgmt/sql/operations/server_connection_policies_operations.py @@ -95,7 +95,7 @@ def create_or_update( # Construct and send request request = self._client.put(url, query_parameters) response = self._client.send( - request, header_parameters, body_content, **operation_config) + request, header_parameters, body_content, stream=False, **operation_config) if response.status_code not in [200, 201]: exp = CloudError(response) @@ -161,7 +161,7 @@ def get( # Construct and send request request = self._client.get(url, query_parameters) - response = self._client.send(request, header_parameters, **operation_config) + response = self._client.send(request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) diff --git a/azure-mgmt-sql/azure/mgmt/sql/operations/server_dns_aliases_operations.py b/azure-mgmt-sql/azure/mgmt/sql/operations/server_dns_aliases_operations.py index 770d4104dcaf..f90e0259360a 100644 --- a/azure-mgmt-sql/azure/mgmt/sql/operations/server_dns_aliases_operations.py +++ b/azure-mgmt-sql/azure/mgmt/sql/operations/server_dns_aliases_operations.py @@ -12,6 +12,7 @@ import uuid from msrest.pipeline import ClientRawResponse from msrestazure.azure_exceptions import CloudError +from msrest.exceptions import DeserializationError from msrestazure.azure_operation import AzureOperationPoller from .. import models @@ -87,7 +88,7 @@ def get( # Construct and send request request = self._client.get(url, query_parameters) - response = self._client.send(request, header_parameters, **operation_config) + response = self._client.send(request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) @@ -105,29 +106,9 @@ def get( return deserialized - def create_or_update( - self, resource_group_name, server_name, dns_alias_name, custom_headers=None, raw=False, **operation_config): - """Creates a server dns alias. - :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 that the alias is pointing - to. - :type server_name: str - :param dns_alias_name: The name of the server DNS alias. - :type dns_alias_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 - :return: An instance of AzureOperationPoller that returns - ServerDnsAlias or ClientRawResponse if raw=true - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.sql.models.ServerDnsAlias] - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` - """ + def _create_or_update_initial( + self, resource_group_name, server_name, dns_alias_name, custom_headers=None, raw=False, **operation_config): # Construct URL url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/dnsAliases/{dnsAliasName}' path_format_arguments = { @@ -153,18 +134,74 @@ def create_or_update( 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.put(url, query_parameters) + response = self._client.send(request, header_parameters, stream=False, **operation_config) + + if response.status_code not in [200, 201, 202]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp - request = self._client.put(url, query_parameters) - return self._client.send(request, header_parameters, **operation_config) + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('ServerDnsAlias', response) + if response.status_code == 201: + deserialized = self._deserialize('ServerDnsAlias', 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, dns_alias_name, custom_headers=None, raw=False, **operation_config): + """Creates a server dns alias. + + :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 that the alias is pointing + to. + :type server_name: str + :param dns_alias_name: The name of the server DNS alias. + :type dns_alias_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 + :return: An instance of AzureOperationPoller that returns + ServerDnsAlias or ClientRawResponse if raw=true + :rtype: + ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.sql.models.ServerDnsAlias] + or ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + server_name=server_name, + dns_alias_name=dns_alias_name, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + if raw: + return raw_result + + # Construct and send request + def long_running_send(): + return raw_result.response def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) if headers: request.headers.update(headers) + header_parameters = {} + header_parameters['x-ms-client-request-id'] = raw_result.response.request.headers['x-ms-client-request-id'] return self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) def get_long_running_output(response): @@ -173,12 +210,7 @@ def get_long_running_output(response): exp.request_id = response.headers.get('x-ms-request-id') raise exp - deserialized = None - - if response.status_code == 200: - deserialized = self._deserialize('ServerDnsAlias', response) - if response.status_code == 201: - deserialized = self._deserialize('ServerDnsAlias', response) + deserialized = self._deserialize('ServerDnsAlias', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) @@ -186,10 +218,6 @@ def get_long_running_output(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) @@ -197,28 +225,9 @@ def get_long_running_output(response): long_running_send, get_long_running_output, get_long_running_status, long_running_operation_timeout) - def delete( - self, resource_group_name, server_name, dns_alias_name, custom_headers=None, raw=False, **operation_config): - """Deletes the server DNS alias with the given name. - :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 that the alias is pointing - to. - :type server_name: str - :param dns_alias_name: The name of the server DNS alias. - :type dns_alias_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 - :return: An instance of AzureOperationPoller that returns None or - ClientRawResponse if raw=true - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` - """ + def _delete_initial( + self, resource_group_name, server_name, dns_alias_name, custom_headers=None, raw=False, **operation_config): # Construct URL url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/dnsAliases/{dnsAliasName}' path_format_arguments = { @@ -244,18 +253,64 @@ def delete( 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) + response = self._client.send(request, header_parameters, stream=False, **operation_config) - request = self._client.delete(url, query_parameters) - return self._client.send(request, header_parameters, **operation_config) + 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 + + def delete( + self, resource_group_name, server_name, dns_alias_name, custom_headers=None, raw=False, **operation_config): + """Deletes the server DNS alias with the given name. + + :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 that the alias is pointing + to. + :type server_name: str + :param dns_alias_name: The name of the server DNS alias. + :type dns_alias_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 + :return: An instance of AzureOperationPoller that returns None or + ClientRawResponse if raw=true + :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or + ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + server_name=server_name, + dns_alias_name=dns_alias_name, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + if raw: + return raw_result + + # Construct and send request + def long_running_send(): + return raw_result.response def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) if headers: request.headers.update(headers) + header_parameters = {} + header_parameters['x-ms-client-request-id'] = raw_result.response.request.headers['x-ms-client-request-id'] return self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) def get_long_running_output(response): @@ -268,10 +323,6 @@ def get_long_running_output(response): 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) @@ -333,7 +384,7 @@ def internal_paging(next_link=None, raw=False): # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) @@ -352,31 +403,9 @@ def internal_paging(next_link=None, raw=False): return deserialized - def acquire( - self, resource_group_name, server_name, dns_alias_name, old_server_dns_alias_id=None, custom_headers=None, raw=False, **operation_config): - """Acquires server DNS alias from another 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 that the alias is pointing - to. - :type server_name: str - :param dns_alias_name: The name of the server dns alias. - :type dns_alias_name: str - :param old_server_dns_alias_id: The id of the server alias that will - be acquired to point to this server instead. - :type old_server_dns_alias_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 - :return: An instance of AzureOperationPoller that returns None or - ClientRawResponse if raw=true - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` - """ + def _acquire_initial( + self, resource_group_name, server_name, dns_alias_name, old_server_dns_alias_id=None, custom_headers=None, raw=False, **operation_config): parameters = models.ServerDnsAliasAcquisition(old_server_dns_alias_id=old_server_dns_alias_id) # Construct URL @@ -407,19 +436,69 @@ def acquire( body_content = self._serialize.body(parameters, 'ServerDnsAliasAcquisition') # Construct and send request - def long_running_send(): + request = self._client.post(url, query_parameters) + response = self._client.send( + request, header_parameters, body_content, stream=False, **operation_config) - request = self._client.post(url, query_parameters) - return self._client.send( - request, header_parameters, body_content, **operation_config) + if response.status_code not in [200, 202]: + 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 acquire( + self, resource_group_name, server_name, dns_alias_name, old_server_dns_alias_id=None, custom_headers=None, raw=False, **operation_config): + """Acquires server DNS alias from another 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 that the alias is pointing + to. + :type server_name: str + :param dns_alias_name: The name of the server dns alias. + :type dns_alias_name: str + :param old_server_dns_alias_id: The id of the server alias that will + be acquired to point to this server instead. + :type old_server_dns_alias_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 + :return: An instance of AzureOperationPoller that returns None or + ClientRawResponse if raw=true + :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or + ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + raw_result = self._acquire_initial( + resource_group_name=resource_group_name, + server_name=server_name, + dns_alias_name=dns_alias_name, + old_server_dns_alias_id=old_server_dns_alias_id, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + if raw: + return raw_result + + # Construct and send request + def long_running_send(): + return raw_result.response def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) if headers: request.headers.update(headers) + header_parameters = {} + header_parameters['x-ms-client-request-id'] = raw_result.response.request.headers['x-ms-client-request-id'] return self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) def get_long_running_output(response): @@ -432,10 +511,6 @@ def get_long_running_output(response): 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) diff --git a/azure-mgmt-sql/azure/mgmt/sql/operations/server_keys_operations.py b/azure-mgmt-sql/azure/mgmt/sql/operations/server_keys_operations.py index 817d8b3b572c..3b3ae05dce44 100644 --- a/azure-mgmt-sql/azure/mgmt/sql/operations/server_keys_operations.py +++ b/azure-mgmt-sql/azure/mgmt/sql/operations/server_keys_operations.py @@ -12,6 +12,7 @@ import uuid from msrest.pipeline import ClientRawResponse from msrestazure.azure_exceptions import CloudError +from msrest.exceptions import DeserializationError from msrestazure.azure_operation import AzureOperationPoller from .. import models @@ -91,7 +92,7 @@ def internal_paging(next_link=None, raw=False): # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) @@ -158,7 +159,7 @@ def get( # Construct and send request request = self._client.get(url, query_parameters) - response = self._client.send(request, header_parameters, **operation_config) + response = self._client.send(request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) @@ -176,6 +177,59 @@ def get( return deserialized + + def _create_or_update_initial( + self, resource_group_name, server_name, key_name, parameters, custom_headers=None, raw=False, **operation_config): + # Construct URL + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/keys/{keyName}' + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serverName': self._serialize.url("server_name", server_name, 'str'), + 'keyName': self._serialize.url("key_name", key_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, 'ServerKey') + + # Construct and send request + request = self._client.put(url, query_parameters) + response = self._client.send( + request, header_parameters, body_content, stream=False, **operation_config) + + if response.status_code not in [200, 201, 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('ServerKey', response) + if response.status_code == 201: + deserialized = self._deserialize('ServerKey', 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, key_name, parameters, custom_headers=None, raw=False, **operation_config): """Creates or updates a server key. @@ -205,47 +259,31 @@ def create_or_update( or ~msrest.pipeline.ClientRawResponse :raises: :class:`CloudError` """ - # Construct URL - url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/keys/{keyName}' - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'keyName': self._serialize.url("key_name", key_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, 'ServerKey') + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + server_name=server_name, + key_name=key_name, + parameters=parameters, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + if raw: + return raw_result # 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) + return raw_result.response def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) if headers: request.headers.update(headers) + header_parameters = {} + header_parameters['x-ms-client-request-id'] = raw_result.response.request.headers['x-ms-client-request-id'] return self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) def get_long_running_output(response): @@ -254,12 +292,7 @@ def get_long_running_output(response): exp.request_id = response.headers.get('x-ms-request-id') raise exp - deserialized = None - - if response.status_code == 200: - deserialized = self._deserialize('ServerKey', response) - if response.status_code == 201: - deserialized = self._deserialize('ServerKey', response) + deserialized = self._deserialize('ServerKey', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) @@ -267,10 +300,6 @@ def get_long_running_output(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) @@ -278,27 +307,9 @@ def get_long_running_output(response): long_running_send, get_long_running_output, get_long_running_status, long_running_operation_timeout) - def delete( - self, resource_group_name, server_name, key_name, custom_headers=None, raw=False, **operation_config): - """Deletes the server key with the given name. - :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 key_name: The name of the server key to be deleted. - :type key_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 - :return: An instance of AzureOperationPoller that returns None or - ClientRawResponse if raw=true - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` - """ + def _delete_initial( + self, resource_group_name, server_name, key_name, custom_headers=None, raw=False, **operation_config): # Construct URL url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/keys/{keyName}' path_format_arguments = { @@ -324,18 +335,63 @@ def delete( 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) + response = self._client.send(request, header_parameters, stream=False, **operation_config) - request = self._client.delete(url, query_parameters) - return self._client.send(request, header_parameters, **operation_config) + 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 + + def delete( + self, resource_group_name, server_name, key_name, custom_headers=None, raw=False, **operation_config): + """Deletes the server key with the given name. + + :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 key_name: The name of the server key to be deleted. + :type key_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 + :return: An instance of AzureOperationPoller that returns None or + ClientRawResponse if raw=true + :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or + ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + server_name=server_name, + key_name=key_name, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + if raw: + return raw_result + + # Construct and send request + def long_running_send(): + return raw_result.response def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) if headers: request.headers.update(headers) + header_parameters = {} + header_parameters['x-ms-client-request-id'] = raw_result.response.request.headers['x-ms-client-request-id'] return self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) def get_long_running_output(response): @@ -348,10 +404,6 @@ def get_long_running_output(response): 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) diff --git a/azure-mgmt-sql/azure/mgmt/sql/operations/server_usages_operations.py b/azure-mgmt-sql/azure/mgmt/sql/operations/server_usages_operations.py index eab99186047c..192035e76e23 100644 --- a/azure-mgmt-sql/azure/mgmt/sql/operations/server_usages_operations.py +++ b/azure-mgmt-sql/azure/mgmt/sql/operations/server_usages_operations.py @@ -90,7 +90,7 @@ def internal_paging(next_link=None, raw=False): # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) diff --git a/azure-mgmt-sql/azure/mgmt/sql/operations/servers_operations.py b/azure-mgmt-sql/azure/mgmt/sql/operations/servers_operations.py index 8f8a934ab2e1..c85b4c8a1f78 100644 --- a/azure-mgmt-sql/azure/mgmt/sql/operations/servers_operations.py +++ b/azure-mgmt-sql/azure/mgmt/sql/operations/servers_operations.py @@ -12,6 +12,7 @@ import uuid from msrest.pipeline import ClientRawResponse from msrestazure.azure_exceptions import CloudError +from msrest.exceptions import DeserializationError from msrestazure.azure_operation import AzureOperationPoller from .. import models @@ -84,7 +85,7 @@ def check_name_availability( # Construct and send request request = self._client.post(url, query_parameters) response = self._client.send( - request, header_parameters, body_content, **operation_config) + request, header_parameters, body_content, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) @@ -149,7 +150,7 @@ def internal_paging(next_link=None, raw=False): # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) @@ -220,7 +221,7 @@ def internal_paging(next_link=None, raw=False): # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) @@ -286,7 +287,7 @@ def get( # Construct and send request request = self._client.get(url, query_parameters) - response = self._client.send(request, header_parameters, **operation_config) + response = self._client.send(request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) @@ -304,28 +305,9 @@ def get( return deserialized - def create_or_update( - self, resource_group_name, server_name, parameters, custom_headers=None, raw=False, **operation_config): - """Creates or updates 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. - :type server_name: str - :param parameters: The requested server resource state. - :type parameters: ~azure.mgmt.sql.models.Server - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :return: An instance of AzureOperationPoller that returns Server or - ClientRawResponse if raw=true - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.sql.models.Server] - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` - """ + def _create_or_update_initial( + self, resource_group_name, server_name, parameters, custom_headers=None, raw=False, **operation_config): api_version = "2015-05-01-preview" # Construct URL @@ -355,19 +337,74 @@ def create_or_update( body_content = self._serialize.body(parameters, 'Server') # Construct and send request - def long_running_send(): + request = self._client.put(url, query_parameters) + response = self._client.send( + request, header_parameters, body_content, stream=False, **operation_config) - request = self._client.put(url, query_parameters) - return self._client.send( - request, header_parameters, body_content, **operation_config) + if response.status_code not in [200, 201, 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('Server', response) + if response.status_code == 201: + deserialized = self._deserialize('Server', 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, parameters, custom_headers=None, raw=False, **operation_config): + """Creates or updates 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. + :type server_name: str + :param parameters: The requested server resource state. + :type parameters: ~azure.mgmt.sql.models.Server + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :return: An instance of AzureOperationPoller that returns Server or + ClientRawResponse if raw=true + :rtype: + ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.sql.models.Server] + or ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + server_name=server_name, + parameters=parameters, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + if raw: + return raw_result + + # Construct and send request + def long_running_send(): + return raw_result.response def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) if headers: request.headers.update(headers) + header_parameters = {} + header_parameters['x-ms-client-request-id'] = raw_result.response.request.headers['x-ms-client-request-id'] return self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) def get_long_running_output(response): @@ -376,12 +413,7 @@ def get_long_running_output(response): exp.request_id = response.headers.get('x-ms-request-id') raise exp - deserialized = None - - if response.status_code == 200: - deserialized = self._deserialize('Server', response) - if response.status_code == 201: - deserialized = self._deserialize('Server', response) + deserialized = self._deserialize('Server', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) @@ -389,10 +421,6 @@ def get_long_running_output(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) @@ -400,25 +428,9 @@ def get_long_running_output(response): long_running_send, get_long_running_output, get_long_running_status, long_running_operation_timeout) - def delete( - self, resource_group_name, server_name, custom_headers=None, raw=False, **operation_config): - """Deletes 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. - :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 - :return: An instance of AzureOperationPoller that returns None or - ClientRawResponse if raw=true - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` - """ + def _delete_initial( + self, resource_group_name, server_name, custom_headers=None, raw=False, **operation_config): api_version = "2015-05-01-preview" # Construct URL @@ -445,18 +457,60 @@ def delete( 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) + response = self._client.send(request, header_parameters, stream=False, **operation_config) + + 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 - request = self._client.delete(url, query_parameters) - return self._client.send(request, header_parameters, **operation_config) + def delete( + self, resource_group_name, server_name, custom_headers=None, raw=False, **operation_config): + """Deletes 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. + :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 + :return: An instance of AzureOperationPoller that returns None or + ClientRawResponse if raw=true + :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or + ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + server_name=server_name, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + if raw: + return raw_result + + # Construct and send request + def long_running_send(): + return raw_result.response def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) if headers: request.headers.update(headers) + header_parameters = {} + header_parameters['x-ms-client-request-id'] = raw_result.response.request.headers['x-ms-client-request-id'] return self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) def get_long_running_output(response): @@ -469,10 +523,6 @@ def get_long_running_output(response): 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) @@ -480,28 +530,9 @@ def get_long_running_output(response): long_running_send, get_long_running_output, get_long_running_status, long_running_operation_timeout) - def update( - self, resource_group_name, server_name, parameters, custom_headers=None, raw=False, **operation_config): - """Updates 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. - :type server_name: str - :param parameters: The requested server resource state. - :type parameters: ~azure.mgmt.sql.models.ServerUpdate - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :return: An instance of AzureOperationPoller that returns Server or - ClientRawResponse if raw=true - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.sql.models.Server] - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` - """ + def _update_initial( + self, resource_group_name, server_name, parameters, custom_headers=None, raw=False, **operation_config): api_version = "2015-05-01-preview" # Construct URL @@ -531,19 +562,72 @@ def update( body_content = self._serialize.body(parameters, 'ServerUpdate') # Construct and send request - def long_running_send(): + request = self._client.patch(url, query_parameters) + response = self._client.send( + request, header_parameters, body_content, stream=False, **operation_config) - request = self._client.patch(url, query_parameters) - return self._client.send( - request, header_parameters, body_content, **operation_config) + 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('Server', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + def update( + self, resource_group_name, server_name, parameters, custom_headers=None, raw=False, **operation_config): + """Updates 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. + :type server_name: str + :param parameters: The requested server resource state. + :type parameters: ~azure.mgmt.sql.models.ServerUpdate + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :return: An instance of AzureOperationPoller that returns Server or + ClientRawResponse if raw=true + :rtype: + ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.sql.models.Server] + or ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + raw_result = self._update_initial( + resource_group_name=resource_group_name, + server_name=server_name, + parameters=parameters, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + if raw: + return raw_result + + # Construct and send request + def long_running_send(): + return raw_result.response def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) if headers: request.headers.update(headers) + header_parameters = {} + header_parameters['x-ms-client-request-id'] = raw_result.response.request.headers['x-ms-client-request-id'] return self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) def get_long_running_output(response): @@ -552,10 +636,7 @@ def get_long_running_output(response): exp.request_id = response.headers.get('x-ms-request-id') raise exp - deserialized = None - - if response.status_code == 200: - deserialized = self._deserialize('Server', response) + deserialized = self._deserialize('Server', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) @@ -563,10 +644,6 @@ def get_long_running_output(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) diff --git a/azure-mgmt-sql/azure/mgmt/sql/operations/service_objectives_operations.py b/azure-mgmt-sql/azure/mgmt/sql/operations/service_objectives_operations.py index 9a14c85e3f28..64ade5034a12 100644 --- a/azure-mgmt-sql/azure/mgmt/sql/operations/service_objectives_operations.py +++ b/azure-mgmt-sql/azure/mgmt/sql/operations/service_objectives_operations.py @@ -86,7 +86,7 @@ def get( # Construct and send request request = self._client.get(url, query_parameters) - response = self._client.send(request, header_parameters, **operation_config) + response = self._client.send(request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) @@ -157,7 +157,7 @@ def internal_paging(next_link=None, raw=False): # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) diff --git a/azure-mgmt-sql/azure/mgmt/sql/operations/service_tier_advisors_operations.py b/azure-mgmt-sql/azure/mgmt/sql/operations/service_tier_advisors_operations.py index b795d635f445..11c70d2e4955 100644 --- a/azure-mgmt-sql/azure/mgmt/sql/operations/service_tier_advisors_operations.py +++ b/azure-mgmt-sql/azure/mgmt/sql/operations/service_tier_advisors_operations.py @@ -88,7 +88,7 @@ def get( # Construct and send request request = self._client.get(url, query_parameters) - response = self._client.send(request, header_parameters, **operation_config) + response = self._client.send(request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) @@ -162,7 +162,7 @@ def internal_paging(next_link=None, raw=False): # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) diff --git a/azure-mgmt-sql/azure/mgmt/sql/operations/subscription_usages_operations.py b/azure-mgmt-sql/azure/mgmt/sql/operations/subscription_usages_operations.py index 7ee07416002f..47973720f6cf 100644 --- a/azure-mgmt-sql/azure/mgmt/sql/operations/subscription_usages_operations.py +++ b/azure-mgmt-sql/azure/mgmt/sql/operations/subscription_usages_operations.py @@ -86,7 +86,7 @@ def internal_paging(next_link=None, raw=False): # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) @@ -149,7 +149,7 @@ def get( # Construct and send request request = self._client.get(url, query_parameters) - response = self._client.send(request, header_parameters, **operation_config) + response = self._client.send(request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) diff --git a/azure-mgmt-sql/azure/mgmt/sql/operations/sync_agents_operations.py b/azure-mgmt-sql/azure/mgmt/sql/operations/sync_agents_operations.py index 1590d6907f22..c09c8b886922 100644 --- a/azure-mgmt-sql/azure/mgmt/sql/operations/sync_agents_operations.py +++ b/azure-mgmt-sql/azure/mgmt/sql/operations/sync_agents_operations.py @@ -12,6 +12,7 @@ import uuid from msrest.pipeline import ClientRawResponse from msrestazure.azure_exceptions import CloudError +from msrest.exceptions import DeserializationError from msrestazure.azure_operation import AzureOperationPoller from .. import models @@ -87,7 +88,7 @@ def get( # Construct and send request request = self._client.get(url, query_parameters) - response = self._client.send(request, header_parameters, **operation_config) + response = self._client.send(request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) @@ -105,32 +106,9 @@ def get( return deserialized - def create_or_update( - self, resource_group_name, server_name, sync_agent_name, sync_database_id=None, custom_headers=None, raw=False, **operation_config): - """Creates or updates a sync agent. - :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 on which the sync agent is - hosted. - :type server_name: str - :param sync_agent_name: The name of the sync agent. - :type sync_agent_name: str - :param sync_database_id: ARM resource id of the sync database in the - sync agent. - :type sync_database_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 - :return: An instance of AzureOperationPoller that returns SyncAgent or - ClientRawResponse if raw=true - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.sql.models.SyncAgent] - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` - """ + def _create_or_update_initial( + self, resource_group_name, server_name, sync_agent_name, sync_database_id=None, custom_headers=None, raw=False, **operation_config): parameters = models.SyncAgent(sync_database_id=sync_database_id) # Construct URL @@ -161,19 +139,79 @@ def create_or_update( body_content = self._serialize.body(parameters, 'SyncAgent') # Construct and send request - def long_running_send(): + request = self._client.put(url, query_parameters) + response = self._client.send( + request, header_parameters, body_content, stream=False, **operation_config) - request = self._client.put(url, query_parameters) - return self._client.send( - request, header_parameters, body_content, **operation_config) + if response.status_code not in [200, 201, 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('SyncAgent', response) + if response.status_code == 201: + deserialized = self._deserialize('SyncAgent', 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, sync_agent_name, sync_database_id=None, custom_headers=None, raw=False, **operation_config): + """Creates or updates a sync agent. + + :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 on which the sync agent is + hosted. + :type server_name: str + :param sync_agent_name: The name of the sync agent. + :type sync_agent_name: str + :param sync_database_id: ARM resource id of the sync database in the + sync agent. + :type sync_database_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 + :return: An instance of AzureOperationPoller that returns SyncAgent or + ClientRawResponse if raw=true + :rtype: + ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.sql.models.SyncAgent] + or ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + server_name=server_name, + sync_agent_name=sync_agent_name, + sync_database_id=sync_database_id, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + if raw: + return raw_result + + # Construct and send request + def long_running_send(): + return raw_result.response def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) if headers: request.headers.update(headers) + header_parameters = {} + header_parameters['x-ms-client-request-id'] = raw_result.response.request.headers['x-ms-client-request-id'] return self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) def get_long_running_output(response): @@ -182,12 +220,7 @@ def get_long_running_output(response): exp.request_id = response.headers.get('x-ms-request-id') raise exp - deserialized = None - - if response.status_code == 200: - deserialized = self._deserialize('SyncAgent', response) - if response.status_code == 201: - deserialized = self._deserialize('SyncAgent', response) + deserialized = self._deserialize('SyncAgent', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) @@ -195,10 +228,6 @@ def get_long_running_output(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) @@ -206,28 +235,9 @@ def get_long_running_output(response): long_running_send, get_long_running_output, get_long_running_status, long_running_operation_timeout) - def delete( - self, resource_group_name, server_name, sync_agent_name, custom_headers=None, raw=False, **operation_config): - """Deletes a sync agent. - :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 on which the sync agent is - hosted. - :type server_name: str - :param sync_agent_name: The name of the sync agent. - :type sync_agent_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 - :return: An instance of AzureOperationPoller that returns None or - ClientRawResponse if raw=true - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` - """ + def _delete_initial( + self, resource_group_name, server_name, sync_agent_name, custom_headers=None, raw=False, **operation_config): # Construct URL url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/syncAgents/{syncAgentName}' path_format_arguments = { @@ -253,18 +263,64 @@ def delete( 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) + response = self._client.send(request, header_parameters, stream=False, **operation_config) - request = self._client.delete(url, query_parameters) - return self._client.send(request, header_parameters, **operation_config) + 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 + + def delete( + self, resource_group_name, server_name, sync_agent_name, custom_headers=None, raw=False, **operation_config): + """Deletes a sync agent. + + :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 on which the sync agent is + hosted. + :type server_name: str + :param sync_agent_name: The name of the sync agent. + :type sync_agent_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 + :return: An instance of AzureOperationPoller that returns None or + ClientRawResponse if raw=true + :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or + ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + server_name=server_name, + sync_agent_name=sync_agent_name, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + if raw: + return raw_result + + # Construct and send request + def long_running_send(): + return raw_result.response def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) if headers: request.headers.update(headers) + header_parameters = {} + header_parameters['x-ms-client-request-id'] = raw_result.response.request.headers['x-ms-client-request-id'] return self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) def get_long_running_output(response): @@ -277,10 +333,6 @@ def get_long_running_output(response): 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) @@ -342,7 +394,7 @@ def internal_paging(next_link=None, raw=False): # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) @@ -410,7 +462,7 @@ def generate_key( # Construct and send request request = self._client.post(url, query_parameters) - response = self._client.send(request, header_parameters, **operation_config) + response = self._client.send(request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) @@ -485,7 +537,7 @@ def internal_paging(next_link=None, raw=False): # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) diff --git a/azure-mgmt-sql/azure/mgmt/sql/operations/sync_groups_operations.py b/azure-mgmt-sql/azure/mgmt/sql/operations/sync_groups_operations.py index c216cc3cc394..d4766e1ef797 100644 --- a/azure-mgmt-sql/azure/mgmt/sql/operations/sync_groups_operations.py +++ b/azure-mgmt-sql/azure/mgmt/sql/operations/sync_groups_operations.py @@ -12,6 +12,7 @@ import uuid from msrest.pipeline import ClientRawResponse from msrestazure.azure_exceptions import CloudError +from msrest.exceptions import DeserializationError from msrestazure.azure_operation import AzureOperationPoller from .. import models @@ -87,7 +88,7 @@ def internal_paging(next_link=None, raw=False): # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) @@ -106,30 +107,9 @@ def internal_paging(next_link=None, raw=False): return deserialized - def refresh_hub_schema( - self, resource_group_name, server_name, database_name, sync_group_name, custom_headers=None, raw=False, **operation_config): - """Refreshes a hub database schema. - :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 on which the sync group - is hosted. - :type database_name: str - :param sync_group_name: The name of the sync group. - :type sync_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 - :return: An instance of AzureOperationPoller that returns None or - ClientRawResponse if raw=true - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` - """ + def _refresh_hub_schema_initial( + self, resource_group_name, server_name, database_name, sync_group_name, custom_headers=None, raw=False, **operation_config): # Construct URL url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/refreshHubSchema' path_format_arguments = { @@ -156,18 +136,67 @@ def refresh_hub_schema( 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) + response = self._client.send(request, header_parameters, stream=False, **operation_config) + + if response.status_code not in [200, 202]: + 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 refresh_hub_schema( + self, resource_group_name, server_name, database_name, sync_group_name, custom_headers=None, raw=False, **operation_config): + """Refreshes a hub database schema. + + :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 on which the sync group + is hosted. + :type database_name: str + :param sync_group_name: The name of the sync group. + :type sync_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 + :return: An instance of AzureOperationPoller that returns None or + ClientRawResponse if raw=true + :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or + ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + raw_result = self._refresh_hub_schema_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + sync_group_name=sync_group_name, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + if raw: + return raw_result - request = self._client.post(url, query_parameters) - return self._client.send(request, header_parameters, **operation_config) + # Construct and send request + def long_running_send(): + return raw_result.response def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) if headers: request.headers.update(headers) + header_parameters = {} + header_parameters['x-ms-client-request-id'] = raw_result.response.request.headers['x-ms-client-request-id'] return self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) def get_long_running_output(response): @@ -180,10 +209,6 @@ def get_long_running_output(response): 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) @@ -251,7 +276,7 @@ def internal_paging(next_link=None, raw=False): # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) @@ -344,7 +369,7 @@ def internal_paging(next_link=None, raw=False): # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) @@ -414,7 +439,7 @@ def cancel_sync( # Construct and send request request = self._client.post(url, query_parameters) - response = self._client.send(request, header_parameters, **operation_config) + response = self._client.send(request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) @@ -476,7 +501,7 @@ def trigger_sync( # Construct and send request request = self._client.post(url, query_parameters) - response = self._client.send(request, header_parameters, **operation_config) + response = self._client.send(request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) @@ -539,7 +564,7 @@ def get( # Construct and send request request = self._client.get(url, query_parameters) - response = self._client.send(request, header_parameters, **operation_config) + response = self._client.send(request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) @@ -557,33 +582,9 @@ def get( return deserialized - def create_or_update( - self, resource_group_name, server_name, database_name, sync_group_name, parameters, custom_headers=None, raw=False, **operation_config): - """Creates or updates a sync 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. - :type server_name: str - :param database_name: The name of the database on which the sync group - is hosted. - :type database_name: str - :param sync_group_name: The name of the sync group. - :type sync_group_name: str - :param parameters: The requested sync group resource state. - :type parameters: ~azure.mgmt.sql.models.SyncGroup - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :return: An instance of AzureOperationPoller that returns SyncGroup or - ClientRawResponse if raw=true - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.sql.models.SyncGroup] - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` - """ + def _create_or_update_initial( + self, resource_group_name, server_name, database_name, sync_group_name, parameters, custom_headers=None, raw=False, **operation_config): # Construct URL url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}' path_format_arguments = { @@ -613,19 +614,81 @@ def create_or_update( body_content = self._serialize.body(parameters, 'SyncGroup') # Construct and send request - def long_running_send(): + request = self._client.put(url, query_parameters) + response = self._client.send( + request, header_parameters, body_content, stream=False, **operation_config) - request = self._client.put(url, query_parameters) - return self._client.send( - request, header_parameters, body_content, **operation_config) + if response.status_code not in [200, 201, 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('SyncGroup', response) + if response.status_code == 201: + deserialized = self._deserialize('SyncGroup', 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, database_name, sync_group_name, parameters, custom_headers=None, raw=False, **operation_config): + """Creates or updates a sync 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. + :type server_name: str + :param database_name: The name of the database on which the sync group + is hosted. + :type database_name: str + :param sync_group_name: The name of the sync group. + :type sync_group_name: str + :param parameters: The requested sync group resource state. + :type parameters: ~azure.mgmt.sql.models.SyncGroup + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :return: An instance of AzureOperationPoller that returns SyncGroup or + ClientRawResponse if raw=true + :rtype: + ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.sql.models.SyncGroup] + or ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + sync_group_name=sync_group_name, + parameters=parameters, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + if raw: + return raw_result + + # Construct and send request + def long_running_send(): + return raw_result.response def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) if headers: request.headers.update(headers) + header_parameters = {} + header_parameters['x-ms-client-request-id'] = raw_result.response.request.headers['x-ms-client-request-id'] return self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) def get_long_running_output(response): @@ -634,12 +697,7 @@ def get_long_running_output(response): exp.request_id = response.headers.get('x-ms-request-id') raise exp - deserialized = None - - if response.status_code == 200: - deserialized = self._deserialize('SyncGroup', response) - if response.status_code == 201: - deserialized = self._deserialize('SyncGroup', response) + deserialized = self._deserialize('SyncGroup', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) @@ -647,10 +705,6 @@ def get_long_running_output(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) @@ -658,6 +712,47 @@ def get_long_running_output(response): long_running_send, get_long_running_output, get_long_running_status, long_running_operation_timeout) + + def _delete_initial( + self, resource_group_name, server_name, database_name, sync_group_name, custom_headers=None, raw=False, **operation_config): + # Construct URL + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}' + 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'), + 'syncGroupName': self._serialize.url("sync_group_name", sync_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.delete(url, query_parameters) + response = self._client.send(request, header_parameters, stream=False, **operation_config) + + 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 + def delete( self, resource_group_name, server_name, database_name, sync_group_name, custom_headers=None, raw=False, **operation_config): """Deletes a sync group. @@ -682,6 +777,53 @@ def delete( ~msrest.pipeline.ClientRawResponse :raises: :class:`CloudError` """ + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + sync_group_name=sync_group_name, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + if raw: + return raw_result + + # Construct and send request + def long_running_send(): + return raw_result.response + + def get_long_running_status(status_link, headers=None): + + request = self._client.get(status_link) + if headers: + request.headers.update(headers) + header_parameters = {} + header_parameters['x-ms-client-request-id'] = raw_result.response.request.headers['x-ms-client-request-id'] + return self._client.send( + request, header_parameters, stream=False, **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 + + 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_initial( + self, resource_group_name, server_name, database_name, sync_group_name, parameters, custom_headers=None, raw=False, **operation_config): # Construct URL url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}' path_format_arguments = { @@ -707,41 +849,29 @@ def delete( 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): + # Construct body + body_content = self._serialize.body(parameters, 'SyncGroup') - request = self._client.get(status_link) - if headers: - request.headers.update(headers) - return self._client.send( - request, header_parameters, **operation_config) + # Construct and send request + request = self._client.patch(url, query_parameters) + response = self._client.send( + request, header_parameters, body_content, stream=False, **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 - if response.status_code not in [200, 202, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + deserialized = None - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + if response.status_code == 200: + deserialized = self._deserialize('SyncGroup', response) if raw: - response = long_running_send() - return get_long_running_output(response) + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_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) + return deserialized def update( self, resource_group_name, server_name, database_name, sync_group_name, parameters, custom_headers=None, raw=False, **operation_config): @@ -770,48 +900,32 @@ def update( or ~msrest.pipeline.ClientRawResponse :raises: :class:`CloudError` """ - # Construct URL - url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}' - 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'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_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, 'SyncGroup') + raw_result = self._update_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + sync_group_name=sync_group_name, + parameters=parameters, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + if raw: + return raw_result # 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) + return raw_result.response def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) if headers: request.headers.update(headers) + header_parameters = {} + header_parameters['x-ms-client-request-id'] = raw_result.response.request.headers['x-ms-client-request-id'] return self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) def get_long_running_output(response): @@ -820,10 +934,7 @@ def get_long_running_output(response): exp.request_id = response.headers.get('x-ms-request-id') raise exp - deserialized = None - - if response.status_code == 200: - deserialized = self._deserialize('SyncGroup', response) + deserialized = self._deserialize('SyncGroup', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) @@ -831,10 +942,6 @@ def get_long_running_output(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) @@ -899,7 +1006,7 @@ def internal_paging(next_link=None, raw=False): # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) diff --git a/azure-mgmt-sql/azure/mgmt/sql/operations/sync_members_operations.py b/azure-mgmt-sql/azure/mgmt/sql/operations/sync_members_operations.py index 240fea187b00..9672266eae2b 100644 --- a/azure-mgmt-sql/azure/mgmt/sql/operations/sync_members_operations.py +++ b/azure-mgmt-sql/azure/mgmt/sql/operations/sync_members_operations.py @@ -12,6 +12,7 @@ import uuid from msrest.pipeline import ClientRawResponse from msrestazure.azure_exceptions import CloudError +from msrest.exceptions import DeserializationError from msrestazure.azure_operation import AzureOperationPoller from .. import models @@ -94,7 +95,7 @@ def get( # Construct and send request request = self._client.get(url, query_parameters) - response = self._client.send(request, header_parameters, **operation_config) + response = self._client.send(request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) @@ -112,6 +113,61 @@ def get( return deserialized + + def _create_or_update_initial( + self, resource_group_name, server_name, database_name, sync_group_name, sync_member_name, parameters, custom_headers=None, raw=False, **operation_config): + # Construct URL + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}' + 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'), + 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), + 'syncMemberName': self._serialize.url("sync_member_name", sync_member_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, 'SyncMember') + + # Construct and send request + request = self._client.put(url, query_parameters) + response = self._client.send( + request, header_parameters, body_content, stream=False, **operation_config) + + if response.status_code not in [200, 201, 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('SyncMember', response) + if response.status_code == 201: + deserialized = self._deserialize('SyncMember', 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, database_name, sync_group_name, sync_member_name, parameters, custom_headers=None, raw=False, **operation_config): """Creates or updates a sync member. @@ -142,49 +198,33 @@ def create_or_update( or ~msrest.pipeline.ClientRawResponse :raises: :class:`CloudError` """ - # Construct URL - url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}' - 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'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'syncMemberName': self._serialize.url("sync_member_name", sync_member_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, 'SyncMember') + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + sync_group_name=sync_group_name, + sync_member_name=sync_member_name, + parameters=parameters, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + if raw: + return raw_result # 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) + return raw_result.response def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) if headers: request.headers.update(headers) + header_parameters = {} + header_parameters['x-ms-client-request-id'] = raw_result.response.request.headers['x-ms-client-request-id'] return self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) def get_long_running_output(response): @@ -193,12 +233,7 @@ def get_long_running_output(response): exp.request_id = response.headers.get('x-ms-request-id') raise exp - deserialized = None - - if response.status_code == 200: - deserialized = self._deserialize('SyncMember', response) - if response.status_code == 201: - deserialized = self._deserialize('SyncMember', response) + deserialized = self._deserialize('SyncMember', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) @@ -206,10 +241,6 @@ def get_long_running_output(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) @@ -217,6 +248,48 @@ def get_long_running_output(response): long_running_send, get_long_running_output, get_long_running_status, long_running_operation_timeout) + + def _delete_initial( + self, resource_group_name, server_name, database_name, sync_group_name, sync_member_name, custom_headers=None, raw=False, **operation_config): + # Construct URL + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}' + 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'), + 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), + 'syncMemberName': self._serialize.url("sync_member_name", sync_member_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.delete(url, query_parameters) + response = self._client.send(request, header_parameters, stream=False, **operation_config) + + 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 + def delete( self, resource_group_name, server_name, database_name, sync_group_name, sync_member_name, custom_headers=None, raw=False, **operation_config): """Deletes a sync member. @@ -244,6 +317,54 @@ def delete( ~msrest.pipeline.ClientRawResponse :raises: :class:`CloudError` """ + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + sync_group_name=sync_group_name, + sync_member_name=sync_member_name, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + if raw: + return raw_result + + # Construct and send request + def long_running_send(): + return raw_result.response + + def get_long_running_status(status_link, headers=None): + + request = self._client.get(status_link) + if headers: + request.headers.update(headers) + header_parameters = {} + header_parameters['x-ms-client-request-id'] = raw_result.response.request.headers['x-ms-client-request-id'] + return self._client.send( + request, header_parameters, stream=False, **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 + + 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_initial( + self, resource_group_name, server_name, database_name, sync_group_name, sync_member_name, parameters, custom_headers=None, raw=False, **operation_config): # Construct URL url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}' path_format_arguments = { @@ -270,41 +391,29 @@ def delete( 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): + # Construct body + body_content = self._serialize.body(parameters, 'SyncMember') - request = self._client.get(status_link) - if headers: - request.headers.update(headers) - return self._client.send( - request, header_parameters, **operation_config) + # Construct and send request + request = self._client.patch(url, query_parameters) + response = self._client.send( + request, header_parameters, body_content, stream=False, **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 - if response.status_code not in [200, 202, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + deserialized = None - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + if response.status_code == 200: + deserialized = self._deserialize('SyncMember', response) if raw: - response = long_running_send() - return get_long_running_output(response) + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_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) + return deserialized def update( self, resource_group_name, server_name, database_name, sync_group_name, sync_member_name, parameters, custom_headers=None, raw=False, **operation_config): @@ -336,49 +445,33 @@ def update( or ~msrest.pipeline.ClientRawResponse :raises: :class:`CloudError` """ - # Construct URL - url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}' - 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'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'syncMemberName': self._serialize.url("sync_member_name", sync_member_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, 'SyncMember') + raw_result = self._update_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + sync_group_name=sync_group_name, + sync_member_name=sync_member_name, + parameters=parameters, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + if raw: + return raw_result # 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) + return raw_result.response def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) if headers: request.headers.update(headers) + header_parameters = {} + header_parameters['x-ms-client-request-id'] = raw_result.response.request.headers['x-ms-client-request-id'] return self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) def get_long_running_output(response): @@ -387,10 +480,7 @@ def get_long_running_output(response): exp.request_id = response.headers.get('x-ms-request-id') raise exp - deserialized = None - - if response.status_code == 200: - deserialized = self._deserialize('SyncMember', response) + deserialized = self._deserialize('SyncMember', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) @@ -398,10 +488,6 @@ def get_long_running_output(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) @@ -469,7 +555,7 @@ def internal_paging(next_link=None, raw=False): # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) @@ -552,7 +638,7 @@ def internal_paging(next_link=None, raw=False): # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) @@ -571,6 +657,48 @@ def internal_paging(next_link=None, raw=False): return deserialized + + def _refresh_member_schema_initial( + self, resource_group_name, server_name, database_name, sync_group_name, sync_member_name, custom_headers=None, raw=False, **operation_config): + # Construct URL + url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}/refreshSchema' + 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'), + 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), + 'syncMemberName': self._serialize.url("sync_member_name", sync_member_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.post(url, query_parameters) + response = self._client.send(request, header_parameters, stream=False, **operation_config) + + if response.status_code not in [200, 202]: + 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 refresh_member_schema( self, resource_group_name, server_name, database_name, sync_group_name, sync_member_name, custom_headers=None, raw=False, **operation_config): """Refreshes a sync member database schema. @@ -598,45 +726,32 @@ def refresh_member_schema( ~msrest.pipeline.ClientRawResponse :raises: :class:`CloudError` """ - # Construct URL - url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}/refreshSchema' - 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'), - 'syncGroupName': self._serialize.url("sync_group_name", sync_group_name, 'str'), - 'syncMemberName': self._serialize.url("sync_member_name", sync_member_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') + raw_result = self._refresh_member_schema_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + sync_group_name=sync_group_name, + sync_member_name=sync_member_name, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + if raw: + return raw_result # Construct and send request def long_running_send(): - - request = self._client.post(url, query_parameters) - return self._client.send(request, header_parameters, **operation_config) + return raw_result.response def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) if headers: request.headers.update(headers) + header_parameters = {} + header_parameters['x-ms-client-request-id'] = raw_result.response.request.headers['x-ms-client-request-id'] return self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) def get_long_running_output(response): @@ -649,10 +764,6 @@ def get_long_running_output(response): 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) diff --git a/azure-mgmt-sql/azure/mgmt/sql/operations/transparent_data_encryption_activities_operations.py b/azure-mgmt-sql/azure/mgmt/sql/operations/transparent_data_encryption_activities_operations.py index 17aff326251e..5db7032d0821 100644 --- a/azure-mgmt-sql/azure/mgmt/sql/operations/transparent_data_encryption_activities_operations.py +++ b/azure-mgmt-sql/azure/mgmt/sql/operations/transparent_data_encryption_activities_operations.py @@ -98,7 +98,7 @@ def internal_paging(next_link=None, raw=False): # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) diff --git a/azure-mgmt-sql/azure/mgmt/sql/operations/transparent_data_encryptions_operations.py b/azure-mgmt-sql/azure/mgmt/sql/operations/transparent_data_encryptions_operations.py index 46d591ab0fe0..8c1e412de709 100644 --- a/azure-mgmt-sql/azure/mgmt/sql/operations/transparent_data_encryptions_operations.py +++ b/azure-mgmt-sql/azure/mgmt/sql/operations/transparent_data_encryptions_operations.py @@ -100,7 +100,7 @@ def create_or_update( # Construct and send request request = self._client.put(url, query_parameters) response = self._client.send( - request, header_parameters, body_content, **operation_config) + request, header_parameters, body_content, stream=False, **operation_config) if response.status_code not in [200, 201]: exp = CloudError(response) @@ -170,7 +170,7 @@ def get( # Construct and send request request = self._client.get(url, query_parameters) - response = self._client.send(request, header_parameters, **operation_config) + response = self._client.send(request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) diff --git a/azure-mgmt-sql/azure/mgmt/sql/operations/virtual_network_rules_operations.py b/azure-mgmt-sql/azure/mgmt/sql/operations/virtual_network_rules_operations.py index 82a4785fcbe9..348a02f0c4c0 100644 --- a/azure-mgmt-sql/azure/mgmt/sql/operations/virtual_network_rules_operations.py +++ b/azure-mgmt-sql/azure/mgmt/sql/operations/virtual_network_rules_operations.py @@ -12,6 +12,7 @@ import uuid from msrest.pipeline import ClientRawResponse from msrestazure.azure_exceptions import CloudError +from msrest.exceptions import DeserializationError from msrestazure.azure_operation import AzureOperationPoller from .. import models @@ -87,7 +88,7 @@ def get( # Construct and send request request = self._client.get(url, query_parameters) - response = self._client.send(request, header_parameters, **operation_config) + response = self._client.send(request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) @@ -105,35 +106,9 @@ def get( return deserialized - def create_or_update( - self, resource_group_name, server_name, virtual_network_rule_name, virtual_network_subnet_id, ignore_missing_vnet_service_endpoint=None, custom_headers=None, raw=False, **operation_config): - """Creates or updates an existing virtual network rule. - :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 virtual_network_rule_name: The name of the virtual network - rule. - :type virtual_network_rule_name: str - :param virtual_network_subnet_id: The ARM resource id of the virtual - network subnet. - :type virtual_network_subnet_id: str - :param ignore_missing_vnet_service_endpoint: Create firewall rule - before the virtual network has vnet service endpoint enabled. - :type ignore_missing_vnet_service_endpoint: bool - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :return: An instance of AzureOperationPoller that returns - VirtualNetworkRule or ClientRawResponse if raw=true - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.sql.models.VirtualNetworkRule] - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` - """ + def _create_or_update_initial( + self, resource_group_name, server_name, virtual_network_rule_name, virtual_network_subnet_id, ignore_missing_vnet_service_endpoint=None, custom_headers=None, raw=False, **operation_config): parameters = models.VirtualNetworkRule(virtual_network_subnet_id=virtual_network_subnet_id, ignore_missing_vnet_service_endpoint=ignore_missing_vnet_service_endpoint) # Construct URL @@ -164,19 +139,83 @@ def create_or_update( body_content = self._serialize.body(parameters, 'VirtualNetworkRule') # Construct and send request - def long_running_send(): + request = self._client.put(url, query_parameters) + response = self._client.send( + request, header_parameters, body_content, stream=False, **operation_config) - request = self._client.put(url, query_parameters) - return self._client.send( - request, header_parameters, body_content, **operation_config) + if response.status_code not in [200, 201, 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('VirtualNetworkRule', response) + if response.status_code == 201: + deserialized = self._deserialize('VirtualNetworkRule', 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, virtual_network_rule_name, virtual_network_subnet_id, ignore_missing_vnet_service_endpoint=None, custom_headers=None, raw=False, **operation_config): + """Creates or updates an existing virtual network rule. + + :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 virtual_network_rule_name: The name of the virtual network + rule. + :type virtual_network_rule_name: str + :param virtual_network_subnet_id: The ARM resource id of the virtual + network subnet. + :type virtual_network_subnet_id: str + :param ignore_missing_vnet_service_endpoint: Create firewall rule + before the virtual network has vnet service endpoint enabled. + :type ignore_missing_vnet_service_endpoint: bool + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :return: An instance of AzureOperationPoller that returns + VirtualNetworkRule or ClientRawResponse if raw=true + :rtype: + ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.sql.models.VirtualNetworkRule] + or ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + server_name=server_name, + virtual_network_rule_name=virtual_network_rule_name, + virtual_network_subnet_id=virtual_network_subnet_id, + ignore_missing_vnet_service_endpoint=ignore_missing_vnet_service_endpoint, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + if raw: + return raw_result + + # Construct and send request + def long_running_send(): + return raw_result.response def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) if headers: request.headers.update(headers) + header_parameters = {} + header_parameters['x-ms-client-request-id'] = raw_result.response.request.headers['x-ms-client-request-id'] return self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) def get_long_running_output(response): @@ -185,12 +224,7 @@ def get_long_running_output(response): exp.request_id = response.headers.get('x-ms-request-id') raise exp - deserialized = None - - if response.status_code == 200: - deserialized = self._deserialize('VirtualNetworkRule', response) - if response.status_code == 201: - deserialized = self._deserialize('VirtualNetworkRule', response) + deserialized = self._deserialize('VirtualNetworkRule', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) @@ -198,10 +232,6 @@ def get_long_running_output(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) @@ -209,28 +239,9 @@ def get_long_running_output(response): long_running_send, get_long_running_output, get_long_running_status, long_running_operation_timeout) - def delete( - self, resource_group_name, server_name, virtual_network_rule_name, custom_headers=None, raw=False, **operation_config): - """Deletes the virtual network rule with the given name. - :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 virtual_network_rule_name: The name of the virtual network - rule. - :type virtual_network_rule_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 - :return: An instance of AzureOperationPoller that returns None or - ClientRawResponse if raw=true - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` - """ + def _delete_initial( + self, resource_group_name, server_name, virtual_network_rule_name, custom_headers=None, raw=False, **operation_config): # Construct URL url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/virtualNetworkRules/{virtualNetworkRuleName}' path_format_arguments = { @@ -256,18 +267,64 @@ def delete( 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) + response = self._client.send(request, header_parameters, stream=False, **operation_config) - request = self._client.delete(url, query_parameters) - return self._client.send(request, header_parameters, **operation_config) + 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 + + def delete( + self, resource_group_name, server_name, virtual_network_rule_name, custom_headers=None, raw=False, **operation_config): + """Deletes the virtual network rule with the given name. + + :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 virtual_network_rule_name: The name of the virtual network + rule. + :type virtual_network_rule_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 + :return: An instance of AzureOperationPoller that returns None or + ClientRawResponse if raw=true + :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or + ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + server_name=server_name, + virtual_network_rule_name=virtual_network_rule_name, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + if raw: + return raw_result + + # Construct and send request + def long_running_send(): + return raw_result.response def get_long_running_status(status_link, headers=None): request = self._client.get(status_link) if headers: request.headers.update(headers) + header_parameters = {} + header_parameters['x-ms-client-request-id'] = raw_result.response.request.headers['x-ms-client-request-id'] return self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) def get_long_running_output(response): @@ -280,10 +337,6 @@ def get_long_running_output(response): 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) @@ -344,7 +397,7 @@ def internal_paging(next_link=None, raw=False): # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send( - request, header_parameters, **operation_config) + request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: exp = CloudError(response) 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 a54c814a166d..d5a85aacee53 100644 --- a/azure-mgmt-sql/azure/mgmt/sql/sql_management_client.py +++ b/azure-mgmt-sql/azure/mgmt/sql/sql_management_client.py @@ -19,19 +19,19 @@ from .operations.recoverable_databases_operations import RecoverableDatabasesOperations from .operations.restorable_dropped_databases_operations import RestorableDroppedDatabasesOperations from .operations.capabilities_operations import CapabilitiesOperations +from .operations.servers_operations import ServersOperations from .operations.server_connection_policies_operations import ServerConnectionPoliciesOperations +from .operations.databases_operations import DatabasesOperations from .operations.database_threat_detection_policies_operations import DatabaseThreatDetectionPoliciesOperations from .operations.data_masking_policies_operations import DataMaskingPoliciesOperations from .operations.data_masking_rules_operations import DataMaskingRulesOperations +from .operations.elastic_pools_operations import ElasticPoolsOperations from .operations.firewall_rules_operations import FirewallRulesOperations from .operations.geo_backup_policies_operations import GeoBackupPoliciesOperations -from .operations.databases_operations import DatabasesOperations -from .operations.elastic_pools_operations import ElasticPoolsOperations from .operations.replication_links_operations import ReplicationLinksOperations from .operations.server_azure_ad_administrators_operations import ServerAzureADAdministratorsOperations from .operations.server_communication_links_operations import ServerCommunicationLinksOperations from .operations.service_objectives_operations import ServiceObjectivesOperations -from .operations.servers_operations import ServersOperations from .operations.elastic_pool_activities_operations import ElasticPoolActivitiesOperations from .operations.elastic_pool_database_activities_operations import ElasticPoolDatabaseActivitiesOperations from .operations.recommended_elastic_pools_operations import RecommendedElasticPoolsOperations @@ -41,6 +41,7 @@ from .operations.server_usages_operations import ServerUsagesOperations from .operations.database_usages_operations import DatabaseUsagesOperations from .operations.database_blob_auditing_policies_operations import DatabaseBlobAuditingPoliciesOperations +from .operations.database_automatic_tuning_operations import DatabaseAutomaticTuningOperations from .operations.encryption_protectors_operations import EncryptionProtectorsOperations from .operations.failover_groups_operations import FailoverGroupsOperations from .operations.operations import Operations @@ -51,6 +52,7 @@ from .operations.subscription_usages_operations import SubscriptionUsagesOperations from .operations.virtual_network_rules_operations import VirtualNetworkRulesOperations from .operations.database_operations import DatabaseOperations +from .operations.server_automatic_tuning_operations import ServerAutomaticTuningOperations from .operations.server_dns_aliases_operations import ServerDnsAliasesOperations from . import models @@ -106,22 +108,24 @@ class SqlManagementClient(object): :vartype restorable_dropped_databases: azure.mgmt.sql.operations.RestorableDroppedDatabasesOperations :ivar capabilities: Capabilities operations :vartype capabilities: azure.mgmt.sql.operations.CapabilitiesOperations + :ivar servers: Servers operations + :vartype servers: azure.mgmt.sql.operations.ServersOperations :ivar server_connection_policies: ServerConnectionPolicies operations :vartype server_connection_policies: azure.mgmt.sql.operations.ServerConnectionPoliciesOperations + :ivar databases: Databases operations + :vartype databases: azure.mgmt.sql.operations.DatabasesOperations :ivar database_threat_detection_policies: DatabaseThreatDetectionPolicies operations :vartype database_threat_detection_policies: azure.mgmt.sql.operations.DatabaseThreatDetectionPoliciesOperations :ivar data_masking_policies: DataMaskingPolicies operations :vartype data_masking_policies: azure.mgmt.sql.operations.DataMaskingPoliciesOperations :ivar data_masking_rules: DataMaskingRules operations :vartype data_masking_rules: azure.mgmt.sql.operations.DataMaskingRulesOperations + :ivar elastic_pools: ElasticPools operations + :vartype elastic_pools: azure.mgmt.sql.operations.ElasticPoolsOperations :ivar firewall_rules: FirewallRules operations :vartype firewall_rules: azure.mgmt.sql.operations.FirewallRulesOperations :ivar geo_backup_policies: GeoBackupPolicies operations :vartype geo_backup_policies: azure.mgmt.sql.operations.GeoBackupPoliciesOperations - :ivar databases: Databases operations - :vartype databases: azure.mgmt.sql.operations.DatabasesOperations - :ivar elastic_pools: ElasticPools operations - :vartype elastic_pools: azure.mgmt.sql.operations.ElasticPoolsOperations :ivar replication_links: ReplicationLinks operations :vartype replication_links: azure.mgmt.sql.operations.ReplicationLinksOperations :ivar server_azure_ad_administrators: ServerAzureADAdministrators operations @@ -130,8 +134,6 @@ class SqlManagementClient(object): :vartype server_communication_links: azure.mgmt.sql.operations.ServerCommunicationLinksOperations :ivar service_objectives: ServiceObjectives operations :vartype service_objectives: azure.mgmt.sql.operations.ServiceObjectivesOperations - :ivar servers: Servers operations - :vartype servers: azure.mgmt.sql.operations.ServersOperations :ivar elastic_pool_activities: ElasticPoolActivities operations :vartype elastic_pool_activities: azure.mgmt.sql.operations.ElasticPoolActivitiesOperations :ivar elastic_pool_database_activities: ElasticPoolDatabaseActivities operations @@ -150,6 +152,8 @@ class SqlManagementClient(object): :vartype database_usages: azure.mgmt.sql.operations.DatabaseUsagesOperations :ivar database_blob_auditing_policies: DatabaseBlobAuditingPolicies operations :vartype database_blob_auditing_policies: azure.mgmt.sql.operations.DatabaseBlobAuditingPoliciesOperations + :ivar database_automatic_tuning: DatabaseAutomaticTuning operations + :vartype database_automatic_tuning: azure.mgmt.sql.operations.DatabaseAutomaticTuningOperations :ivar encryption_protectors: EncryptionProtectors operations :vartype encryption_protectors: azure.mgmt.sql.operations.EncryptionProtectorsOperations :ivar failover_groups: FailoverGroups operations @@ -170,6 +174,8 @@ class SqlManagementClient(object): :vartype virtual_network_rules: azure.mgmt.sql.operations.VirtualNetworkRulesOperations :ivar database_operations: DatabaseOperations operations :vartype database_operations: azure.mgmt.sql.operations.DatabaseOperations + :ivar server_automatic_tuning: ServerAutomaticTuning operations + :vartype server_automatic_tuning: azure.mgmt.sql.operations.ServerAutomaticTuningOperations :ivar server_dns_aliases: ServerDnsAliases operations :vartype server_dns_aliases: azure.mgmt.sql.operations.ServerDnsAliasesOperations @@ -204,22 +210,24 @@ def __init__( self._client, self.config, self._serialize, self._deserialize) self.capabilities = CapabilitiesOperations( self._client, self.config, self._serialize, self._deserialize) + self.servers = ServersOperations( + self._client, self.config, self._serialize, self._deserialize) self.server_connection_policies = ServerConnectionPoliciesOperations( self._client, self.config, self._serialize, self._deserialize) + self.databases = DatabasesOperations( + self._client, self.config, self._serialize, self._deserialize) self.database_threat_detection_policies = DatabaseThreatDetectionPoliciesOperations( self._client, self.config, self._serialize, self._deserialize) self.data_masking_policies = DataMaskingPoliciesOperations( self._client, self.config, self._serialize, self._deserialize) self.data_masking_rules = DataMaskingRulesOperations( self._client, self.config, self._serialize, self._deserialize) + self.elastic_pools = ElasticPoolsOperations( + self._client, self.config, self._serialize, self._deserialize) self.firewall_rules = FirewallRulesOperations( self._client, self.config, self._serialize, self._deserialize) self.geo_backup_policies = GeoBackupPoliciesOperations( self._client, self.config, self._serialize, self._deserialize) - self.databases = DatabasesOperations( - self._client, self.config, self._serialize, self._deserialize) - self.elastic_pools = ElasticPoolsOperations( - self._client, self.config, self._serialize, self._deserialize) self.replication_links = ReplicationLinksOperations( self._client, self.config, self._serialize, self._deserialize) self.server_azure_ad_administrators = ServerAzureADAdministratorsOperations( @@ -228,8 +236,6 @@ def __init__( self._client, self.config, self._serialize, self._deserialize) self.service_objectives = ServiceObjectivesOperations( self._client, self.config, self._serialize, self._deserialize) - self.servers = ServersOperations( - self._client, self.config, self._serialize, self._deserialize) self.elastic_pool_activities = ElasticPoolActivitiesOperations( self._client, self.config, self._serialize, self._deserialize) self.elastic_pool_database_activities = ElasticPoolDatabaseActivitiesOperations( @@ -248,6 +254,8 @@ def __init__( self._client, self.config, self._serialize, self._deserialize) self.database_blob_auditing_policies = DatabaseBlobAuditingPoliciesOperations( self._client, self.config, self._serialize, self._deserialize) + self.database_automatic_tuning = DatabaseAutomaticTuningOperations( + self._client, self.config, self._serialize, self._deserialize) self.encryption_protectors = EncryptionProtectorsOperations( self._client, self.config, self._serialize, self._deserialize) self.failover_groups = FailoverGroupsOperations( @@ -268,5 +276,7 @@ def __init__( self._client, self.config, self._serialize, self._deserialize) self.database_operations = DatabaseOperations( self._client, self.config, self._serialize, self._deserialize) + self.server_automatic_tuning = ServerAutomaticTuningOperations( + self._client, self.config, self._serialize, self._deserialize) self.server_dns_aliases = ServerDnsAliasesOperations( 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 c806fd2eb6c3..53a203f32aaf 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.5" +VERSION = ""