diff --git a/lib/services/sqlManagement2/LICENSE.txt b/lib/services/sqlManagement2/LICENSE.txt index 5431ba98b9..8f3d856145 100644 --- a/lib/services/sqlManagement2/LICENSE.txt +++ b/lib/services/sqlManagement2/LICENSE.txt @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2018 Microsoft +Copyright (c) 2019 Microsoft Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/lib/services/sqlManagement2/lib/models/index.d.ts b/lib/services/sqlManagement2/lib/models/index.d.ts index c5e73a0727..33febab8c6 100644 --- a/lib/services/sqlManagement2/lib/models/index.d.ts +++ b/lib/services/sqlManagement2/lib/models/index.d.ts @@ -3118,6 +3118,27 @@ export interface ServerSecurityAlertPolicy extends ProxyResource { readonly creationTime?: Date; } +/** + * @class + * Initializes a new instance of the RestorableDroppedManagedDatabase class. + * @constructor + * A restorable dropped managed database resource. + * + * @property {string} [databaseName] The name of the database. + * @property {date} [creationDate] The creation date of the database (ISO8601 + * format). + * @property {date} [deletionDate] The deletion date of the database (ISO8601 + * format). + * @property {date} [earliestRestoreDate] The earliest restore date of the + * database (ISO8601 format). + */ +export interface RestorableDroppedManagedDatabase extends TrackedResource { + readonly databaseName?: string; + readonly creationDate?: Date; + readonly deletionDate?: Date; + readonly earliestRestoreDate?: Date; +} + /** * @class * Initializes a new instance of the RestorePoint class. @@ -4433,6 +4454,18 @@ export interface ManagedInstanceEncryptionProtector extends ProxyResource { readonly thumbprint?: string; } +/** + * @class + * Initializes a new instance of the RecoverableManagedDatabase class. + * @constructor + * A recoverable managed database resource. + * + * @property {string} [lastAvailableBackupDate] The last available backup date. + */ +export interface RecoverableManagedDatabase extends ProxyResource { + readonly lastAvailableBackupDate?: string; +} + /** * @class * Initializes a new instance of the ManagedInstanceVulnerabilityAssessment class. @@ -5037,6 +5070,18 @@ export interface ServerDnsAliasListResult extends Array { readonly nextLink?: string; } +/** + * @class + * Initializes a new instance of the RestorableDroppedManagedDatabaseListResult class. + * @constructor + * A list of restorable dropped managed databases. + * + * @property {string} [nextLink] Link to retrieve next page of results. + */ +export interface RestorableDroppedManagedDatabaseListResult extends Array { + readonly nextLink?: string; +} + /** * @class * Initializes a new instance of the RestorePointListResult class. @@ -5133,6 +5178,18 @@ export interface ManagedInstanceEncryptionProtectorListResult extends Array { + readonly nextLink?: string; +} + /** * @class * Initializes a new instance of the ManagedInstanceVulnerabilityAssessmentListResult class. diff --git a/lib/services/sqlManagement2/lib/models/index.js b/lib/services/sqlManagement2/lib/models/index.js index 425e9c878b..7c74c081f5 100644 --- a/lib/services/sqlManagement2/lib/models/index.js +++ b/lib/services/sqlManagement2/lib/models/index.js @@ -121,6 +121,7 @@ exports.ServerAutomaticTuning = require('./serverAutomaticTuning'); exports.ServerDnsAlias = require('./serverDnsAlias'); exports.ServerDnsAliasAcquisition = require('./serverDnsAliasAcquisition'); exports.ServerSecurityAlertPolicy = require('./serverSecurityAlertPolicy'); +exports.RestorableDroppedManagedDatabase = require('./restorableDroppedManagedDatabase'); exports.RestorePoint = require('./restorePoint'); exports.CreateDatabaseRestorePointDefinition = require('./createDatabaseRestorePointDefinition'); exports.ManagedDatabaseSecurityAlertPolicy = require('./managedDatabaseSecurityAlertPolicy'); @@ -162,6 +163,7 @@ exports.BackupShortTermRetentionPolicy = require('./backupShortTermRetentionPoli exports.TdeCertificate = require('./tdeCertificate'); exports.ManagedInstanceKey = require('./managedInstanceKey'); exports.ManagedInstanceEncryptionProtector = require('./managedInstanceEncryptionProtector'); +exports.RecoverableManagedDatabase = require('./recoverableManagedDatabase'); exports.ManagedInstanceVulnerabilityAssessment = require('./managedInstanceVulnerabilityAssessment'); exports.ServerVulnerabilityAssessment = require('./serverVulnerabilityAssessment'); exports.RecoverableDatabaseListResult = require('./recoverableDatabaseListResult'); @@ -212,6 +214,7 @@ exports.LongTermRetentionBackupListResult = require('./longTermRetentionBackupLi exports.ManagedBackupShortTermRetentionPolicyListResult = require('./managedBackupShortTermRetentionPolicyListResult'); exports.ManagedDatabaseListResult = require('./managedDatabaseListResult'); exports.ServerDnsAliasListResult = require('./serverDnsAliasListResult'); +exports.RestorableDroppedManagedDatabaseListResult = require('./restorableDroppedManagedDatabaseListResult'); exports.RestorePointListResult = require('./restorePointListResult'); exports.DatabaseOperationListResult = require('./databaseOperationListResult'); exports.ElasticPoolOperationListResult = require('./elasticPoolOperationListResult'); @@ -220,5 +223,6 @@ exports.InstanceFailoverGroupListResult = require('./instanceFailoverGroupListRe exports.BackupShortTermRetentionPolicyListResult = require('./backupShortTermRetentionPolicyListResult'); exports.ManagedInstanceKeyListResult = require('./managedInstanceKeyListResult'); exports.ManagedInstanceEncryptionProtectorListResult = require('./managedInstanceEncryptionProtectorListResult'); +exports.RecoverableManagedDatabaseListResult = require('./recoverableManagedDatabaseListResult'); exports.ManagedInstanceVulnerabilityAssessmentListResult = require('./managedInstanceVulnerabilityAssessmentListResult'); exports.ServerVulnerabilityAssessmentListResult = require('./serverVulnerabilityAssessmentListResult'); diff --git a/lib/services/sqlManagement2/lib/models/recoverableManagedDatabase.js b/lib/services/sqlManagement2/lib/models/recoverableManagedDatabase.js new file mode 100644 index 0000000000..42fda76f71 --- /dev/null +++ b/lib/services/sqlManagement2/lib/models/recoverableManagedDatabase.js @@ -0,0 +1,82 @@ +/* + * 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. + */ + +'use strict'; + +const models = require('./index'); + +/** + * A recoverable managed database resource. + * + * @extends models['ProxyResource'] + */ +class RecoverableManagedDatabase extends models['ProxyResource'] { + /** + * Create a RecoverableManagedDatabase. + * @property {string} [lastAvailableBackupDate] The last available backup + * date. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of RecoverableManagedDatabase + * + * @returns {object} metadata of RecoverableManagedDatabase + * + */ + mapper() { + return { + required: false, + serializedName: 'RecoverableManagedDatabase', + type: { + name: 'Composite', + className: 'RecoverableManagedDatabase', + modelProperties: { + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + name: { + required: false, + readOnly: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + type: { + required: false, + readOnly: true, + serializedName: 'type', + type: { + name: 'String' + } + }, + lastAvailableBackupDate: { + required: false, + readOnly: true, + serializedName: 'properties.lastAvailableBackupDate', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = RecoverableManagedDatabase; diff --git a/lib/services/sqlManagement2/lib/models/recoverableManagedDatabaseListResult.js b/lib/services/sqlManagement2/lib/models/recoverableManagedDatabaseListResult.js new file mode 100644 index 0000000000..5a3d20e65d --- /dev/null +++ b/lib/services/sqlManagement2/lib/models/recoverableManagedDatabaseListResult.js @@ -0,0 +1,69 @@ +/* + * 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. + */ + +'use strict'; + +/** + * A list of recoverable managed databases. + */ +class RecoverableManagedDatabaseListResult extends Array { + /** + * Create a RecoverableManagedDatabaseListResult. + * @property {string} [nextLink] Link to retrieve next page of results. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of RecoverableManagedDatabaseListResult + * + * @returns {object} metadata of RecoverableManagedDatabaseListResult + * + */ + mapper() { + return { + required: false, + serializedName: 'RecoverableManagedDatabaseListResult', + type: { + name: 'Composite', + className: 'RecoverableManagedDatabaseListResult', + modelProperties: { + value: { + required: false, + readOnly: true, + serializedName: '', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'RecoverableManagedDatabaseElementType', + type: { + name: 'Composite', + className: 'RecoverableManagedDatabase' + } + } + } + }, + nextLink: { + required: false, + readOnly: true, + serializedName: 'nextLink', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = RecoverableManagedDatabaseListResult; diff --git a/lib/services/sqlManagement2/lib/models/restorableDroppedManagedDatabase.js b/lib/services/sqlManagement2/lib/models/restorableDroppedManagedDatabase.js new file mode 100644 index 0000000000..695502b4b9 --- /dev/null +++ b/lib/services/sqlManagement2/lib/models/restorableDroppedManagedDatabase.js @@ -0,0 +1,132 @@ +/* + * 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. + */ + +'use strict'; + +const models = require('./index'); + +/** + * A restorable dropped managed database resource. + * + * @extends models['TrackedResource'] + */ +class RestorableDroppedManagedDatabase extends models['TrackedResource'] { + /** + * Create a RestorableDroppedManagedDatabase. + * @property {string} [databaseName] The name of the database. + * @property {date} [creationDate] The creation date of the database (ISO8601 + * format). + * @property {date} [deletionDate] The deletion date of the database (ISO8601 + * format). + * @property {date} [earliestRestoreDate] The earliest restore date of the + * database (ISO8601 format). + */ + constructor() { + super(); + } + + /** + * Defines the metadata of RestorableDroppedManagedDatabase + * + * @returns {object} metadata of RestorableDroppedManagedDatabase + * + */ + mapper() { + return { + required: false, + serializedName: 'RestorableDroppedManagedDatabase', + type: { + name: 'Composite', + className: 'RestorableDroppedManagedDatabase', + modelProperties: { + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + name: { + required: false, + readOnly: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + type: { + required: false, + readOnly: true, + serializedName: 'type', + type: { + name: 'String' + } + }, + location: { + required: true, + serializedName: 'location', + type: { + name: 'String' + } + }, + tags: { + required: false, + serializedName: 'tags', + type: { + name: 'Dictionary', + value: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + databaseName: { + required: false, + readOnly: true, + serializedName: 'properties.databaseName', + type: { + name: 'String' + } + }, + creationDate: { + required: false, + readOnly: true, + serializedName: 'properties.creationDate', + type: { + name: 'DateTime' + } + }, + deletionDate: { + required: false, + readOnly: true, + serializedName: 'properties.deletionDate', + type: { + name: 'DateTime' + } + }, + earliestRestoreDate: { + required: false, + readOnly: true, + serializedName: 'properties.earliestRestoreDate', + type: { + name: 'DateTime' + } + } + } + } + }; + } +} + +module.exports = RestorableDroppedManagedDatabase; diff --git a/lib/services/sqlManagement2/lib/models/restorableDroppedManagedDatabaseListResult.js b/lib/services/sqlManagement2/lib/models/restorableDroppedManagedDatabaseListResult.js new file mode 100644 index 0000000000..ef25bc0af7 --- /dev/null +++ b/lib/services/sqlManagement2/lib/models/restorableDroppedManagedDatabaseListResult.js @@ -0,0 +1,69 @@ +/* + * 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. + */ + +'use strict'; + +/** + * A list of restorable dropped managed databases. + */ +class RestorableDroppedManagedDatabaseListResult extends Array { + /** + * Create a RestorableDroppedManagedDatabaseListResult. + * @property {string} [nextLink] Link to retrieve next page of results. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of RestorableDroppedManagedDatabaseListResult + * + * @returns {object} metadata of RestorableDroppedManagedDatabaseListResult + * + */ + mapper() { + return { + required: false, + serializedName: 'RestorableDroppedManagedDatabaseListResult', + type: { + name: 'Composite', + className: 'RestorableDroppedManagedDatabaseListResult', + modelProperties: { + value: { + required: false, + readOnly: true, + serializedName: '', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'RestorableDroppedManagedDatabaseElementType', + type: { + name: 'Composite', + className: 'RestorableDroppedManagedDatabase' + } + } + } + }, + nextLink: { + required: false, + readOnly: true, + serializedName: 'nextLink', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = RestorableDroppedManagedDatabaseListResult; diff --git a/lib/services/sqlManagement2/lib/operations/index.d.ts b/lib/services/sqlManagement2/lib/operations/index.d.ts index d33717992d..55dab3428b 100644 --- a/lib/services/sqlManagement2/lib/operations/index.d.ts +++ b/lib/services/sqlManagement2/lib/operations/index.d.ts @@ -23495,9 +23495,9 @@ export interface LongTermRetentionBackups { * * @param {string} locationName The location of the database. * - * @param {string} longTermRetentionServerName + * @param {string} longTermRetentionServerName The name of the server * - * @param {string} longTermRetentionDatabaseName + * @param {string} longTermRetentionDatabaseName The name of the database * * @param {string} backupName The backup name. * @@ -23519,9 +23519,9 @@ export interface LongTermRetentionBackups { * * @param {string} locationName The location of the database. * - * @param {string} longTermRetentionServerName + * @param {string} longTermRetentionServerName The name of the server * - * @param {string} longTermRetentionDatabaseName + * @param {string} longTermRetentionDatabaseName The name of the database * * @param {string} backupName The backup name. * @@ -23563,9 +23563,9 @@ export interface LongTermRetentionBackups { * * @param {string} locationName The location of the database * - * @param {string} longTermRetentionServerName + * @param {string} longTermRetentionServerName The name of the server * - * @param {string} longTermRetentionDatabaseName + * @param {string} longTermRetentionDatabaseName The name of the database * * @param {string} backupName The backup name. * @@ -23587,9 +23587,9 @@ export interface LongTermRetentionBackups { * * @param {string} locationName The location of the database * - * @param {string} longTermRetentionServerName + * @param {string} longTermRetentionServerName The name of the server * - * @param {string} longTermRetentionDatabaseName + * @param {string} longTermRetentionDatabaseName The name of the database * * @param {string} backupName The backup name. * @@ -23629,9 +23629,9 @@ export interface LongTermRetentionBackups { * * @param {string} locationName The location of the database * - * @param {string} longTermRetentionServerName + * @param {string} longTermRetentionServerName The name of the server * - * @param {string} longTermRetentionDatabaseName + * @param {string} longTermRetentionDatabaseName The name of the database * * @param {object} [options] Optional Parameters. * @@ -23658,9 +23658,9 @@ export interface LongTermRetentionBackups { * * @param {string} locationName The location of the database * - * @param {string} longTermRetentionServerName + * @param {string} longTermRetentionServerName The name of the server * - * @param {string} longTermRetentionDatabaseName + * @param {string} longTermRetentionDatabaseName The name of the database * * @param {object} [options] Optional Parameters. * @@ -23777,7 +23777,7 @@ export interface LongTermRetentionBackups { * * @param {string} locationName The location of the database * - * @param {string} longTermRetentionServerName + * @param {string} longTermRetentionServerName The name of the server * * @param {object} [options] Optional Parameters. * @@ -23804,7 +23804,7 @@ export interface LongTermRetentionBackups { * * @param {string} locationName The location of the database * - * @param {string} longTermRetentionServerName + * @param {string} longTermRetentionServerName The name of the server * * @param {object} [options] Optional Parameters. * @@ -23851,9 +23851,9 @@ export interface LongTermRetentionBackups { * * @param {string} locationName The location of the database * - * @param {string} longTermRetentionServerName + * @param {string} longTermRetentionServerName The name of the server * - * @param {string} longTermRetentionDatabaseName + * @param {string} longTermRetentionDatabaseName The name of the database * * @param {string} backupName The backup name. * @@ -23875,9 +23875,9 @@ export interface LongTermRetentionBackups { * * @param {string} locationName The location of the database * - * @param {string} longTermRetentionServerName + * @param {string} longTermRetentionServerName The name of the server * - * @param {string} longTermRetentionDatabaseName + * @param {string} longTermRetentionDatabaseName The name of the database * * @param {string} backupName The backup name. * @@ -26034,6 +26034,523 @@ export interface ManagedDatabases { listByInstanceNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; } +/** + * @class + * ManagedRestorableDroppedDatabaseBackupShortTermRetentionPolicies + * __NOTE__: An instance of this class is automatically created for an + * instance of the SqlManagementClient. + */ +export interface ManagedRestorableDroppedDatabaseBackupShortTermRetentionPolicies { + + + /** + * Gets a dropped database's short term retention policy. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} managedInstanceName The name of the managed instance. + * + * @param {string} restorableDroppedDatabaseId + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + getWithHttpOperationResponse(resourceGroupName: string, managedInstanceName: string, restorableDroppedDatabaseId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets a dropped database's short term retention policy. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} managedInstanceName The name of the managed instance. + * + * @param {string} restorableDroppedDatabaseId + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ManagedBackupShortTermRetentionPolicy} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {ManagedBackupShortTermRetentionPolicy} [result] - The deserialized result object if an error did not occur. + * See {@link ManagedBackupShortTermRetentionPolicy} for + * more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + get(resourceGroupName: string, managedInstanceName: string, restorableDroppedDatabaseId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(resourceGroupName: string, managedInstanceName: string, restorableDroppedDatabaseId: string, callback: ServiceCallback): void; + get(resourceGroupName: string, managedInstanceName: string, restorableDroppedDatabaseId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Sets a database's long term retention policy. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} managedInstanceName The name of the managed instance. + * + * @param {string} restorableDroppedDatabaseId + * + * @param {object} parameters The long term retention policy info. + * + * @param {number} [parameters.retentionDays] The backup retention period in + * days. This is how many days Point-in-Time Restore will be supported. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + createOrUpdateWithHttpOperationResponse(resourceGroupName: string, managedInstanceName: string, restorableDroppedDatabaseId: string, parameters: models.ManagedBackupShortTermRetentionPolicy, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Sets a database's long term retention policy. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} managedInstanceName The name of the managed instance. + * + * @param {string} restorableDroppedDatabaseId + * + * @param {object} parameters The long term retention policy info. + * + * @param {number} [parameters.retentionDays] The backup retention period in + * days. This is how many days Point-in-Time Restore will be supported. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ManagedBackupShortTermRetentionPolicy} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {ManagedBackupShortTermRetentionPolicy} [result] - The deserialized result object if an error did not occur. + * See {@link ManagedBackupShortTermRetentionPolicy} for + * more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + createOrUpdate(resourceGroupName: string, managedInstanceName: string, restorableDroppedDatabaseId: string, parameters: models.ManagedBackupShortTermRetentionPolicy, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + createOrUpdate(resourceGroupName: string, managedInstanceName: string, restorableDroppedDatabaseId: string, parameters: models.ManagedBackupShortTermRetentionPolicy, callback: ServiceCallback): void; + createOrUpdate(resourceGroupName: string, managedInstanceName: string, restorableDroppedDatabaseId: string, parameters: models.ManagedBackupShortTermRetentionPolicy, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Sets a database's long term retention policy. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} managedInstanceName The name of the managed instance. + * + * @param {string} restorableDroppedDatabaseId + * + * @param {object} parameters The long term retention policy info. + * + * @param {number} [parameters.retentionDays] The backup retention period in + * days. This is how many days Point-in-Time Restore will be supported. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + updateWithHttpOperationResponse(resourceGroupName: string, managedInstanceName: string, restorableDroppedDatabaseId: string, parameters: models.ManagedBackupShortTermRetentionPolicy, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Sets a database's long term retention policy. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} managedInstanceName The name of the managed instance. + * + * @param {string} restorableDroppedDatabaseId + * + * @param {object} parameters The long term retention policy info. + * + * @param {number} [parameters.retentionDays] The backup retention period in + * days. This is how many days Point-in-Time Restore will be supported. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ManagedBackupShortTermRetentionPolicy} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {ManagedBackupShortTermRetentionPolicy} [result] - The deserialized result object if an error did not occur. + * See {@link ManagedBackupShortTermRetentionPolicy} for + * more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + update(resourceGroupName: string, managedInstanceName: string, restorableDroppedDatabaseId: string, parameters: models.ManagedBackupShortTermRetentionPolicy, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + update(resourceGroupName: string, managedInstanceName: string, restorableDroppedDatabaseId: string, parameters: models.ManagedBackupShortTermRetentionPolicy, callback: ServiceCallback): void; + update(resourceGroupName: string, managedInstanceName: string, restorableDroppedDatabaseId: string, parameters: models.ManagedBackupShortTermRetentionPolicy, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Gets a dropped database's short term retention policy list. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} managedInstanceName The name of the managed instance. + * + * @param {string} restorableDroppedDatabaseId + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByRestorableDroppedDatabaseWithHttpOperationResponse(resourceGroupName: string, managedInstanceName: string, restorableDroppedDatabaseId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets a dropped database's short term retention policy list. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} managedInstanceName The name of the managed instance. + * + * @param {string} restorableDroppedDatabaseId + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ManagedBackupShortTermRetentionPolicyListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {ManagedBackupShortTermRetentionPolicyListResult} [result] - The deserialized result object if an error did not occur. + * See {@link + * ManagedBackupShortTermRetentionPolicyListResult} for + * more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listByRestorableDroppedDatabase(resourceGroupName: string, managedInstanceName: string, restorableDroppedDatabaseId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByRestorableDroppedDatabase(resourceGroupName: string, managedInstanceName: string, restorableDroppedDatabaseId: string, callback: ServiceCallback): void; + listByRestorableDroppedDatabase(resourceGroupName: string, managedInstanceName: string, restorableDroppedDatabaseId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Sets a database's long term retention policy. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} managedInstanceName The name of the managed instance. + * + * @param {string} restorableDroppedDatabaseId + * + * @param {object} parameters The long term retention policy info. + * + * @param {number} [parameters.retentionDays] The backup retention period in + * days. This is how many days Point-in-Time Restore will be supported. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + beginCreateOrUpdateWithHttpOperationResponse(resourceGroupName: string, managedInstanceName: string, restorableDroppedDatabaseId: string, parameters: models.ManagedBackupShortTermRetentionPolicy, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Sets a database's long term retention policy. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} managedInstanceName The name of the managed instance. + * + * @param {string} restorableDroppedDatabaseId + * + * @param {object} parameters The long term retention policy info. + * + * @param {number} [parameters.retentionDays] The backup retention period in + * days. This is how many days Point-in-Time Restore will be supported. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ManagedBackupShortTermRetentionPolicy} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {ManagedBackupShortTermRetentionPolicy} [result] - The deserialized result object if an error did not occur. + * See {@link ManagedBackupShortTermRetentionPolicy} for + * more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + beginCreateOrUpdate(resourceGroupName: string, managedInstanceName: string, restorableDroppedDatabaseId: string, parameters: models.ManagedBackupShortTermRetentionPolicy, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + beginCreateOrUpdate(resourceGroupName: string, managedInstanceName: string, restorableDroppedDatabaseId: string, parameters: models.ManagedBackupShortTermRetentionPolicy, callback: ServiceCallback): void; + beginCreateOrUpdate(resourceGroupName: string, managedInstanceName: string, restorableDroppedDatabaseId: string, parameters: models.ManagedBackupShortTermRetentionPolicy, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Sets a database's long term retention policy. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} managedInstanceName The name of the managed instance. + * + * @param {string} restorableDroppedDatabaseId + * + * @param {object} parameters The long term retention policy info. + * + * @param {number} [parameters.retentionDays] The backup retention period in + * days. This is how many days Point-in-Time Restore will be supported. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + beginUpdateWithHttpOperationResponse(resourceGroupName: string, managedInstanceName: string, restorableDroppedDatabaseId: string, parameters: models.ManagedBackupShortTermRetentionPolicy, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Sets a database's long term retention policy. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} managedInstanceName The name of the managed instance. + * + * @param {string} restorableDroppedDatabaseId + * + * @param {object} parameters The long term retention policy info. + * + * @param {number} [parameters.retentionDays] The backup retention period in + * days. This is how many days Point-in-Time Restore will be supported. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ManagedBackupShortTermRetentionPolicy} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {ManagedBackupShortTermRetentionPolicy} [result] - The deserialized result object if an error did not occur. + * See {@link ManagedBackupShortTermRetentionPolicy} for + * more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + beginUpdate(resourceGroupName: string, managedInstanceName: string, restorableDroppedDatabaseId: string, parameters: models.ManagedBackupShortTermRetentionPolicy, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + beginUpdate(resourceGroupName: string, managedInstanceName: string, restorableDroppedDatabaseId: string, parameters: models.ManagedBackupShortTermRetentionPolicy, callback: ServiceCallback): void; + beginUpdate(resourceGroupName: string, managedInstanceName: string, restorableDroppedDatabaseId: string, parameters: models.ManagedBackupShortTermRetentionPolicy, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Gets a dropped database's short term retention policy list. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByRestorableDroppedDatabaseNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets a dropped database's short term retention policy list. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ManagedBackupShortTermRetentionPolicyListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {ManagedBackupShortTermRetentionPolicyListResult} [result] - The deserialized result object if an error did not occur. + * See {@link + * ManagedBackupShortTermRetentionPolicyListResult} for + * more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listByRestorableDroppedDatabaseNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByRestorableDroppedDatabaseNext(nextPageLink: string, callback: ServiceCallback): void; + listByRestorableDroppedDatabaseNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + /** * @class * ServerAutomaticTuningOperations @@ -26967,11 +27484,270 @@ export interface ServerSecurityAlertPolicies { * endpoint (e.g. https://MyAccount.blob.core.windows.net). This blob storage * will hold all Threat Detection audit logs. * - * @param {string} [parameters.storageAccountAccessKey] Specifies the - * identifier key of the Threat Detection audit storage account. + * @param {string} [parameters.storageAccountAccessKey] Specifies the + * identifier key of the Threat Detection audit storage account. + * + * @param {number} [parameters.retentionDays] Specifies the number of days to + * keep in the Threat Detection audit logs. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ServerSecurityAlertPolicy} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {ServerSecurityAlertPolicy} [result] - The deserialized result object if an error did not occur. + * See {@link ServerSecurityAlertPolicy} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + createOrUpdate(resourceGroupName: string, serverName: string, parameters: models.ServerSecurityAlertPolicy, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + createOrUpdate(resourceGroupName: string, serverName: string, parameters: models.ServerSecurityAlertPolicy, callback: ServiceCallback): void; + createOrUpdate(resourceGroupName: string, serverName: string, parameters: models.ServerSecurityAlertPolicy, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Creates or updates a threat detection policy. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {object} parameters The server security alert policy. + * + * @param {string} parameters.state Specifies the state of the policy, whether + * it is enabled or disabled. Possible values include: 'New', 'Enabled', + * 'Disabled' + * + * @param {array} [parameters.disabledAlerts] Specifies an array of alerts that + * are disabled. Allowed values are: Sql_Injection, + * Sql_Injection_Vulnerability, Access_Anomaly, Data_Exfiltration, + * Unsafe_Action + * + * @param {array} [parameters.emailAddresses] Specifies an array of e-mail + * addresses to which the alert is sent. + * + * @param {boolean} [parameters.emailAccountAdmins] Specifies that the alert is + * sent to the account administrators. + * + * @param {string} [parameters.storageEndpoint] Specifies the blob storage + * endpoint (e.g. https://MyAccount.blob.core.windows.net). This blob storage + * will hold all Threat Detection audit logs. + * + * @param {string} [parameters.storageAccountAccessKey] Specifies the + * identifier key of the Threat Detection audit storage account. + * + * @param {number} [parameters.retentionDays] Specifies the number of days to + * keep in the Threat Detection audit logs. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + beginCreateOrUpdateWithHttpOperationResponse(resourceGroupName: string, serverName: string, parameters: models.ServerSecurityAlertPolicy, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Creates or updates a threat detection policy. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} serverName The name of the server. + * + * @param {object} parameters The server security alert policy. + * + * @param {string} parameters.state Specifies the state of the policy, whether + * it is enabled or disabled. Possible values include: 'New', 'Enabled', + * 'Disabled' + * + * @param {array} [parameters.disabledAlerts] Specifies an array of alerts that + * are disabled. Allowed values are: Sql_Injection, + * Sql_Injection_Vulnerability, Access_Anomaly, Data_Exfiltration, + * Unsafe_Action + * + * @param {array} [parameters.emailAddresses] Specifies an array of e-mail + * addresses to which the alert is sent. + * + * @param {boolean} [parameters.emailAccountAdmins] Specifies that the alert is + * sent to the account administrators. + * + * @param {string} [parameters.storageEndpoint] Specifies the blob storage + * endpoint (e.g. https://MyAccount.blob.core.windows.net). This blob storage + * will hold all Threat Detection audit logs. + * + * @param {string} [parameters.storageAccountAccessKey] Specifies the + * identifier key of the Threat Detection audit storage account. + * + * @param {number} [parameters.retentionDays] Specifies the number of days to + * keep in the Threat Detection audit logs. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ServerSecurityAlertPolicy} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {ServerSecurityAlertPolicy} [result] - The deserialized result object if an error did not occur. + * See {@link ServerSecurityAlertPolicy} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + beginCreateOrUpdate(resourceGroupName: string, serverName: string, parameters: models.ServerSecurityAlertPolicy, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + beginCreateOrUpdate(resourceGroupName: string, serverName: string, parameters: models.ServerSecurityAlertPolicy, callback: ServiceCallback): void; + beginCreateOrUpdate(resourceGroupName: string, serverName: string, parameters: models.ServerSecurityAlertPolicy, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * RestorableDroppedManagedDatabases + * __NOTE__: An instance of this class is automatically created for an + * instance of the SqlManagementClient. + */ +export interface RestorableDroppedManagedDatabases { + + + /** + * Gets a list of restorable dropped managed databases. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} managedInstanceName The name of the managed instance. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByInstanceWithHttpOperationResponse(resourceGroupName: string, managedInstanceName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets a list of restorable dropped managed databases. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} managedInstanceName The name of the managed instance. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {RestorableDroppedManagedDatabaseListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {RestorableDroppedManagedDatabaseListResult} [result] - The deserialized result object if an error did not occur. + * See {@link RestorableDroppedManagedDatabaseListResult} + * for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listByInstance(resourceGroupName: string, managedInstanceName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByInstance(resourceGroupName: string, managedInstanceName: string, callback: ServiceCallback): void; + listByInstance(resourceGroupName: string, managedInstanceName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Gets a restorable dropped managed database. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} managedInstanceName The name of the managed instance. + * + * @param {string} restorableDroppedDatabaseId + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + getWithHttpOperationResponse(resourceGroupName: string, managedInstanceName: string, restorableDroppedDatabaseId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets a restorable dropped managed database. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} managedInstanceName The name of the managed instance. * - * @param {number} [parameters.retentionDays] Specifies the number of days to - * keep in the Threat Detection audit logs. + * @param {string} restorableDroppedDatabaseId * * @param {object} [options] Optional Parameters. * @@ -26985,7 +27761,7 @@ export interface ServerSecurityAlertPolicies { * * {Promise} A promise is returned. * - * @resolve {ServerSecurityAlertPolicy} - The deserialized result object. + * @resolve {RestorableDroppedManagedDatabase} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -26993,54 +27769,24 @@ export interface ServerSecurityAlertPolicies { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {ServerSecurityAlertPolicy} [result] - The deserialized result object if an error did not occur. - * See {@link ServerSecurityAlertPolicy} for more + * {RestorableDroppedManagedDatabase} [result] - The deserialized result object if an error did not occur. + * See {@link RestorableDroppedManagedDatabase} for more * information. * * {WebResource} [request] - The HTTP Request object if an error did not occur. * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - createOrUpdate(resourceGroupName: string, serverName: string, parameters: models.ServerSecurityAlertPolicy, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - createOrUpdate(resourceGroupName: string, serverName: string, parameters: models.ServerSecurityAlertPolicy, callback: ServiceCallback): void; - createOrUpdate(resourceGroupName: string, serverName: string, parameters: models.ServerSecurityAlertPolicy, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + get(resourceGroupName: string, managedInstanceName: string, restorableDroppedDatabaseId: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(resourceGroupName: string, managedInstanceName: string, restorableDroppedDatabaseId: string, callback: ServiceCallback): void; + get(resourceGroupName: string, managedInstanceName: string, restorableDroppedDatabaseId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * Creates or updates a threat detection policy. - * - * @param {string} resourceGroupName The name of the resource group that - * contains the resource. You can obtain this value from the Azure Resource - * Manager API or the portal. - * - * @param {string} serverName The name of the server. - * - * @param {object} parameters The server security alert policy. - * - * @param {string} parameters.state Specifies the state of the policy, whether - * it is enabled or disabled. Possible values include: 'New', 'Enabled', - * 'Disabled' - * - * @param {array} [parameters.disabledAlerts] Specifies an array of alerts that - * are disabled. Allowed values are: Sql_Injection, - * Sql_Injection_Vulnerability, Access_Anomaly, Data_Exfiltration, - * Unsafe_Action - * - * @param {array} [parameters.emailAddresses] Specifies an array of e-mail - * addresses to which the alert is sent. + * Gets a list of restorable dropped managed databases. * - * @param {boolean} [parameters.emailAccountAdmins] Specifies that the alert is - * sent to the account administrators. - * - * @param {string} [parameters.storageEndpoint] Specifies the blob storage - * endpoint (e.g. https://MyAccount.blob.core.windows.net). This blob storage - * will hold all Threat Detection audit logs. - * - * @param {string} [parameters.storageAccountAccessKey] Specifies the - * identifier key of the Threat Detection audit storage account. - * - * @param {number} [parameters.retentionDays] Specifies the number of days to - * keep in the Threat Detection audit logs. + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. * * @param {object} [options] Optional Parameters. * @@ -27049,47 +27795,17 @@ export interface ServerSecurityAlertPolicies { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - beginCreateOrUpdateWithHttpOperationResponse(resourceGroupName: string, serverName: string, parameters: models.ServerSecurityAlertPolicy, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + listByInstanceNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Creates or updates a threat detection policy. - * - * @param {string} resourceGroupName The name of the resource group that - * contains the resource. You can obtain this value from the Azure Resource - * Manager API or the portal. - * - * @param {string} serverName The name of the server. - * - * @param {object} parameters The server security alert policy. - * - * @param {string} parameters.state Specifies the state of the policy, whether - * it is enabled or disabled. Possible values include: 'New', 'Enabled', - * 'Disabled' - * - * @param {array} [parameters.disabledAlerts] Specifies an array of alerts that - * are disabled. Allowed values are: Sql_Injection, - * Sql_Injection_Vulnerability, Access_Anomaly, Data_Exfiltration, - * Unsafe_Action - * - * @param {array} [parameters.emailAddresses] Specifies an array of e-mail - * addresses to which the alert is sent. - * - * @param {boolean} [parameters.emailAccountAdmins] Specifies that the alert is - * sent to the account administrators. + * Gets a list of restorable dropped managed databases. * - * @param {string} [parameters.storageEndpoint] Specifies the blob storage - * endpoint (e.g. https://MyAccount.blob.core.windows.net). This blob storage - * will hold all Threat Detection audit logs. - * - * @param {string} [parameters.storageAccountAccessKey] Specifies the - * identifier key of the Threat Detection audit storage account. - * - * @param {number} [parameters.retentionDays] Specifies the number of days to - * keep in the Threat Detection audit logs. + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. * * @param {object} [options] Optional Parameters. * @@ -27103,7 +27819,7 @@ export interface ServerSecurityAlertPolicies { * * {Promise} A promise is returned. * - * @resolve {ServerSecurityAlertPolicy} - The deserialized result object. + * @resolve {RestorableDroppedManagedDatabaseListResult} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -27111,17 +27827,17 @@ export interface ServerSecurityAlertPolicies { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {ServerSecurityAlertPolicy} [result] - The deserialized result object if an error did not occur. - * See {@link ServerSecurityAlertPolicy} for more - * information. + * {RestorableDroppedManagedDatabaseListResult} [result] - The deserialized result object if an error did not occur. + * See {@link RestorableDroppedManagedDatabaseListResult} + * for more information. * * {WebResource} [request] - The HTTP Request object if an error did not occur. * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - beginCreateOrUpdate(resourceGroupName: string, serverName: string, parameters: models.ServerSecurityAlertPolicy, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - beginCreateOrUpdate(resourceGroupName: string, serverName: string, parameters: models.ServerSecurityAlertPolicy, callback: ServiceCallback): void; - beginCreateOrUpdate(resourceGroupName: string, serverName: string, parameters: models.ServerSecurityAlertPolicy, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + listByInstanceNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByInstanceNext(nextPageLink: string, callback: ServiceCallback): void; + listByInstanceNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; } /** @@ -32614,6 +33330,205 @@ export interface ManagedInstanceEncryptionProtectors { listByInstanceNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; } +/** + * @class + * RecoverableManagedDatabases + * __NOTE__: An instance of this class is automatically created for an + * instance of the SqlManagementClient. + */ +export interface RecoverableManagedDatabases { + + + /** + * Gets a list of recoverable managed databases. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} managedInstanceName The name of the managed instance. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByInstanceWithHttpOperationResponse(resourceGroupName: string, managedInstanceName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets a list of recoverable managed databases. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} managedInstanceName The name of the managed instance. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {RecoverableManagedDatabaseListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {RecoverableManagedDatabaseListResult} [result] - The deserialized result object if an error did not occur. + * See {@link RecoverableManagedDatabaseListResult} for + * more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listByInstance(resourceGroupName: string, managedInstanceName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByInstance(resourceGroupName: string, managedInstanceName: string, callback: ServiceCallback): void; + listByInstance(resourceGroupName: string, managedInstanceName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Gets a recoverable managed database. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} managedInstanceName The name of the managed instance. + * + * @param {string} recoverableDatabaseName + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + getWithHttpOperationResponse(resourceGroupName: string, managedInstanceName: string, recoverableDatabaseName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets a recoverable managed database. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} managedInstanceName The name of the managed instance. + * + * @param {string} recoverableDatabaseName + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {RecoverableManagedDatabase} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {RecoverableManagedDatabase} [result] - The deserialized result object if an error did not occur. + * See {@link RecoverableManagedDatabase} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + get(resourceGroupName: string, managedInstanceName: string, recoverableDatabaseName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(resourceGroupName: string, managedInstanceName: string, recoverableDatabaseName: string, callback: ServiceCallback): void; + get(resourceGroupName: string, managedInstanceName: string, recoverableDatabaseName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Gets a list of recoverable managed databases. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByInstanceNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets a list of recoverable managed databases. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {RecoverableManagedDatabaseListResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {RecoverableManagedDatabaseListResult} [result] - The deserialized result object if an error did not occur. + * See {@link RecoverableManagedDatabaseListResult} for + * more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listByInstanceNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByInstanceNext(nextPageLink: string, callback: ServiceCallback): void; + listByInstanceNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + /** * @class * ManagedInstanceVulnerabilityAssessments diff --git a/lib/services/sqlManagement2/lib/operations/index.js b/lib/services/sqlManagement2/lib/operations/index.js index d88f136016..9d10213fea 100644 --- a/lib/services/sqlManagement2/lib/operations/index.js +++ b/lib/services/sqlManagement2/lib/operations/index.js @@ -67,9 +67,11 @@ exports.LongTermRetentionBackups = require('./longTermRetentionBackups'); exports.BackupLongTermRetentionPolicies = require('./backupLongTermRetentionPolicies'); exports.ManagedBackupShortTermRetentionPolicies = require('./managedBackupShortTermRetentionPolicies'); exports.ManagedDatabases = require('./managedDatabases'); +exports.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPolicies = require('./managedRestorableDroppedDatabaseBackupShortTermRetentionPolicies'); exports.ServerAutomaticTuningOperations = require('./serverAutomaticTuningOperations'); exports.ServerDnsAliases = require('./serverDnsAliases'); exports.ServerSecurityAlertPolicies = require('./serverSecurityAlertPolicies'); +exports.RestorableDroppedManagedDatabases = require('./restorableDroppedManagedDatabases'); exports.RestorePoints = require('./restorePoints'); exports.ManagedDatabaseSecurityAlertPolicies = require('./managedDatabaseSecurityAlertPolicies'); exports.ManagedServerSecurityAlertPolicies = require('./managedServerSecurityAlertPolicies'); @@ -86,5 +88,6 @@ exports.TdeCertificates = require('./tdeCertificates'); exports.ManagedInstanceTdeCertificates = require('./managedInstanceTdeCertificates'); exports.ManagedInstanceKeys = require('./managedInstanceKeys'); exports.ManagedInstanceEncryptionProtectors = require('./managedInstanceEncryptionProtectors'); +exports.RecoverableManagedDatabases = require('./recoverableManagedDatabases'); exports.ManagedInstanceVulnerabilityAssessments = require('./managedInstanceVulnerabilityAssessments'); exports.ServerVulnerabilityAssessments = require('./serverVulnerabilityAssessments'); diff --git a/lib/services/sqlManagement2/lib/operations/longTermRetentionBackups.js b/lib/services/sqlManagement2/lib/operations/longTermRetentionBackups.js index 39ad67fada..5a6dc4b181 100644 --- a/lib/services/sqlManagement2/lib/operations/longTermRetentionBackups.js +++ b/lib/services/sqlManagement2/lib/operations/longTermRetentionBackups.js @@ -19,9 +19,9 @@ const WebResource = msRest.WebResource; * * @param {string} locationName The location of the database. * - * @param {string} longTermRetentionServerName + * @param {string} longTermRetentionServerName The name of the server * - * @param {string} longTermRetentionDatabaseName + * @param {string} longTermRetentionDatabaseName The name of the database * * @param {string} backupName The backup name. * @@ -176,9 +176,9 @@ function _get(locationName, longTermRetentionServerName, longTermRetentionDataba * * @param {string} locationName The location of the database * - * @param {string} longTermRetentionServerName + * @param {string} longTermRetentionServerName The name of the server * - * @param {string} longTermRetentionDatabaseName + * @param {string} longTermRetentionDatabaseName The name of the database * * @param {string} backupName The backup name. * @@ -242,9 +242,9 @@ function _deleteMethod(locationName, longTermRetentionServerName, longTermRetent * * @param {string} locationName The location of the database * - * @param {string} longTermRetentionServerName + * @param {string} longTermRetentionServerName The name of the server * - * @param {string} longTermRetentionDatabaseName + * @param {string} longTermRetentionDatabaseName The name of the database * * @param {object} [options] Optional Parameters. * @@ -572,7 +572,7 @@ function _listByLocation(locationName, options, callback) { * * @param {string} locationName The location of the database * - * @param {string} longTermRetentionServerName + * @param {string} longTermRetentionServerName The name of the server * * @param {object} [options] Optional Parameters. * @@ -737,9 +737,9 @@ function _listByServer(locationName, longTermRetentionServerName, options, callb * * @param {string} locationName The location of the database * - * @param {string} longTermRetentionServerName + * @param {string} longTermRetentionServerName The name of the server * - * @param {string} longTermRetentionDatabaseName + * @param {string} longTermRetentionDatabaseName The name of the database * * @param {string} backupName The backup name. * @@ -1277,9 +1277,9 @@ class LongTermRetentionBackups { * * @param {string} locationName The location of the database. * - * @param {string} longTermRetentionServerName + * @param {string} longTermRetentionServerName The name of the server * - * @param {string} longTermRetentionDatabaseName + * @param {string} longTermRetentionDatabaseName The name of the database * * @param {string} backupName The backup name. * @@ -1313,9 +1313,9 @@ class LongTermRetentionBackups { * * @param {string} locationName The location of the database. * - * @param {string} longTermRetentionServerName + * @param {string} longTermRetentionServerName The name of the server * - * @param {string} longTermRetentionDatabaseName + * @param {string} longTermRetentionDatabaseName The name of the database * * @param {string} backupName The backup name. * @@ -1372,9 +1372,9 @@ class LongTermRetentionBackups { * * @param {string} locationName The location of the database * - * @param {string} longTermRetentionServerName + * @param {string} longTermRetentionServerName The name of the server * - * @param {string} longTermRetentionDatabaseName + * @param {string} longTermRetentionDatabaseName The name of the database * * @param {string} backupName The backup name. * @@ -1408,9 +1408,9 @@ class LongTermRetentionBackups { * * @param {string} locationName The location of the database * - * @param {string} longTermRetentionServerName + * @param {string} longTermRetentionServerName The name of the server * - * @param {string} longTermRetentionDatabaseName + * @param {string} longTermRetentionDatabaseName The name of the database * * @param {string} backupName The backup name. * @@ -1465,9 +1465,9 @@ class LongTermRetentionBackups { * * @param {string} locationName The location of the database * - * @param {string} longTermRetentionServerName + * @param {string} longTermRetentionServerName The name of the server * - * @param {string} longTermRetentionDatabaseName + * @param {string} longTermRetentionDatabaseName The name of the database * * @param {object} [options] Optional Parameters. * @@ -1506,9 +1506,9 @@ class LongTermRetentionBackups { * * @param {string} locationName The location of the database * - * @param {string} longTermRetentionServerName + * @param {string} longTermRetentionServerName The name of the server * - * @param {string} longTermRetentionDatabaseName + * @param {string} longTermRetentionDatabaseName The name of the database * * @param {object} [options] Optional Parameters. * @@ -1667,7 +1667,7 @@ class LongTermRetentionBackups { * * @param {string} locationName The location of the database * - * @param {string} longTermRetentionServerName + * @param {string} longTermRetentionServerName The name of the server * * @param {object} [options] Optional Parameters. * @@ -1706,7 +1706,7 @@ class LongTermRetentionBackups { * * @param {string} locationName The location of the database * - * @param {string} longTermRetentionServerName + * @param {string} longTermRetentionServerName The name of the server * * @param {object} [options] Optional Parameters. * @@ -1768,9 +1768,9 @@ class LongTermRetentionBackups { * * @param {string} locationName The location of the database * - * @param {string} longTermRetentionServerName + * @param {string} longTermRetentionServerName The name of the server * - * @param {string} longTermRetentionDatabaseName + * @param {string} longTermRetentionDatabaseName The name of the database * * @param {string} backupName The backup name. * @@ -1804,9 +1804,9 @@ class LongTermRetentionBackups { * * @param {string} locationName The location of the database * - * @param {string} longTermRetentionServerName + * @param {string} longTermRetentionServerName The name of the server * - * @param {string} longTermRetentionDatabaseName + * @param {string} longTermRetentionDatabaseName The name of the database * * @param {string} backupName The backup name. * diff --git a/lib/services/sqlManagement2/lib/operations/managedRestorableDroppedDatabaseBackupShortTermRetentionPolicies.js b/lib/services/sqlManagement2/lib/operations/managedRestorableDroppedDatabaseBackupShortTermRetentionPolicies.js new file mode 100644 index 0000000000..aee7f97667 --- /dev/null +++ b/lib/services/sqlManagement2/lib/operations/managedRestorableDroppedDatabaseBackupShortTermRetentionPolicies.js @@ -0,0 +1,1697 @@ +/* + * 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. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Gets a dropped database's short term retention policy. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} managedInstanceName The name of the managed instance. + * + * @param {string} restorableDroppedDatabaseId + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ManagedBackupShortTermRetentionPolicy} for + * more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _get(resourceGroupName, managedInstanceName, restorableDroppedDatabaseId, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let policyName = 'default'; + let apiVersion = '2017-03-01-preview'; + // Validate + try { + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (managedInstanceName === null || managedInstanceName === undefined || typeof managedInstanceName.valueOf() !== 'string') { + throw new Error('managedInstanceName cannot be null or undefined and it must be of type string.'); + } + if (restorableDroppedDatabaseId === null || restorableDroppedDatabaseId === undefined || typeof restorableDroppedDatabaseId.valueOf() !== 'string') { + throw new Error('restorableDroppedDatabaseId cannot be null or undefined and it must be of type string.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/restorableDroppedDatabases/{restorableDroppedDatabaseId}/backupShortTermRetentionPolicies/{policyName}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{managedInstanceName}', encodeURIComponent(managedInstanceName)); + requestUrl = requestUrl.replace('{restorableDroppedDatabaseId}', encodeURIComponent(restorableDroppedDatabaseId)); + requestUrl = requestUrl.replace('{policyName}', encodeURIComponent(policyName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error; + if (parsedErrorResponse.code) error.code = parsedErrorResponse.code; + if (parsedErrorResponse.message) error.message = parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['CloudError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['ManagedBackupShortTermRetentionPolicy']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + + +/** + * Sets a database's long term retention policy. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} managedInstanceName The name of the managed instance. + * + * @param {string} restorableDroppedDatabaseId + * + * @param {object} parameters The long term retention policy info. + * + * @param {number} [parameters.retentionDays] The backup retention period in + * days. This is how many days Point-in-Time Restore will be supported. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ManagedBackupShortTermRetentionPolicy} for + * more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _createOrUpdate(resourceGroupName, managedInstanceName, restorableDroppedDatabaseId, parameters, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + + if (!callback) { + throw new Error('callback cannot be null.'); + } + + // Send request + this.beginCreateOrUpdate(resourceGroupName, managedInstanceName, restorableDroppedDatabaseId, parameters, options, (err, parsedResult, httpRequest, response) => { + if (err) return callback(err); + + let initialResult = new msRest.HttpOperationResponse(); + initialResult.request = httpRequest; + initialResult.response = response; + initialResult.body = response.body; + client.getLongRunningOperationResult(initialResult, options, (err, pollingResult) => { + if (err) return callback(err); + + // Create Result + let result = null; + + httpRequest = pollingResult.request; + response = pollingResult.response; + let responseBody = pollingResult.body; + if (responseBody === '') responseBody = null; + + // Deserialize Response + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['ManagedBackupShortTermRetentionPolicy']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + + return callback(null, result, httpRequest, response); + }); + }); +} + + +/** + * Sets a database's long term retention policy. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} managedInstanceName The name of the managed instance. + * + * @param {string} restorableDroppedDatabaseId + * + * @param {object} parameters The long term retention policy info. + * + * @param {number} [parameters.retentionDays] The backup retention period in + * days. This is how many days Point-in-Time Restore will be supported. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ManagedBackupShortTermRetentionPolicy} for + * more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _update(resourceGroupName, managedInstanceName, restorableDroppedDatabaseId, parameters, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + + if (!callback) { + throw new Error('callback cannot be null.'); + } + + // Send request + this.beginUpdate(resourceGroupName, managedInstanceName, restorableDroppedDatabaseId, parameters, options, (err, parsedResult, httpRequest, response) => { + if (err) return callback(err); + + let initialResult = new msRest.HttpOperationResponse(); + initialResult.request = httpRequest; + initialResult.response = response; + initialResult.body = response.body; + client.getLongRunningOperationResult(initialResult, options, (err, pollingResult) => { + if (err) return callback(err); + + // Create Result + let result = null; + + httpRequest = pollingResult.request; + response = pollingResult.response; + let responseBody = pollingResult.body; + if (responseBody === '') responseBody = null; + + // Deserialize Response + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['ManagedBackupShortTermRetentionPolicy']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + + return callback(null, result, httpRequest, response); + }); + }); +} + +/** + * Gets a dropped database's short term retention policy list. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} managedInstanceName The name of the managed instance. + * + * @param {string} restorableDroppedDatabaseId + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link + * ManagedBackupShortTermRetentionPolicyListResult} for + * more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listByRestorableDroppedDatabase(resourceGroupName, managedInstanceName, restorableDroppedDatabaseId, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let apiVersion = '2017-03-01-preview'; + // Validate + try { + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (managedInstanceName === null || managedInstanceName === undefined || typeof managedInstanceName.valueOf() !== 'string') { + throw new Error('managedInstanceName cannot be null or undefined and it must be of type string.'); + } + if (restorableDroppedDatabaseId === null || restorableDroppedDatabaseId === undefined || typeof restorableDroppedDatabaseId.valueOf() !== 'string') { + throw new Error('restorableDroppedDatabaseId cannot be null or undefined and it must be of type string.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/restorableDroppedDatabases/{restorableDroppedDatabaseId}/backupShortTermRetentionPolicies'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{managedInstanceName}', encodeURIComponent(managedInstanceName)); + requestUrl = requestUrl.replace('{restorableDroppedDatabaseId}', encodeURIComponent(restorableDroppedDatabaseId)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error; + if (parsedErrorResponse.code) error.code = parsedErrorResponse.code; + if (parsedErrorResponse.message) error.message = parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['CloudError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['ManagedBackupShortTermRetentionPolicyListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Sets a database's long term retention policy. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} managedInstanceName The name of the managed instance. + * + * @param {string} restorableDroppedDatabaseId + * + * @param {object} parameters The long term retention policy info. + * + * @param {number} [parameters.retentionDays] The backup retention period in + * days. This is how many days Point-in-Time Restore will be supported. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ManagedBackupShortTermRetentionPolicy} for + * more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _beginCreateOrUpdate(resourceGroupName, managedInstanceName, restorableDroppedDatabaseId, parameters, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let policyName = 'default'; + let apiVersion = '2017-03-01-preview'; + // Validate + try { + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (managedInstanceName === null || managedInstanceName === undefined || typeof managedInstanceName.valueOf() !== 'string') { + throw new Error('managedInstanceName cannot be null or undefined and it must be of type string.'); + } + if (restorableDroppedDatabaseId === null || restorableDroppedDatabaseId === undefined || typeof restorableDroppedDatabaseId.valueOf() !== 'string') { + throw new Error('restorableDroppedDatabaseId cannot be null or undefined and it must be of type string.'); + } + if (parameters === null || parameters === undefined) { + throw new Error('parameters cannot be null or undefined.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/restorableDroppedDatabases/{restorableDroppedDatabaseId}/backupShortTermRetentionPolicies/{policyName}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{managedInstanceName}', encodeURIComponent(managedInstanceName)); + requestUrl = requestUrl.replace('{restorableDroppedDatabaseId}', encodeURIComponent(restorableDroppedDatabaseId)); + requestUrl = requestUrl.replace('{policyName}', encodeURIComponent(policyName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'PUT'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + // Serialize Request + let requestContent = null; + let requestModel = null; + try { + if (parameters !== null && parameters !== undefined) { + let requestModelMapper = new client.models['ManagedBackupShortTermRetentionPolicy']().mapper(); + requestModel = client.serialize(requestModelMapper, parameters, 'parameters'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(parameters, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200 && statusCode !== 202) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error; + if (parsedErrorResponse.code) error.code = parsedErrorResponse.code; + if (parsedErrorResponse.message) error.message = parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['CloudError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['ManagedBackupShortTermRetentionPolicy']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Sets a database's long term retention policy. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} managedInstanceName The name of the managed instance. + * + * @param {string} restorableDroppedDatabaseId + * + * @param {object} parameters The long term retention policy info. + * + * @param {number} [parameters.retentionDays] The backup retention period in + * days. This is how many days Point-in-Time Restore will be supported. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ManagedBackupShortTermRetentionPolicy} for + * more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _beginUpdate(resourceGroupName, managedInstanceName, restorableDroppedDatabaseId, parameters, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let policyName = 'default'; + let apiVersion = '2017-03-01-preview'; + // Validate + try { + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (managedInstanceName === null || managedInstanceName === undefined || typeof managedInstanceName.valueOf() !== 'string') { + throw new Error('managedInstanceName cannot be null or undefined and it must be of type string.'); + } + if (restorableDroppedDatabaseId === null || restorableDroppedDatabaseId === undefined || typeof restorableDroppedDatabaseId.valueOf() !== 'string') { + throw new Error('restorableDroppedDatabaseId cannot be null or undefined and it must be of type string.'); + } + if (parameters === null || parameters === undefined) { + throw new Error('parameters cannot be null or undefined.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/restorableDroppedDatabases/{restorableDroppedDatabaseId}/backupShortTermRetentionPolicies/{policyName}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{managedInstanceName}', encodeURIComponent(managedInstanceName)); + requestUrl = requestUrl.replace('{restorableDroppedDatabaseId}', encodeURIComponent(restorableDroppedDatabaseId)); + requestUrl = requestUrl.replace('{policyName}', encodeURIComponent(policyName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'PATCH'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + // Serialize Request + let requestContent = null; + let requestModel = null; + try { + if (parameters !== null && parameters !== undefined) { + let requestModelMapper = new client.models['ManagedBackupShortTermRetentionPolicy']().mapper(); + requestModel = client.serialize(requestModelMapper, parameters, 'parameters'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(parameters, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200 && statusCode !== 202) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error; + if (parsedErrorResponse.code) error.code = parsedErrorResponse.code; + if (parsedErrorResponse.message) error.message = parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['CloudError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['ManagedBackupShortTermRetentionPolicy']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Gets a dropped database's short term retention policy list. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link + * ManagedBackupShortTermRetentionPolicyListResult} for + * more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listByRestorableDroppedDatabaseNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error; + if (parsedErrorResponse.code) error.code = parsedErrorResponse.code; + if (parsedErrorResponse.message) error.message = parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['CloudError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['ManagedBackupShortTermRetentionPolicyListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a ManagedRestorableDroppedDatabaseBackupShortTermRetentionPolicies. */ +class ManagedRestorableDroppedDatabaseBackupShortTermRetentionPolicies { + /** + * Create a ManagedRestorableDroppedDatabaseBackupShortTermRetentionPolicies. + * @param {SqlManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._get = _get; + this._createOrUpdate = _createOrUpdate; + this._update = _update; + this._listByRestorableDroppedDatabase = _listByRestorableDroppedDatabase; + this._beginCreateOrUpdate = _beginCreateOrUpdate; + this._beginUpdate = _beginUpdate; + this._listByRestorableDroppedDatabaseNext = _listByRestorableDroppedDatabaseNext; + } + + /** + * Gets a dropped database's short term retention policy. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} managedInstanceName The name of the managed instance. + * + * @param {string} restorableDroppedDatabaseId + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + getWithHttpOperationResponse(resourceGroupName, managedInstanceName, restorableDroppedDatabaseId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(resourceGroupName, managedInstanceName, restorableDroppedDatabaseId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Gets a dropped database's short term retention policy. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} managedInstanceName The name of the managed instance. + * + * @param {string} restorableDroppedDatabaseId + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {ManagedBackupShortTermRetentionPolicy} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ManagedBackupShortTermRetentionPolicy} for + * more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + get(resourceGroupName, managedInstanceName, restorableDroppedDatabaseId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._get(resourceGroupName, managedInstanceName, restorableDroppedDatabaseId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(resourceGroupName, managedInstanceName, restorableDroppedDatabaseId, options, optionalCallback); + } + } + + /** + * Sets a database's long term retention policy. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} managedInstanceName The name of the managed instance. + * + * @param {string} restorableDroppedDatabaseId + * + * @param {object} parameters The long term retention policy info. + * + * @param {number} [parameters.retentionDays] The backup retention period in + * days. This is how many days Point-in-Time Restore will be supported. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + createOrUpdateWithHttpOperationResponse(resourceGroupName, managedInstanceName, restorableDroppedDatabaseId, parameters, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._createOrUpdate(resourceGroupName, managedInstanceName, restorableDroppedDatabaseId, parameters, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Sets a database's long term retention policy. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} managedInstanceName The name of the managed instance. + * + * @param {string} restorableDroppedDatabaseId + * + * @param {object} parameters The long term retention policy info. + * + * @param {number} [parameters.retentionDays] The backup retention period in + * days. This is how many days Point-in-Time Restore will be supported. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {ManagedBackupShortTermRetentionPolicy} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ManagedBackupShortTermRetentionPolicy} for + * more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + createOrUpdate(resourceGroupName, managedInstanceName, restorableDroppedDatabaseId, parameters, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._createOrUpdate(resourceGroupName, managedInstanceName, restorableDroppedDatabaseId, parameters, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._createOrUpdate(resourceGroupName, managedInstanceName, restorableDroppedDatabaseId, parameters, options, optionalCallback); + } + } + + /** + * Sets a database's long term retention policy. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} managedInstanceName The name of the managed instance. + * + * @param {string} restorableDroppedDatabaseId + * + * @param {object} parameters The long term retention policy info. + * + * @param {number} [parameters.retentionDays] The backup retention period in + * days. This is how many days Point-in-Time Restore will be supported. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + updateWithHttpOperationResponse(resourceGroupName, managedInstanceName, restorableDroppedDatabaseId, parameters, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._update(resourceGroupName, managedInstanceName, restorableDroppedDatabaseId, parameters, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Sets a database's long term retention policy. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} managedInstanceName The name of the managed instance. + * + * @param {string} restorableDroppedDatabaseId + * + * @param {object} parameters The long term retention policy info. + * + * @param {number} [parameters.retentionDays] The backup retention period in + * days. This is how many days Point-in-Time Restore will be supported. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {ManagedBackupShortTermRetentionPolicy} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ManagedBackupShortTermRetentionPolicy} for + * more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + update(resourceGroupName, managedInstanceName, restorableDroppedDatabaseId, parameters, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._update(resourceGroupName, managedInstanceName, restorableDroppedDatabaseId, parameters, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._update(resourceGroupName, managedInstanceName, restorableDroppedDatabaseId, parameters, options, optionalCallback); + } + } + + /** + * Gets a dropped database's short term retention policy list. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} managedInstanceName The name of the managed instance. + * + * @param {string} restorableDroppedDatabaseId + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByRestorableDroppedDatabaseWithHttpOperationResponse(resourceGroupName, managedInstanceName, restorableDroppedDatabaseId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByRestorableDroppedDatabase(resourceGroupName, managedInstanceName, restorableDroppedDatabaseId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Gets a dropped database's short term retention policy list. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} managedInstanceName The name of the managed instance. + * + * @param {string} restorableDroppedDatabaseId + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {ManagedBackupShortTermRetentionPolicyListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link + * ManagedBackupShortTermRetentionPolicyListResult} for + * more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listByRestorableDroppedDatabase(resourceGroupName, managedInstanceName, restorableDroppedDatabaseId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByRestorableDroppedDatabase(resourceGroupName, managedInstanceName, restorableDroppedDatabaseId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByRestorableDroppedDatabase(resourceGroupName, managedInstanceName, restorableDroppedDatabaseId, options, optionalCallback); + } + } + + /** + * Sets a database's long term retention policy. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} managedInstanceName The name of the managed instance. + * + * @param {string} restorableDroppedDatabaseId + * + * @param {object} parameters The long term retention policy info. + * + * @param {number} [parameters.retentionDays] The backup retention period in + * days. This is how many days Point-in-Time Restore will be supported. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + beginCreateOrUpdateWithHttpOperationResponse(resourceGroupName, managedInstanceName, restorableDroppedDatabaseId, parameters, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._beginCreateOrUpdate(resourceGroupName, managedInstanceName, restorableDroppedDatabaseId, parameters, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Sets a database's long term retention policy. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} managedInstanceName The name of the managed instance. + * + * @param {string} restorableDroppedDatabaseId + * + * @param {object} parameters The long term retention policy info. + * + * @param {number} [parameters.retentionDays] The backup retention period in + * days. This is how many days Point-in-Time Restore will be supported. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {ManagedBackupShortTermRetentionPolicy} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ManagedBackupShortTermRetentionPolicy} for + * more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + beginCreateOrUpdate(resourceGroupName, managedInstanceName, restorableDroppedDatabaseId, parameters, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._beginCreateOrUpdate(resourceGroupName, managedInstanceName, restorableDroppedDatabaseId, parameters, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._beginCreateOrUpdate(resourceGroupName, managedInstanceName, restorableDroppedDatabaseId, parameters, options, optionalCallback); + } + } + + /** + * Sets a database's long term retention policy. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} managedInstanceName The name of the managed instance. + * + * @param {string} restorableDroppedDatabaseId + * + * @param {object} parameters The long term retention policy info. + * + * @param {number} [parameters.retentionDays] The backup retention period in + * days. This is how many days Point-in-Time Restore will be supported. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + beginUpdateWithHttpOperationResponse(resourceGroupName, managedInstanceName, restorableDroppedDatabaseId, parameters, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._beginUpdate(resourceGroupName, managedInstanceName, restorableDroppedDatabaseId, parameters, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Sets a database's long term retention policy. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} managedInstanceName The name of the managed instance. + * + * @param {string} restorableDroppedDatabaseId + * + * @param {object} parameters The long term retention policy info. + * + * @param {number} [parameters.retentionDays] The backup retention period in + * days. This is how many days Point-in-Time Restore will be supported. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {ManagedBackupShortTermRetentionPolicy} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ManagedBackupShortTermRetentionPolicy} for + * more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + beginUpdate(resourceGroupName, managedInstanceName, restorableDroppedDatabaseId, parameters, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._beginUpdate(resourceGroupName, managedInstanceName, restorableDroppedDatabaseId, parameters, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._beginUpdate(resourceGroupName, managedInstanceName, restorableDroppedDatabaseId, parameters, options, optionalCallback); + } + } + + /** + * Gets a dropped database's short term retention policy list. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByRestorableDroppedDatabaseNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByRestorableDroppedDatabaseNext(nextPageLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Gets a dropped database's short term retention policy list. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {ManagedBackupShortTermRetentionPolicyListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link + * ManagedBackupShortTermRetentionPolicyListResult} for + * more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listByRestorableDroppedDatabaseNext(nextPageLink, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByRestorableDroppedDatabaseNext(nextPageLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByRestorableDroppedDatabaseNext(nextPageLink, options, optionalCallback); + } + } + +} + +module.exports = ManagedRestorableDroppedDatabaseBackupShortTermRetentionPolicies; diff --git a/lib/services/sqlManagement2/lib/operations/recoverableManagedDatabases.js b/lib/services/sqlManagement2/lib/operations/recoverableManagedDatabases.js new file mode 100644 index 0000000000..221d69c550 --- /dev/null +++ b/lib/services/sqlManagement2/lib/operations/recoverableManagedDatabases.js @@ -0,0 +1,729 @@ +/* + * 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. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Gets a list of recoverable managed databases. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} managedInstanceName The name of the managed instance. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link RecoverableManagedDatabaseListResult} for + * more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listByInstance(resourceGroupName, managedInstanceName, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let apiVersion = '2017-10-01-preview'; + // Validate + try { + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (managedInstanceName === null || managedInstanceName === undefined || typeof managedInstanceName.valueOf() !== 'string') { + throw new Error('managedInstanceName cannot be null or undefined and it must be of type string.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/recoverableDatabases'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{managedInstanceName}', encodeURIComponent(managedInstanceName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error; + if (parsedErrorResponse.code) error.code = parsedErrorResponse.code; + if (parsedErrorResponse.message) error.message = parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['CloudError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['RecoverableManagedDatabaseListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Gets a recoverable managed database. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} managedInstanceName The name of the managed instance. + * + * @param {string} recoverableDatabaseName + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link RecoverableManagedDatabase} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _get(resourceGroupName, managedInstanceName, recoverableDatabaseName, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let apiVersion = '2017-10-01-preview'; + // Validate + try { + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (managedInstanceName === null || managedInstanceName === undefined || typeof managedInstanceName.valueOf() !== 'string') { + throw new Error('managedInstanceName cannot be null or undefined and it must be of type string.'); + } + if (recoverableDatabaseName === null || recoverableDatabaseName === undefined || typeof recoverableDatabaseName.valueOf() !== 'string') { + throw new Error('recoverableDatabaseName cannot be null or undefined and it must be of type string.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/recoverableDatabases/{recoverableDatabaseName}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{managedInstanceName}', encodeURIComponent(managedInstanceName)); + requestUrl = requestUrl.replace('{recoverableDatabaseName}', encodeURIComponent(recoverableDatabaseName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error; + if (parsedErrorResponse.code) error.code = parsedErrorResponse.code; + if (parsedErrorResponse.message) error.message = parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['CloudError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['RecoverableManagedDatabase']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Gets a list of recoverable managed databases. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link RecoverableManagedDatabaseListResult} for + * more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listByInstanceNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error; + if (parsedErrorResponse.code) error.code = parsedErrorResponse.code; + if (parsedErrorResponse.message) error.message = parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['CloudError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['RecoverableManagedDatabaseListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a RecoverableManagedDatabases. */ +class RecoverableManagedDatabases { + /** + * Create a RecoverableManagedDatabases. + * @param {SqlManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._listByInstance = _listByInstance; + this._get = _get; + this._listByInstanceNext = _listByInstanceNext; + } + + /** + * Gets a list of recoverable managed databases. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} managedInstanceName The name of the managed instance. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByInstanceWithHttpOperationResponse(resourceGroupName, managedInstanceName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByInstance(resourceGroupName, managedInstanceName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Gets a list of recoverable managed databases. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} managedInstanceName The name of the managed instance. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {RecoverableManagedDatabaseListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link RecoverableManagedDatabaseListResult} for + * more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listByInstance(resourceGroupName, managedInstanceName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByInstance(resourceGroupName, managedInstanceName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByInstance(resourceGroupName, managedInstanceName, options, optionalCallback); + } + } + + /** + * Gets a recoverable managed database. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} managedInstanceName The name of the managed instance. + * + * @param {string} recoverableDatabaseName + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + getWithHttpOperationResponse(resourceGroupName, managedInstanceName, recoverableDatabaseName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(resourceGroupName, managedInstanceName, recoverableDatabaseName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Gets a recoverable managed database. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} managedInstanceName The name of the managed instance. + * + * @param {string} recoverableDatabaseName + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {RecoverableManagedDatabase} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link RecoverableManagedDatabase} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + get(resourceGroupName, managedInstanceName, recoverableDatabaseName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._get(resourceGroupName, managedInstanceName, recoverableDatabaseName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(resourceGroupName, managedInstanceName, recoverableDatabaseName, options, optionalCallback); + } + } + + /** + * Gets a list of recoverable managed databases. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByInstanceNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByInstanceNext(nextPageLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Gets a list of recoverable managed databases. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {RecoverableManagedDatabaseListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link RecoverableManagedDatabaseListResult} for + * more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listByInstanceNext(nextPageLink, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByInstanceNext(nextPageLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByInstanceNext(nextPageLink, options, optionalCallback); + } + } + +} + +module.exports = RecoverableManagedDatabases; diff --git a/lib/services/sqlManagement2/lib/operations/restorableDroppedManagedDatabases.js b/lib/services/sqlManagement2/lib/operations/restorableDroppedManagedDatabases.js new file mode 100644 index 0000000000..3a2c45a520 --- /dev/null +++ b/lib/services/sqlManagement2/lib/operations/restorableDroppedManagedDatabases.js @@ -0,0 +1,729 @@ +/* + * 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. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Gets a list of restorable dropped managed databases. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} managedInstanceName The name of the managed instance. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link RestorableDroppedManagedDatabaseListResult} + * for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listByInstance(resourceGroupName, managedInstanceName, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let apiVersion = '2017-03-01-preview'; + // Validate + try { + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (managedInstanceName === null || managedInstanceName === undefined || typeof managedInstanceName.valueOf() !== 'string') { + throw new Error('managedInstanceName cannot be null or undefined and it must be of type string.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/restorableDroppedDatabases'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{managedInstanceName}', encodeURIComponent(managedInstanceName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error; + if (parsedErrorResponse.code) error.code = parsedErrorResponse.code; + if (parsedErrorResponse.message) error.message = parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['CloudError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['RestorableDroppedManagedDatabaseListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Gets a restorable dropped managed database. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} managedInstanceName The name of the managed instance. + * + * @param {string} restorableDroppedDatabaseId + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link RestorableDroppedManagedDatabase} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _get(resourceGroupName, managedInstanceName, restorableDroppedDatabaseId, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let apiVersion = '2017-03-01-preview'; + // Validate + try { + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (managedInstanceName === null || managedInstanceName === undefined || typeof managedInstanceName.valueOf() !== 'string') { + throw new Error('managedInstanceName cannot be null or undefined and it must be of type string.'); + } + if (restorableDroppedDatabaseId === null || restorableDroppedDatabaseId === undefined || typeof restorableDroppedDatabaseId.valueOf() !== 'string') { + throw new Error('restorableDroppedDatabaseId cannot be null or undefined and it must be of type string.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/restorableDroppedDatabases/{restorableDroppedDatabaseId}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{managedInstanceName}', encodeURIComponent(managedInstanceName)); + requestUrl = requestUrl.replace('{restorableDroppedDatabaseId}', encodeURIComponent(restorableDroppedDatabaseId)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error; + if (parsedErrorResponse.code) error.code = parsedErrorResponse.code; + if (parsedErrorResponse.message) error.message = parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['CloudError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['RestorableDroppedManagedDatabase']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Gets a list of restorable dropped managed databases. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link RestorableDroppedManagedDatabaseListResult} + * for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listByInstanceNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error; + if (parsedErrorResponse.code) error.code = parsedErrorResponse.code; + if (parsedErrorResponse.message) error.message = parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['CloudError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['RestorableDroppedManagedDatabaseListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a RestorableDroppedManagedDatabases. */ +class RestorableDroppedManagedDatabases { + /** + * Create a RestorableDroppedManagedDatabases. + * @param {SqlManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._listByInstance = _listByInstance; + this._get = _get; + this._listByInstanceNext = _listByInstanceNext; + } + + /** + * Gets a list of restorable dropped managed databases. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} managedInstanceName The name of the managed instance. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByInstanceWithHttpOperationResponse(resourceGroupName, managedInstanceName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByInstance(resourceGroupName, managedInstanceName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Gets a list of restorable dropped managed databases. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} managedInstanceName The name of the managed instance. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {RestorableDroppedManagedDatabaseListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link RestorableDroppedManagedDatabaseListResult} + * for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listByInstance(resourceGroupName, managedInstanceName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByInstance(resourceGroupName, managedInstanceName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByInstance(resourceGroupName, managedInstanceName, options, optionalCallback); + } + } + + /** + * Gets a restorable dropped managed database. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} managedInstanceName The name of the managed instance. + * + * @param {string} restorableDroppedDatabaseId + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + getWithHttpOperationResponse(resourceGroupName, managedInstanceName, restorableDroppedDatabaseId, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(resourceGroupName, managedInstanceName, restorableDroppedDatabaseId, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Gets a restorable dropped managed database. + * + * @param {string} resourceGroupName The name of the resource group that + * contains the resource. You can obtain this value from the Azure Resource + * Manager API or the portal. + * + * @param {string} managedInstanceName The name of the managed instance. + * + * @param {string} restorableDroppedDatabaseId + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {RestorableDroppedManagedDatabase} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link RestorableDroppedManagedDatabase} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + get(resourceGroupName, managedInstanceName, restorableDroppedDatabaseId, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._get(resourceGroupName, managedInstanceName, restorableDroppedDatabaseId, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(resourceGroupName, managedInstanceName, restorableDroppedDatabaseId, options, optionalCallback); + } + } + + /** + * Gets a list of restorable dropped managed databases. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByInstanceNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByInstanceNext(nextPageLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Gets a list of restorable dropped managed databases. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {RestorableDroppedManagedDatabaseListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link RestorableDroppedManagedDatabaseListResult} + * for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listByInstanceNext(nextPageLink, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByInstanceNext(nextPageLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByInstanceNext(nextPageLink, options, optionalCallback); + } + } + +} + +module.exports = RestorableDroppedManagedDatabases; diff --git a/lib/services/sqlManagement2/lib/sqlManagementClient.d.ts b/lib/services/sqlManagement2/lib/sqlManagementClient.d.ts index 219a079ca7..07fd537e24 100644 --- a/lib/services/sqlManagement2/lib/sqlManagementClient.d.ts +++ b/lib/services/sqlManagement2/lib/sqlManagementClient.d.ts @@ -107,9 +107,11 @@ export default class SqlManagementClient extends AzureServiceClient { backupLongTermRetentionPolicies: operations.BackupLongTermRetentionPolicies; managedBackupShortTermRetentionPolicies: operations.ManagedBackupShortTermRetentionPolicies; managedDatabases: operations.ManagedDatabases; + managedRestorableDroppedDatabaseBackupShortTermRetentionPolicies: operations.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPolicies; serverAutomaticTuningOperations: operations.ServerAutomaticTuningOperations; serverDnsAliases: operations.ServerDnsAliases; serverSecurityAlertPolicies: operations.ServerSecurityAlertPolicies; + restorableDroppedManagedDatabases: operations.RestorableDroppedManagedDatabases; restorePoints: operations.RestorePoints; managedDatabaseSecurityAlertPolicies: operations.ManagedDatabaseSecurityAlertPolicies; managedServerSecurityAlertPolicies: operations.ManagedServerSecurityAlertPolicies; @@ -126,6 +128,7 @@ export default class SqlManagementClient extends AzureServiceClient { managedInstanceTdeCertificates: operations.ManagedInstanceTdeCertificates; managedInstanceKeys: operations.ManagedInstanceKeys; managedInstanceEncryptionProtectors: operations.ManagedInstanceEncryptionProtectors; + recoverableManagedDatabases: operations.RecoverableManagedDatabases; managedInstanceVulnerabilityAssessments: operations.ManagedInstanceVulnerabilityAssessments; serverVulnerabilityAssessments: operations.ServerVulnerabilityAssessments; } diff --git a/lib/services/sqlManagement2/lib/sqlManagementClient.js b/lib/services/sqlManagement2/lib/sqlManagementClient.js index e985815b2a..3e47ee0c05 100644 --- a/lib/services/sqlManagement2/lib/sqlManagementClient.js +++ b/lib/services/sqlManagement2/lib/sqlManagementClient.js @@ -124,9 +124,11 @@ class SqlManagementClient extends ServiceClient { this.backupLongTermRetentionPolicies = new operations.BackupLongTermRetentionPolicies(this); this.managedBackupShortTermRetentionPolicies = new operations.ManagedBackupShortTermRetentionPolicies(this); this.managedDatabases = new operations.ManagedDatabases(this); + this.managedRestorableDroppedDatabaseBackupShortTermRetentionPolicies = new operations.ManagedRestorableDroppedDatabaseBackupShortTermRetentionPolicies(this); this.serverAutomaticTuningOperations = new operations.ServerAutomaticTuningOperations(this); this.serverDnsAliases = new operations.ServerDnsAliases(this); this.serverSecurityAlertPolicies = new operations.ServerSecurityAlertPolicies(this); + this.restorableDroppedManagedDatabases = new operations.RestorableDroppedManagedDatabases(this); this.restorePoints = new operations.RestorePoints(this); this.managedDatabaseSecurityAlertPolicies = new operations.ManagedDatabaseSecurityAlertPolicies(this); this.managedServerSecurityAlertPolicies = new operations.ManagedServerSecurityAlertPolicies(this); @@ -143,6 +145,7 @@ class SqlManagementClient extends ServiceClient { this.managedInstanceTdeCertificates = new operations.ManagedInstanceTdeCertificates(this); this.managedInstanceKeys = new operations.ManagedInstanceKeys(this); this.managedInstanceEncryptionProtectors = new operations.ManagedInstanceEncryptionProtectors(this); + this.recoverableManagedDatabases = new operations.RecoverableManagedDatabases(this); this.managedInstanceVulnerabilityAssessments = new operations.ManagedInstanceVulnerabilityAssessments(this); this.serverVulnerabilityAssessments = new operations.ServerVulnerabilityAssessments(this); this.models = models;