diff --git a/lib/services/recoveryServicesBackupManagement/README.md b/lib/services/recoveryServicesBackupManagement/README.md index e25fab5941..58428e7c18 100644 --- a/lib/services/recoveryServicesBackupManagement/README.md +++ b/lib/services/recoveryServicesBackupManagement/README.md @@ -18,7 +18,7 @@ npm install azure-arm-recoveryservicesbackup ## How to use -### Authentication, client creation and list backupJobs as an example. +### Authentication, client creation and get protectionIntent as an example. ```javascript const msRestAzure = require("ms-rest-azure"); @@ -28,9 +28,9 @@ msRestAzure.interactiveLogin().then((creds) => { const client = new RecoveryServicesBackupClient(creds, subscriptionId); const vaultName = "testvaultName"; const resourceGroupName = "testresourceGroupName"; - const filter = "testfilter"; - const skipToken = "testskipToken"; - return client.backupJobs.list(vaultName, resourceGroupName, filter, skipToken).then((result) => { + const fabricName = "testfabricName"; + const intentObjectName = "testintentObjectName"; + return client.protectionIntent.get(vaultName, resourceGroupName, fabricName, intentObjectName).then((result) => { console.log("The result is:"); console.log(result); }); diff --git a/lib/services/recoveryServicesBackupManagement/lib/models/azureFileShareProtectionPolicy.js b/lib/services/recoveryServicesBackupManagement/lib/models/azureFileShareProtectionPolicy.js index 9a1b0481ad..f25137e1b6 100644 --- a/lib/services/recoveryServicesBackupManagement/lib/models/azureFileShareProtectionPolicy.js +++ b/lib/services/recoveryServicesBackupManagement/lib/models/azureFileShareProtectionPolicy.js @@ -20,7 +20,11 @@ const models = require('./index'); class AzureFileShareProtectionPolicy extends models['ProtectionPolicy'] { /** * Create a AzureFileShareProtectionPolicy. - * @member {string} [workLoadType] Type of workload for the backup management + * @member {string} [workLoadType] Type of workload for the backup + * management. Possible values include: 'Invalid', 'VM', 'FileFolder', + * 'AzureSqlDb', 'SQLDB', 'Exchange', 'Sharepoint', 'VMwareVM', + * 'SystemState', 'Client', 'GenericDataSource', 'SQLDataBase', + * 'AzureFileShare', 'SAPHanaDatabase' * @member {object} [schedulePolicy] Backup schedule specified as part of * backup policy. * @member {string} [schedulePolicy.schedulePolicyType] Polymorphic diff --git a/lib/services/recoveryServicesBackupManagement/lib/models/azureIaaSVMJobExtendedInfo.js b/lib/services/recoveryServicesBackupManagement/lib/models/azureIaaSVMJobExtendedInfo.js index bf6b476e92..63d42d4c8a 100644 --- a/lib/services/recoveryServicesBackupManagement/lib/models/azureIaaSVMJobExtendedInfo.js +++ b/lib/services/recoveryServicesBackupManagement/lib/models/azureIaaSVMJobExtendedInfo.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * Azure IaaS VM workload-specific additional information for job. * diff --git a/lib/services/recoveryServicesBackupManagement/lib/models/azureStorageJobExtendedInfo.js b/lib/services/recoveryServicesBackupManagement/lib/models/azureStorageJobExtendedInfo.js index 0e2eaf4e52..cdfbbed485 100644 --- a/lib/services/recoveryServicesBackupManagement/lib/models/azureStorageJobExtendedInfo.js +++ b/lib/services/recoveryServicesBackupManagement/lib/models/azureStorageJobExtendedInfo.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * Azure Storage workload-specific additional information for job. * diff --git a/lib/services/recoveryServicesBackupManagement/lib/models/azureVmWorkloadProtectableItem.js b/lib/services/recoveryServicesBackupManagement/lib/models/azureVmWorkloadProtectableItem.js index 1c37449354..ff3486b7f0 100644 --- a/lib/services/recoveryServicesBackupManagement/lib/models/azureVmWorkloadProtectableItem.js +++ b/lib/services/recoveryServicesBackupManagement/lib/models/azureVmWorkloadProtectableItem.js @@ -28,6 +28,8 @@ class AzureVmWorkloadProtectableItem extends models['WorkloadProtectableItem'] { * @member {string} [serverName] Host/Cluster Name for instance or AG * @member {boolean} [isAutoProtectable] Indicates if protectable item is * auto-protectable + * @member {boolean} [isAutoProtected] Indicates if protectable item is + * auto-protected * @member {number} [subinquireditemcount] For instance or AG, indicates * number of DB's present * @member {number} [subprotectableitemcount] For instance or AG, indicates @@ -128,6 +130,13 @@ class AzureVmWorkloadProtectableItem extends models['WorkloadProtectableItem'] { name: 'Boolean' } }, + isAutoProtected: { + required: false, + serializedName: 'isAutoProtected', + type: { + name: 'Boolean' + } + }, subinquireditemcount: { required: false, serializedName: 'subinquireditemcount', diff --git a/lib/services/recoveryServicesBackupManagement/lib/models/azureVmWorkloadProtectionPolicy.js b/lib/services/recoveryServicesBackupManagement/lib/models/azureVmWorkloadProtectionPolicy.js index f121cd2bbf..7f4c7a0737 100644 --- a/lib/services/recoveryServicesBackupManagement/lib/models/azureVmWorkloadProtectionPolicy.js +++ b/lib/services/recoveryServicesBackupManagement/lib/models/azureVmWorkloadProtectionPolicy.js @@ -20,7 +20,11 @@ const models = require('./index'); class AzureVmWorkloadProtectionPolicy extends models['ProtectionPolicy'] { /** * Create a AzureVmWorkloadProtectionPolicy. - * @member {string} [workLoadType] Type of workload for the backup management + * @member {string} [workLoadType] Type of workload for the backup + * management. Possible values include: 'Invalid', 'VM', 'FileFolder', + * 'AzureSqlDb', 'SQLDB', 'Exchange', 'Sharepoint', 'VMwareVM', + * 'SystemState', 'Client', 'GenericDataSource', 'SQLDataBase', + * 'AzureFileShare', 'SAPHanaDatabase' * @member {object} [settings] Common settings for the backup management * @member {string} [settings.timeZone] TimeZone optional input as string. * For example: TimeZone = "Pacific Standard Time". diff --git a/lib/services/recoveryServicesBackupManagement/lib/models/azureVmWorkloadSAPHanaDatabaseProtectableItem.js b/lib/services/recoveryServicesBackupManagement/lib/models/azureVmWorkloadSAPHanaDatabaseProtectableItem.js index c8428609c0..5257135b29 100644 --- a/lib/services/recoveryServicesBackupManagement/lib/models/azureVmWorkloadSAPHanaDatabaseProtectableItem.js +++ b/lib/services/recoveryServicesBackupManagement/lib/models/azureVmWorkloadSAPHanaDatabaseProtectableItem.js @@ -108,6 +108,13 @@ class AzureVmWorkloadSAPHanaDatabaseProtectableItem extends models['AzureVmWorkl name: 'Boolean' } }, + isAutoProtected: { + required: false, + serializedName: 'isAutoProtected', + type: { + name: 'Boolean' + } + }, subinquireditemcount: { required: false, serializedName: 'subinquireditemcount', diff --git a/lib/services/recoveryServicesBackupManagement/lib/models/azureVmWorkloadSAPHanaSystemProtectableItem.js b/lib/services/recoveryServicesBackupManagement/lib/models/azureVmWorkloadSAPHanaSystemProtectableItem.js index 2399ef67d9..3a5247354f 100644 --- a/lib/services/recoveryServicesBackupManagement/lib/models/azureVmWorkloadSAPHanaSystemProtectableItem.js +++ b/lib/services/recoveryServicesBackupManagement/lib/models/azureVmWorkloadSAPHanaSystemProtectableItem.js @@ -108,6 +108,13 @@ class AzureVmWorkloadSAPHanaSystemProtectableItem extends models['AzureVmWorkloa name: 'Boolean' } }, + isAutoProtected: { + required: false, + serializedName: 'isAutoProtected', + type: { + name: 'Boolean' + } + }, subinquireditemcount: { required: false, serializedName: 'subinquireditemcount', diff --git a/lib/services/recoveryServicesBackupManagement/lib/models/azureVmWorkloadSQLAvailabilityGroupProtectableItem.js b/lib/services/recoveryServicesBackupManagement/lib/models/azureVmWorkloadSQLAvailabilityGroupProtectableItem.js index 27b6d1289c..b29837dc5f 100644 --- a/lib/services/recoveryServicesBackupManagement/lib/models/azureVmWorkloadSQLAvailabilityGroupProtectableItem.js +++ b/lib/services/recoveryServicesBackupManagement/lib/models/azureVmWorkloadSQLAvailabilityGroupProtectableItem.js @@ -109,6 +109,13 @@ class AzureVmWorkloadSQLAvailabilityGroupProtectableItem extends models['AzureVm name: 'Boolean' } }, + isAutoProtected: { + required: false, + serializedName: 'isAutoProtected', + type: { + name: 'Boolean' + } + }, subinquireditemcount: { required: false, serializedName: 'subinquireditemcount', diff --git a/lib/services/recoveryServicesBackupManagement/lib/models/azureVmWorkloadSQLDatabaseProtectableItem.js b/lib/services/recoveryServicesBackupManagement/lib/models/azureVmWorkloadSQLDatabaseProtectableItem.js index 931af9bdbd..af84e8a6ad 100644 --- a/lib/services/recoveryServicesBackupManagement/lib/models/azureVmWorkloadSQLDatabaseProtectableItem.js +++ b/lib/services/recoveryServicesBackupManagement/lib/models/azureVmWorkloadSQLDatabaseProtectableItem.js @@ -108,6 +108,13 @@ class AzureVmWorkloadSQLDatabaseProtectableItem extends models['AzureVmWorkloadP name: 'Boolean' } }, + isAutoProtected: { + required: false, + serializedName: 'isAutoProtected', + type: { + name: 'Boolean' + } + }, subinquireditemcount: { required: false, serializedName: 'subinquireditemcount', diff --git a/lib/services/recoveryServicesBackupManagement/lib/models/azureVmWorkloadSQLInstanceProtectableItem.js b/lib/services/recoveryServicesBackupManagement/lib/models/azureVmWorkloadSQLInstanceProtectableItem.js index c006e83366..04e2d7721f 100644 --- a/lib/services/recoveryServicesBackupManagement/lib/models/azureVmWorkloadSQLInstanceProtectableItem.js +++ b/lib/services/recoveryServicesBackupManagement/lib/models/azureVmWorkloadSQLInstanceProtectableItem.js @@ -108,6 +108,13 @@ class AzureVmWorkloadSQLInstanceProtectableItem extends models['AzureVmWorkloadP name: 'Boolean' } }, + isAutoProtected: { + required: false, + serializedName: 'isAutoProtected', + type: { + name: 'Boolean' + } + }, subinquireditemcount: { required: false, serializedName: 'subinquireditemcount', diff --git a/lib/services/recoveryServicesBackupManagement/lib/models/azureWorkloadContainer.js b/lib/services/recoveryServicesBackupManagement/lib/models/azureWorkloadContainer.js index b207b298f8..da2e358e95 100644 --- a/lib/services/recoveryServicesBackupManagement/lib/models/azureWorkloadContainer.js +++ b/lib/services/recoveryServicesBackupManagement/lib/models/azureWorkloadContainer.js @@ -64,7 +64,7 @@ class AzureWorkloadContainer extends models['ProtectionContainer'] { mapper() { return { required: false, - serializedName: 'AzureWorkloadContainer', + serializedName: 'AzureWorkloadBackupRequest', type: { name: 'Composite', polymorphicDiscriminator: { diff --git a/lib/services/recoveryServicesBackupManagement/lib/models/azureWorkloadContainerExtendedInfo.js b/lib/services/recoveryServicesBackupManagement/lib/models/azureWorkloadContainerExtendedInfo.js index b4486137df..773d8ee112 100644 --- a/lib/services/recoveryServicesBackupManagement/lib/models/azureWorkloadContainerExtendedInfo.js +++ b/lib/services/recoveryServicesBackupManagement/lib/models/azureWorkloadContainerExtendedInfo.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * Extended information of the container. * diff --git a/lib/services/recoveryServicesBackupManagement/lib/models/azureWorkloadJobExtendedInfo.js b/lib/services/recoveryServicesBackupManagement/lib/models/azureWorkloadJobExtendedInfo.js index 8576a9323d..965cf8515a 100644 --- a/lib/services/recoveryServicesBackupManagement/lib/models/azureWorkloadJobExtendedInfo.js +++ b/lib/services/recoveryServicesBackupManagement/lib/models/azureWorkloadJobExtendedInfo.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * Azure VM workload-specific additional information for job. * diff --git a/lib/services/recoveryServicesBackupManagement/lib/models/azureWorkloadSQLRecoveryPointExtendedInfo.js b/lib/services/recoveryServicesBackupManagement/lib/models/azureWorkloadSQLRecoveryPointExtendedInfo.js index f38a575a9b..1e4b189da4 100644 --- a/lib/services/recoveryServicesBackupManagement/lib/models/azureWorkloadSQLRecoveryPointExtendedInfo.js +++ b/lib/services/recoveryServicesBackupManagement/lib/models/azureWorkloadSQLRecoveryPointExtendedInfo.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * Extended info class details * diff --git a/lib/services/recoveryServicesBackupManagement/lib/models/backupEngineBase.js b/lib/services/recoveryServicesBackupManagement/lib/models/backupEngineBase.js index a5e06b9408..83091a9778 100644 --- a/lib/services/recoveryServicesBackupManagement/lib/models/backupEngineBase.js +++ b/lib/services/recoveryServicesBackupManagement/lib/models/backupEngineBase.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * The base backup engine class. All workload specific backup engines derive * from this class. diff --git a/lib/services/recoveryServicesBackupManagement/lib/models/backupManagementUsage.js b/lib/services/recoveryServicesBackupManagement/lib/models/backupManagementUsage.js index 20f4e2d85a..45d14b3d4b 100644 --- a/lib/services/recoveryServicesBackupManagement/lib/models/backupManagementUsage.js +++ b/lib/services/recoveryServicesBackupManagement/lib/models/backupManagementUsage.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * Backup management usages of a vault. * diff --git a/lib/services/recoveryServicesBackupManagement/lib/models/backupStatusResponse.js b/lib/services/recoveryServicesBackupManagement/lib/models/backupStatusResponse.js index 4b07bfbcd8..0ed47f4e40 100644 --- a/lib/services/recoveryServicesBackupManagement/lib/models/backupStatusResponse.js +++ b/lib/services/recoveryServicesBackupManagement/lib/models/backupStatusResponse.js @@ -20,7 +20,6 @@ class BackupStatusResponse { * @member {string} [protectionStatus] Specifies whether the container is * registered or not. Possible values include: 'Invalid', 'NotProtected', * 'Protecting', 'Protected', 'ProtectionFailed' - * @member {string} [vaultId] Specifies the arm resource id of the vault * @member {string} [fabricName] Specifies the fabric name - Azure or AD. * Possible values include: 'Invalid', 'Azure' * @member {string} [containerName] Specifies the product specific container @@ -57,13 +56,6 @@ class BackupStatusResponse { name: 'String' } }, - vaultId: { - required: false, - serializedName: 'vaultId', - type: { - name: 'String' - } - }, fabricName: { required: false, serializedName: 'fabricName', diff --git a/lib/services/recoveryServicesBackupManagement/lib/models/clientDiscoveryForProperties.js b/lib/services/recoveryServicesBackupManagement/lib/models/clientDiscoveryForProperties.js index 44b459cb33..c2adf7fec6 100644 --- a/lib/services/recoveryServicesBackupManagement/lib/models/clientDiscoveryForProperties.js +++ b/lib/services/recoveryServicesBackupManagement/lib/models/clientDiscoveryForProperties.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * Class to represent shoebox properties in json client discovery. * diff --git a/lib/services/recoveryServicesBackupManagement/lib/models/clientDiscoveryForServiceSpecification.js b/lib/services/recoveryServicesBackupManagement/lib/models/clientDiscoveryForServiceSpecification.js index 491353f624..ab52bd8439 100644 --- a/lib/services/recoveryServicesBackupManagement/lib/models/clientDiscoveryForServiceSpecification.js +++ b/lib/services/recoveryServicesBackupManagement/lib/models/clientDiscoveryForServiceSpecification.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * Class to represent shoebox service specification in json client discovery. * diff --git a/lib/services/recoveryServicesBackupManagement/lib/models/clientDiscoveryValueForSingleApi.js b/lib/services/recoveryServicesBackupManagement/lib/models/clientDiscoveryValueForSingleApi.js index 1acb5cf06f..a6dbe5bad4 100644 --- a/lib/services/recoveryServicesBackupManagement/lib/models/clientDiscoveryValueForSingleApi.js +++ b/lib/services/recoveryServicesBackupManagement/lib/models/clientDiscoveryValueForSingleApi.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * Available operation details. * diff --git a/lib/services/recoveryServicesBackupManagement/lib/models/dailyRetentionFormat.js b/lib/services/recoveryServicesBackupManagement/lib/models/dailyRetentionFormat.js index bc60b22650..9cd22bebf8 100644 --- a/lib/services/recoveryServicesBackupManagement/lib/models/dailyRetentionFormat.js +++ b/lib/services/recoveryServicesBackupManagement/lib/models/dailyRetentionFormat.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * Daily retention format. * diff --git a/lib/services/recoveryServicesBackupManagement/lib/models/dailyRetentionSchedule.js b/lib/services/recoveryServicesBackupManagement/lib/models/dailyRetentionSchedule.js index 298e293b63..0cfdca28ef 100644 --- a/lib/services/recoveryServicesBackupManagement/lib/models/dailyRetentionSchedule.js +++ b/lib/services/recoveryServicesBackupManagement/lib/models/dailyRetentionSchedule.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * Daily retention schedule. * diff --git a/lib/services/recoveryServicesBackupManagement/lib/models/distributedNodesInfo.js b/lib/services/recoveryServicesBackupManagement/lib/models/distributedNodesInfo.js index 032066fa12..fc002ff063 100644 --- a/lib/services/recoveryServicesBackupManagement/lib/models/distributedNodesInfo.js +++ b/lib/services/recoveryServicesBackupManagement/lib/models/distributedNodesInfo.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * This is used to represent the various nodes of the distributed container. * diff --git a/lib/services/recoveryServicesBackupManagement/lib/models/dpmJobExtendedInfo.js b/lib/services/recoveryServicesBackupManagement/lib/models/dpmJobExtendedInfo.js index 20b60427d2..9f10551462 100644 --- a/lib/services/recoveryServicesBackupManagement/lib/models/dpmJobExtendedInfo.js +++ b/lib/services/recoveryServicesBackupManagement/lib/models/dpmJobExtendedInfo.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * Additional information on the DPM workload-specific job. * diff --git a/lib/services/recoveryServicesBackupManagement/lib/models/genericContainerExtendedInfo.js b/lib/services/recoveryServicesBackupManagement/lib/models/genericContainerExtendedInfo.js index 42c4c695de..da4b06aef9 100644 --- a/lib/services/recoveryServicesBackupManagement/lib/models/genericContainerExtendedInfo.js +++ b/lib/services/recoveryServicesBackupManagement/lib/models/genericContainerExtendedInfo.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * Container extended information * diff --git a/lib/services/recoveryServicesBackupManagement/lib/models/index.d.ts b/lib/services/recoveryServicesBackupManagement/lib/models/index.d.ts index f0b74b17af..f5ac0e9126 100644 --- a/lib/services/recoveryServicesBackupManagement/lib/models/index.d.ts +++ b/lib/services/recoveryServicesBackupManagement/lib/models/index.d.ts @@ -180,7 +180,10 @@ export interface ProtectionPolicy { * @constructor * AzureStorage backup policy. * - * @member {string} [workLoadType] Type of workload for the backup management + * @member {string} [workLoadType] Type of workload for the backup management. + * Possible values include: 'Invalid', 'VM', 'FileFolder', 'AzureSqlDb', + * 'SQLDB', 'Exchange', 'Sharepoint', 'VMwareVM', 'SystemState', 'Client', + * 'GenericDataSource', 'SQLDataBase', 'AzureFileShare', 'SAPHanaDatabase' * @member {object} [schedulePolicy] Backup schedule specified as part of * backup policy. * @member {string} [schedulePolicy.schedulePolicyType] Polymorphic @@ -866,7 +869,8 @@ export interface Settings { * @constructor * Sub-protection policy which includes schedule and retention * - * @member {string} [policyType] Type of backup policy type + * @member {string} [policyType] Type of backup policy type. Possible values + * include: 'Invalid', 'Full', 'Differential', 'Log', 'CopyOnlyFull' * @member {object} [schedulePolicy] Backup schedule specified as part of * backup policy. * @member {string} [schedulePolicy.schedulePolicyType] Polymorphic @@ -888,7 +892,10 @@ export interface SubProtectionPolicy { * @constructor * Azure VM (Mercury) workload-specific backup policy. * - * @member {string} [workLoadType] Type of workload for the backup management + * @member {string} [workLoadType] Type of workload for the backup management. + * Possible values include: 'Invalid', 'VM', 'FileFolder', 'AzureSqlDb', + * 'SQLDB', 'Exchange', 'Sharepoint', 'VMwareVM', 'SystemState', 'Client', + * 'GenericDataSource', 'SQLDataBase', 'AzureFileShare', 'SAPHanaDatabase' * @member {object} [settings] Common settings for the backup management * @member {string} [settings.timeZone] TimeZone optional input as string. For * example: TimeZone = "Pacific Standard Time". @@ -1279,7 +1286,6 @@ export interface BackupStatusRequest { * @member {string} [protectionStatus] Specifies whether the container is * registered or not. Possible values include: 'Invalid', 'NotProtected', * 'Protecting', 'Protected', 'ProtectionFailed' - * @member {string} [vaultId] Specifies the arm resource id of the vault * @member {string} [fabricName] Specifies the fabric name - Azure or AD. * Possible values include: 'Invalid', 'Azure' * @member {string} [containerName] Specifies the product specific container @@ -1294,7 +1300,6 @@ export interface BackupStatusRequest { */ export interface BackupStatusResponse { protectionStatus?: string; - vaultId?: string; fabricName?: string; containerName?: string; protectedItemName?: string; @@ -2274,14 +2279,12 @@ export interface OperationResultInfoBaseResource extends OperationWorkerResponse * 'Client', 'GenericDataSource', 'SQLDataBase', 'AzureFileShare', * 'SAPHanaDatabase' * @member {string} [resourceId] ARM Virtual Machine Id - * @member {string} [vaultId] ARM id of the Recovery Services Vault * @member {string} [properties] Configuration of VM if any needs to be * validated like OS type etc */ export interface PreValidateEnableBackupRequest { resourceType?: string; resourceId?: string; - vaultId?: string; properties?: string; } @@ -2381,6 +2384,28 @@ export interface ProtectedItemResource extends Resource { properties?: ProtectedItem; } +/** + * @class + * Initializes a new instance of the ProtectionIntentQueryObject class. + * @constructor + * Filters to list protection intent. + * + * @member {string} [backupManagementType] Backup management type for the + * backed up item. Possible values include: 'Invalid', 'AzureIaasVM', 'MAB', + * 'DPM', 'AzureBackupServer', 'AzureSql', 'AzureStorage', 'AzureWorkload', + * 'DefaultBackup' + * @member {string} [itemType] Type of workload this item represents. Possible + * values include: 'Invalid', 'SQLInstance', 'SQLAvailabilityGroupContainer' + * @member {string} [parentName] Parent name of the intent + * @member {string} [itemName] Item name of the intent + */ +export interface ProtectionIntentQueryObject { + backupManagementType?: string; + itemType?: string; + parentName?: string; + itemName?: string; +} + /** * @class * Initializes a new instance of the ProtectionIntentResource class. @@ -3088,6 +3113,8 @@ export interface PreBackupValidation { * @member {string} [serverName] Host/Cluster Name for instance or AG * @member {boolean} [isAutoProtectable] Indicates if protectable item is * auto-protectable + * @member {boolean} [isAutoProtected] Indicates if protectable item is + * auto-protected * @member {number} [subinquireditemcount] For instance or AG, indicates number * of DB's present * @member {number} [subprotectableitemcount] For instance or AG, indicates @@ -3106,6 +3133,7 @@ export interface AzureVmWorkloadProtectableItem extends WorkloadProtectableItem parentUniqueName?: string; serverName?: string; isAutoProtectable?: boolean; + isAutoProtected?: boolean; subinquireditemcount?: number; subprotectableitemcount?: number; prebackupvalidation?: PreBackupValidation; @@ -4636,6 +4664,16 @@ export interface ProtectionPolicyResourceList extends Array { } +/** + * @class + * Initializes a new instance of the ProtectionIntentResourceList class. + * @constructor + * List of ProtectionIntent resources + * + */ +export interface ProtectionIntentResourceList extends Array { +} + /** * @class * Initializes a new instance of the BackupManagementUsageList class. diff --git a/lib/services/recoveryServicesBackupManagement/lib/models/index.js b/lib/services/recoveryServicesBackupManagement/lib/models/index.js index 2422c080ff..f9ba31c31a 100644 --- a/lib/services/recoveryServicesBackupManagement/lib/models/index.js +++ b/lib/services/recoveryServicesBackupManagement/lib/models/index.js @@ -120,6 +120,7 @@ exports.PreValidateEnableBackupRequest = require('./preValidateEnableBackupReque exports.PreValidateEnableBackupResponse = require('./preValidateEnableBackupResponse'); exports.ProtectedItemQueryObject = require('./protectedItemQueryObject'); exports.ProtectedItemResource = require('./protectedItemResource'); +exports.ProtectionIntentQueryObject = require('./protectionIntentQueryObject'); exports.ProtectionIntentResource = require('./protectionIntentResource'); exports.ProtectionPolicyQueryObject = require('./protectionPolicyQueryObject'); exports.ProtectionPolicyResource = require('./protectionPolicyResource'); @@ -240,6 +241,7 @@ exports.ClientDiscoveryValueForSingleApi = require('./clientDiscoveryValueForSin exports.JobResourceList = require('./jobResourceList'); exports.ProtectionPolicyResourceList = require('./protectionPolicyResourceList'); exports.ProtectedItemResourceList = require('./protectedItemResourceList'); +exports.ProtectionIntentResourceList = require('./protectionIntentResourceList'); exports.BackupManagementUsageList = require('./backupManagementUsageList'); exports.BackupEngineBaseResourceList = require('./backupEngineBaseResourceList'); exports.ProtectableContainerResourceList = require('./protectableContainerResourceList'); @@ -330,7 +332,7 @@ exports.discriminators = { 'WorkloadProtectableItem.SQLInstance' : exports.AzureVmWorkloadSQLInstanceProtectableItem, 'WorkloadItem.SQLInstance' : exports.AzureVmWorkloadSQLInstanceWorkloadItem, 'BackupRequest.AzureWorkloadBackupRequest' : exports.AzureWorkloadBackupRequest, - 'ProtectionContainer.AzureWorkloadContainer' : exports.AzureWorkloadContainer, + 'ProtectionContainer.AzureWorkloadBackupRequest' : exports.AzureWorkloadContainer, 'RecoveryPoint.AzureWorkloadRecoveryPoint' : exports.AzureWorkloadRecoveryPoint, 'RecoveryPoint.AzureWorkloadSAPHanaPointInTimeRecoveryPoint' : exports.AzureWorkloadSAPHanaPointInTimeRecoveryPoint, 'RecoveryPoint.AzureWorkloadSAPHanaRecoveryPoint' : exports.AzureWorkloadSAPHanaRecoveryPoint, diff --git a/lib/services/recoveryServicesBackupManagement/lib/models/inquiryInfo.js b/lib/services/recoveryServicesBackupManagement/lib/models/inquiryInfo.js index 00729607b1..05437d05d6 100644 --- a/lib/services/recoveryServicesBackupManagement/lib/models/inquiryInfo.js +++ b/lib/services/recoveryServicesBackupManagement/lib/models/inquiryInfo.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * Details about inquired protectable items under a given container. * diff --git a/lib/services/recoveryServicesBackupManagement/lib/models/inquiryValidation.js b/lib/services/recoveryServicesBackupManagement/lib/models/inquiryValidation.js index 1659e8c572..40503748b5 100644 --- a/lib/services/recoveryServicesBackupManagement/lib/models/inquiryValidation.js +++ b/lib/services/recoveryServicesBackupManagement/lib/models/inquiryValidation.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * Validation for inquired protectable items under a given container. * diff --git a/lib/services/recoveryServicesBackupManagement/lib/models/instantItemRecoveryTarget.js b/lib/services/recoveryServicesBackupManagement/lib/models/instantItemRecoveryTarget.js index 23c0807974..82468614ef 100644 --- a/lib/services/recoveryServicesBackupManagement/lib/models/instantItemRecoveryTarget.js +++ b/lib/services/recoveryServicesBackupManagement/lib/models/instantItemRecoveryTarget.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * Target details for file / folder restore. * diff --git a/lib/services/recoveryServicesBackupManagement/lib/models/keyAndSecretDetails.js b/lib/services/recoveryServicesBackupManagement/lib/models/keyAndSecretDetails.js index 3e9f742262..31d74e55e5 100644 --- a/lib/services/recoveryServicesBackupManagement/lib/models/keyAndSecretDetails.js +++ b/lib/services/recoveryServicesBackupManagement/lib/models/keyAndSecretDetails.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * BEK is bitlocker key. * KEK is encryption key for BEK diff --git a/lib/services/recoveryServicesBackupManagement/lib/models/mabJobExtendedInfo.js b/lib/services/recoveryServicesBackupManagement/lib/models/mabJobExtendedInfo.js index 250e070899..ab3eb85eb0 100644 --- a/lib/services/recoveryServicesBackupManagement/lib/models/mabJobExtendedInfo.js +++ b/lib/services/recoveryServicesBackupManagement/lib/models/mabJobExtendedInfo.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * Additional information for the MAB workload-specific job. * diff --git a/lib/services/recoveryServicesBackupManagement/lib/models/monthlyRetentionSchedule.js b/lib/services/recoveryServicesBackupManagement/lib/models/monthlyRetentionSchedule.js index 763deac3bc..0679f0af4d 100644 --- a/lib/services/recoveryServicesBackupManagement/lib/models/monthlyRetentionSchedule.js +++ b/lib/services/recoveryServicesBackupManagement/lib/models/monthlyRetentionSchedule.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * Monthly retention schedule. * diff --git a/lib/services/recoveryServicesBackupManagement/lib/models/operationStatus.js b/lib/services/recoveryServicesBackupManagement/lib/models/operationStatus.js index 62e6d80c11..1cbe2d7a90 100644 --- a/lib/services/recoveryServicesBackupManagement/lib/models/operationStatus.js +++ b/lib/services/recoveryServicesBackupManagement/lib/models/operationStatus.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * Operation status. * diff --git a/lib/services/recoveryServicesBackupManagement/lib/models/preValidateEnableBackupRequest.js b/lib/services/recoveryServicesBackupManagement/lib/models/preValidateEnableBackupRequest.js index 76ae59db7c..17036bd129 100644 --- a/lib/services/recoveryServicesBackupManagement/lib/models/preValidateEnableBackupRequest.js +++ b/lib/services/recoveryServicesBackupManagement/lib/models/preValidateEnableBackupRequest.js @@ -28,7 +28,6 @@ class PreValidateEnableBackupRequest { * 'SystemState', 'Client', 'GenericDataSource', 'SQLDataBase', * 'AzureFileShare', 'SAPHanaDatabase' * @member {string} [resourceId] ARM Virtual Machine Id - * @member {string} [vaultId] ARM id of the Recovery Services Vault * @member {string} [properties] Configuration of VM if any needs to be * validated like OS type etc */ @@ -63,13 +62,6 @@ class PreValidateEnableBackupRequest { name: 'String' } }, - vaultId: { - required: false, - serializedName: 'vaultId', - type: { - name: 'String' - } - }, properties: { required: false, serializedName: 'properties', diff --git a/lib/services/recoveryServicesBackupManagement/lib/models/protectionIntentQueryObject.js b/lib/services/recoveryServicesBackupManagement/lib/models/protectionIntentQueryObject.js new file mode 100644 index 0000000000..446f0f67fe --- /dev/null +++ b/lib/services/recoveryServicesBackupManagement/lib/models/protectionIntentQueryObject.js @@ -0,0 +1,81 @@ +/* + * 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'; + +/** + * Filters to list protection intent. + * + */ +class ProtectionIntentQueryObject { + /** + * Create a ProtectionIntentQueryObject. + * @member {string} [backupManagementType] Backup management type for the + * backed up item. Possible values include: 'Invalid', 'AzureIaasVM', 'MAB', + * 'DPM', 'AzureBackupServer', 'AzureSql', 'AzureStorage', 'AzureWorkload', + * 'DefaultBackup' + * @member {string} [itemType] Type of workload this item represents. + * Possible values include: 'Invalid', 'SQLInstance', + * 'SQLAvailabilityGroupContainer' + * @member {string} [parentName] Parent name of the intent + * @member {string} [itemName] Item name of the intent + */ + constructor() { + } + + /** + * Defines the metadata of ProtectionIntentQueryObject + * + * @returns {object} metadata of ProtectionIntentQueryObject + * + */ + mapper() { + return { + required: false, + serializedName: 'ProtectionIntentQueryObject', + type: { + name: 'Composite', + className: 'ProtectionIntentQueryObject', + modelProperties: { + backupManagementType: { + required: false, + serializedName: 'backupManagementType', + type: { + name: 'String' + } + }, + itemType: { + required: false, + serializedName: 'itemType', + type: { + name: 'String' + } + }, + parentName: { + required: false, + serializedName: 'parentName', + type: { + name: 'String' + } + }, + itemName: { + required: false, + serializedName: 'itemName', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = ProtectionIntentQueryObject; diff --git a/lib/services/recoveryServicesBackupManagement/lib/models/protectionIntentResourceList.js b/lib/services/recoveryServicesBackupManagement/lib/models/protectionIntentResourceList.js new file mode 100644 index 0000000000..faeb79e631 --- /dev/null +++ b/lib/services/recoveryServicesBackupManagement/lib/models/protectionIntentResourceList.js @@ -0,0 +1,66 @@ +/* + * 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'; + +/** + * List of ProtectionIntent resources + */ +class ProtectionIntentResourceList extends Array { + /** + * Create a ProtectionIntentResourceList. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of ProtectionIntentResourceList + * + * @returns {object} metadata of ProtectionIntentResourceList + * + */ + mapper() { + return { + required: false, + serializedName: 'ProtectionIntentResourceList', + type: { + name: 'Composite', + className: 'ProtectionIntentResourceList', + modelProperties: { + nextLink: { + required: false, + serializedName: 'nextLink', + type: { + name: 'String' + } + }, + value: { + required: false, + serializedName: '', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ProtectionIntentResourceElementType', + type: { + name: 'Composite', + className: 'ProtectionIntentResource' + } + } + } + } + } + } + }; + } +} + +module.exports = ProtectionIntentResourceList; diff --git a/lib/services/recoveryServicesBackupManagement/lib/models/subProtectionPolicy.js b/lib/services/recoveryServicesBackupManagement/lib/models/subProtectionPolicy.js index e62dfb2635..fa676f8811 100644 --- a/lib/services/recoveryServicesBackupManagement/lib/models/subProtectionPolicy.js +++ b/lib/services/recoveryServicesBackupManagement/lib/models/subProtectionPolicy.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * Sub-protection policy which includes schedule and retention * @@ -19,7 +17,8 @@ const models = require('./index'); class SubProtectionPolicy { /** * Create a SubProtectionPolicy. - * @member {string} [policyType] Type of backup policy type + * @member {string} [policyType] Type of backup policy type. Possible values + * include: 'Invalid', 'Full', 'Differential', 'Log', 'CopyOnlyFull' * @member {object} [schedulePolicy] Backup schedule specified as part of * backup policy. * @member {string} [schedulePolicy.schedulePolicyType] Polymorphic diff --git a/lib/services/recoveryServicesBackupManagement/lib/models/validateOperationResponse.js b/lib/services/recoveryServicesBackupManagement/lib/models/validateOperationResponse.js index 87f68c2e49..5732d78c4f 100644 --- a/lib/services/recoveryServicesBackupManagement/lib/models/validateOperationResponse.js +++ b/lib/services/recoveryServicesBackupManagement/lib/models/validateOperationResponse.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * Base class for validate operation response. * diff --git a/lib/services/recoveryServicesBackupManagement/lib/models/validateOperationsResponse.js b/lib/services/recoveryServicesBackupManagement/lib/models/validateOperationsResponse.js index f9bd3a6bb3..b740e7d579 100644 --- a/lib/services/recoveryServicesBackupManagement/lib/models/validateOperationsResponse.js +++ b/lib/services/recoveryServicesBackupManagement/lib/models/validateOperationsResponse.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * Class representing a ValidateOperationsResponse. */ diff --git a/lib/services/recoveryServicesBackupManagement/lib/models/weeklyRetentionSchedule.js b/lib/services/recoveryServicesBackupManagement/lib/models/weeklyRetentionSchedule.js index cd583ce7f8..98b6412ce0 100644 --- a/lib/services/recoveryServicesBackupManagement/lib/models/weeklyRetentionSchedule.js +++ b/lib/services/recoveryServicesBackupManagement/lib/models/weeklyRetentionSchedule.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * Weekly retention schedule. * diff --git a/lib/services/recoveryServicesBackupManagement/lib/models/workloadInquiryDetails.js b/lib/services/recoveryServicesBackupManagement/lib/models/workloadInquiryDetails.js index f89cbff72a..e3d7affaa2 100644 --- a/lib/services/recoveryServicesBackupManagement/lib/models/workloadInquiryDetails.js +++ b/lib/services/recoveryServicesBackupManagement/lib/models/workloadInquiryDetails.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * Details of an inquired protectable item. * diff --git a/lib/services/recoveryServicesBackupManagement/lib/models/yearlyRetentionSchedule.js b/lib/services/recoveryServicesBackupManagement/lib/models/yearlyRetentionSchedule.js index 51ab1b7c87..886e7f8529 100644 --- a/lib/services/recoveryServicesBackupManagement/lib/models/yearlyRetentionSchedule.js +++ b/lib/services/recoveryServicesBackupManagement/lib/models/yearlyRetentionSchedule.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * Yearly retention schedule. * diff --git a/lib/services/recoveryServicesBackupManagement/lib/operations/backupProtectionIntent.js b/lib/services/recoveryServicesBackupManagement/lib/operations/backupProtectionIntent.js new file mode 100644 index 0000000000..deb06437ef --- /dev/null +++ b/lib/services/recoveryServicesBackupManagement/lib/operations/backupProtectionIntent.js @@ -0,0 +1,504 @@ +/* + * 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; + +/** + * Provides a pageable list of all intents that are present within a vault. + * + * @param {string} vaultName The name of the recovery services vault. + * + * @param {string} resourceGroupName The name of the resource group where the + * recovery services vault is present. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] OData filter options. + * + * @param {string} [options.skipToken] skipToken Filter. + * + * @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 ProtectionIntentResourceList} 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 _list(vaultName, resourceGroupName, 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 filter = (options && options.filter !== undefined) ? options.filter : undefined; + let skipToken = (options && options.skipToken !== undefined) ? options.skipToken : undefined; + let apiVersion = '2017-07-01'; + // Validate + try { + if (vaultName === null || vaultName === undefined || typeof vaultName.valueOf() !== 'string') { + throw new Error('vaultName cannot be null or undefined and it must be of type string.'); + } + 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 (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 (filter !== null && filter !== undefined && typeof filter.valueOf() !== 'string') { + throw new Error('filter must be of type string.'); + } + if (skipToken !== null && skipToken !== undefined && typeof skipToken.valueOf() !== 'string') { + throw new Error('skipToken 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.RecoveryServices/vaults/{vaultName}/backupProtectionIntents'; + requestUrl = requestUrl.replace('{vaultName}', encodeURIComponent(vaultName)); + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (filter !== null && filter !== undefined) { + queryParameters.push('$filter=' + encodeURIComponent(filter)); + } + if (skipToken !== null && skipToken !== undefined) { + queryParameters.push('$skipToken=' + encodeURIComponent(skipToken)); + } + 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['ProtectionIntentResourceList']().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); + }); +} + +/** + * Provides a pageable list of all intents that are present within a vault. + * + * @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 ProtectionIntentResourceList} 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 _listNext(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['ProtectionIntentResourceList']().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 BackupProtectionIntent. */ +class BackupProtectionIntent { + /** + * Create a BackupProtectionIntent. + * @param {RecoveryServicesBackupClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._list = _list; + this._listNext = _listNext; + } + + /** + * Provides a pageable list of all intents that are present within a vault. + * + * @param {string} vaultName The name of the recovery services vault. + * + * @param {string} resourceGroupName The name of the resource group where the + * recovery services vault is present. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] OData filter options. + * + * @param {string} [options.skipToken] skipToken Filter. + * + * @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. + */ + listWithHttpOperationResponse(vaultName, resourceGroupName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(vaultName, resourceGroupName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Provides a pageable list of all intents that are present within a vault. + * + * @param {string} vaultName The name of the recovery services vault. + * + * @param {string} resourceGroupName The name of the resource group where the + * recovery services vault is present. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] OData filter options. + * + * @param {string} [options.skipToken] skipToken Filter. + * + * @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 {ProtectionIntentResourceList} - 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 ProtectionIntentResourceList} 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. + */ + list(vaultName, resourceGroupName, 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._list(vaultName, resourceGroupName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(vaultName, resourceGroupName, options, optionalCallback); + } + } + + /** + * Provides a pageable list of all intents that are present within a vault. + * + * @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. + */ + listNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listNext(nextPageLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Provides a pageable list of all intents that are present within a vault. + * + * @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 {ProtectionIntentResourceList} - 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 ProtectionIntentResourceList} 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. + */ + listNext(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._listNext(nextPageLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listNext(nextPageLink, options, optionalCallback); + } + } + +} + +module.exports = BackupProtectionIntent; diff --git a/lib/services/recoveryServicesBackupManagement/lib/operations/index.d.ts b/lib/services/recoveryServicesBackupManagement/lib/operations/index.d.ts index 3ae7a1ffb6..66f6d37d9d 100644 --- a/lib/services/recoveryServicesBackupManagement/lib/operations/index.d.ts +++ b/lib/services/recoveryServicesBackupManagement/lib/operations/index.d.ts @@ -40,8 +40,6 @@ export interface ProtectionIntentOperations { * * @param {string} [parameters.resourceId] ARM Virtual Machine Id * - * @param {string} [parameters.vaultId] ARM id of the Recovery Services Vault - * * @param {string} [parameters.properties] Configuration of VM if any needs to * be validated like OS type etc * @@ -77,8 +75,6 @@ export interface ProtectionIntentOperations { * * @param {string} [parameters.resourceId] ARM Virtual Machine Id * - * @param {string} [parameters.vaultId] ARM id of the Recovery Services Vault - * * @param {string} [parameters.properties] Configuration of VM if any needs to * be validated like OS type etc * @@ -115,6 +111,82 @@ export interface ProtectionIntentOperations { validate(azureRegion: string, parameters: models.PreValidateEnableBackupRequest, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + /** + * Provides the details of the protection intent up item. This is an + * asynchronous operation. To know the status of the operation, + * call the GetItemOperationResult API. + * + * @param {string} vaultName The name of the recovery services vault. + * + * @param {string} resourceGroupName The name of the resource group where the + * recovery services vault is present. + * + * @param {string} fabricName Fabric name associated with the backed up item. + * + * @param {string} intentObjectName Backed up item name whose details are to be + * fetched. + * + * @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(vaultName: string, resourceGroupName: string, fabricName: string, intentObjectName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Provides the details of the protection intent up item. This is an + * asynchronous operation. To know the status of the operation, + * call the GetItemOperationResult API. + * + * @param {string} vaultName The name of the recovery services vault. + * + * @param {string} resourceGroupName The name of the resource group where the + * recovery services vault is present. + * + * @param {string} fabricName Fabric name associated with the backed up item. + * + * @param {string} intentObjectName Backed up item name whose details are to be + * fetched. + * + * @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 {ProtectionIntentResource} - 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. + * + * {ProtectionIntentResource} [result] - The deserialized result object if an error did not occur. + * See {@link ProtectionIntentResource} 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(vaultName: string, resourceGroupName: string, fabricName: string, intentObjectName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(vaultName: string, resourceGroupName: string, fabricName: string, intentObjectName: string, callback: ServiceCallback): void; + get(vaultName: string, resourceGroupName: string, fabricName: string, intentObjectName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + /** * Create Intent for Enabling backup of an item. This is a synchronous * operation. @@ -247,6 +319,74 @@ export interface ProtectionIntentOperations { createOrUpdate(vaultName: string, resourceGroupName: string, fabricName: string, intentObjectName: string, parameters: models.ProtectionIntentResource, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; createOrUpdate(vaultName: string, resourceGroupName: string, fabricName: string, intentObjectName: string, parameters: models.ProtectionIntentResource, callback: ServiceCallback): void; createOrUpdate(vaultName: string, resourceGroupName: string, fabricName: string, intentObjectName: string, parameters: models.ProtectionIntentResource, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Used to remove intent from an item + * + * @param {string} vaultName The name of the recovery services vault. + * + * @param {string} resourceGroupName The name of the resource group where the + * recovery services vault is present. + * + * @param {string} fabricName Fabric name associated with the intent. + * + * @param {string} intentObjectName Intent to be deleted. + * + * @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. + */ + deleteMethodWithHttpOperationResponse(vaultName: string, resourceGroupName: string, fabricName: string, intentObjectName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Used to remove intent from an item + * + * @param {string} vaultName The name of the recovery services vault. + * + * @param {string} resourceGroupName The name of the resource group where the + * recovery services vault is present. + * + * @param {string} fabricName Fabric name associated with the intent. + * + * @param {string} intentObjectName Intent to be deleted. + * + * @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 {null} - 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. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {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. + */ + deleteMethod(vaultName: string, resourceGroupName: string, fabricName: string, intentObjectName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + deleteMethod(vaultName: string, resourceGroupName: string, fabricName: string, intentObjectName: string, callback: ServiceCallback): void; + deleteMethod(vaultName: string, resourceGroupName: string, fabricName: string, intentObjectName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; } /** @@ -1057,6 +1197,143 @@ export interface BackupProtectedItems { listNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; } +/** + * @class + * BackupProtectionIntent + * __NOTE__: An instance of this class is automatically created for an + * instance of the RecoveryServicesBackupClient. + */ +export interface BackupProtectionIntent { + + + /** + * Provides a pageable list of all intents that are present within a vault. + * + * @param {string} vaultName The name of the recovery services vault. + * + * @param {string} resourceGroupName The name of the resource group where the + * recovery services vault is present. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] OData filter options. + * + * @param {string} [options.skipToken] skipToken Filter. + * + * @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. + */ + listWithHttpOperationResponse(vaultName: string, resourceGroupName: string, options?: { filter? : string, skipToken? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Provides a pageable list of all intents that are present within a vault. + * + * @param {string} vaultName The name of the recovery services vault. + * + * @param {string} resourceGroupName The name of the resource group where the + * recovery services vault is present. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] OData filter options. + * + * @param {string} [options.skipToken] skipToken Filter. + * + * @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 {ProtectionIntentResourceList} - 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. + * + * {ProtectionIntentResourceList} [result] - The deserialized result object if an error did not occur. + * See {@link ProtectionIntentResourceList} 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. + */ + list(vaultName: string, resourceGroupName: string, options?: { filter? : string, skipToken? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + list(vaultName: string, resourceGroupName: string, callback: ServiceCallback): void; + list(vaultName: string, resourceGroupName: string, options: { filter? : string, skipToken? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Provides a pageable list of all intents that are present within a vault. + * + * @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. + */ + listNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Provides a pageable list of all intents that are present within a vault. + * + * @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 {ProtectionIntentResourceList} - 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. + * + * {ProtectionIntentResourceList} [result] - The deserialized result object if an error did not occur. + * See {@link ProtectionIntentResourceList} 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. + */ + listNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listNext(nextPageLink: string, callback: ServiceCallback): void; + listNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + /** * @class * BackupUsageSummaries @@ -1704,7 +1981,7 @@ export interface ProtectableContainers { /** - * Lists the containers registered to Recovery Services Vault. + * Lists the containers that can be registered to Recovery Services Vault. * * @param {string} vaultName The name of the recovery services vault. * @@ -1729,7 +2006,7 @@ export interface ProtectableContainers { listWithHttpOperationResponse(vaultName: string, resourceGroupName: string, fabricName: string, options?: { filter? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Lists the containers registered to Recovery Services Vault. + * Lists the containers that can be registered to Recovery Services Vault. * * @param {string} vaultName The name of the recovery services vault. * @@ -1774,7 +2051,7 @@ export interface ProtectableContainers { /** - * Lists the containers registered to Recovery Services Vault. + * Lists the containers that can be registered to Recovery Services Vault. * * @param {string} nextPageLink The NextLink from the previous successful call * to List operation. @@ -1793,7 +2070,7 @@ export interface ProtectableContainers { listNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Lists the containers registered to Recovery Services Vault. + * Lists the containers that can be registered to Recovery Services Vault. * * @param {string} nextPageLink The NextLink from the previous successful call * to List operation. @@ -2123,11 +2400,10 @@ export interface ProtectionContainers { /** - * @summary Inquires all the protectable item in the given container that can - * be protected. + * @summary Inquires all the protectable items under the given container. * - * Inquires all the protectable items that are protectable under the given - * container. + * This is an async operation and the results should be tracked using location + * header or Azure-async-url. * * @param {string} vaultName The name of the recovery services vault. * @@ -2155,11 +2431,10 @@ export interface ProtectionContainers { inquireWithHttpOperationResponse(vaultName: string, resourceGroupName: string, fabricName: string, containerName: string, options?: { filter? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * @summary Inquires all the protectable item in the given container that can - * be protected. + * @summary Inquires all the protectable items under the given container. * - * Inquires all the protectable items that are protectable under the given - * container. + * This is an async operation and the results should be tracked using location + * header or Azure-async-url. * * @param {string} vaultName The name of the recovery services vault. * @@ -2680,11 +2955,11 @@ export interface ProtectedItems { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - createOrUpdateWithHttpOperationResponse(vaultName: string, resourceGroupName: string, fabricName: string, containerName: string, protectedItemName: string, parameters: models.ProtectedItemResource, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + createOrUpdateWithHttpOperationResponse(vaultName: string, resourceGroupName: string, fabricName: string, containerName: string, protectedItemName: string, parameters: models.ProtectedItemResource, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** * Enables backup of an item or to modifies the backup policy information of an @@ -2759,7 +3034,7 @@ export interface ProtectedItems { * * {Promise} A promise is returned. * - * @resolve {null} - The deserialized result object. + * @resolve {ProtectedItemResource} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -2767,15 +3042,16 @@ export interface ProtectedItems { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {null} [result] - The deserialized result object if an error did not occur. + * {ProtectedItemResource} [result] - The deserialized result object if an error did not occur. + * See {@link ProtectedItemResource} 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(vaultName: string, resourceGroupName: string, fabricName: string, containerName: string, protectedItemName: string, parameters: models.ProtectedItemResource, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - createOrUpdate(vaultName: string, resourceGroupName: string, fabricName: string, containerName: string, protectedItemName: string, parameters: models.ProtectedItemResource, callback: ServiceCallback): void; - createOrUpdate(vaultName: string, resourceGroupName: string, fabricName: string, containerName: string, protectedItemName: string, parameters: models.ProtectedItemResource, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + createOrUpdate(vaultName: string, resourceGroupName: string, fabricName: string, containerName: string, protectedItemName: string, parameters: models.ProtectedItemResource, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + createOrUpdate(vaultName: string, resourceGroupName: string, fabricName: string, containerName: string, protectedItemName: string, parameters: models.ProtectedItemResource, callback: ServiceCallback): void; + createOrUpdate(vaultName: string, resourceGroupName: string, fabricName: string, containerName: string, protectedItemName: string, parameters: models.ProtectedItemResource, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** diff --git a/lib/services/recoveryServicesBackupManagement/lib/operations/index.js b/lib/services/recoveryServicesBackupManagement/lib/operations/index.js index a6d85d635e..f754d044bd 100644 --- a/lib/services/recoveryServicesBackupManagement/lib/operations/index.js +++ b/lib/services/recoveryServicesBackupManagement/lib/operations/index.js @@ -23,6 +23,7 @@ exports.ExportJobsOperationResults = require('./exportJobsOperationResults'); exports.Jobs = require('./jobs'); exports.BackupPolicies = require('./backupPolicies'); exports.BackupProtectedItems = require('./backupProtectedItems'); +exports.BackupProtectionIntent = require('./backupProtectionIntent'); exports.BackupUsageSummaries = require('./backupUsageSummaries'); exports.Operation = require('./operation'); exports.BackupResourceVaultConfigs = require('./backupResourceVaultConfigs'); diff --git a/lib/services/recoveryServicesBackupManagement/lib/operations/protectableContainers.js b/lib/services/recoveryServicesBackupManagement/lib/operations/protectableContainers.js index 383e390f99..5e3e1b34f2 100644 --- a/lib/services/recoveryServicesBackupManagement/lib/operations/protectableContainers.js +++ b/lib/services/recoveryServicesBackupManagement/lib/operations/protectableContainers.js @@ -15,7 +15,7 @@ const msRestAzure = require('ms-rest-azure'); const WebResource = msRest.WebResource; /** - * Lists the containers registered to Recovery Services Vault. + * Lists the containers that can be registered to Recovery Services Vault. * * @param {string} vaultName The name of the recovery services vault. * @@ -175,7 +175,7 @@ function _list(vaultName, resourceGroupName, fabricName, options, callback) { } /** - * Lists the containers registered to Recovery Services Vault. + * Lists the containers that can be registered to Recovery Services Vault. * * @param {string} nextPageLink The NextLink from the previous successful call * to List operation. @@ -315,7 +315,7 @@ class ProtectableContainers { } /** - * Lists the containers registered to Recovery Services Vault. + * Lists the containers that can be registered to Recovery Services Vault. * * @param {string} vaultName The name of the recovery services vault. * @@ -352,7 +352,7 @@ class ProtectableContainers { } /** - * Lists the containers registered to Recovery Services Vault. + * Lists the containers that can be registered to Recovery Services Vault. * * @param {string} vaultName The name of the recovery services vault. * @@ -412,7 +412,7 @@ class ProtectableContainers { } /** - * Lists the containers registered to Recovery Services Vault. + * Lists the containers that can be registered to Recovery Services Vault. * * @param {string} nextPageLink The NextLink from the previous successful call * to List operation. @@ -443,7 +443,7 @@ class ProtectableContainers { } /** - * Lists the containers registered to Recovery Services Vault. + * Lists the containers that can be registered to Recovery Services Vault. * * @param {string} nextPageLink The NextLink from the previous successful call * to List operation. diff --git a/lib/services/recoveryServicesBackupManagement/lib/operations/protectedItems.js b/lib/services/recoveryServicesBackupManagement/lib/operations/protectedItems.js index 8bc2b77028..0c14947fb0 100644 --- a/lib/services/recoveryServicesBackupManagement/lib/operations/protectedItems.js +++ b/lib/services/recoveryServicesBackupManagement/lib/operations/protectedItems.js @@ -261,7 +261,8 @@ function _get(vaultName, resourceGroupName, fabricName, containerName, protected * * {Error} err - The Error object if an error occurred, null otherwise. * - * {null} [result] - The deserialized result object if an error did not occur. + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ProtectedItemResource} for more information. * * {object} [request] - The HTTP Request object if an error did not occur. * @@ -364,7 +365,7 @@ function _createOrUpdate(vaultName, resourceGroupName, fabricName, containerName return callback(err); } let statusCode = response.statusCode; - if (statusCode !== 202) { + if (statusCode !== 200 && statusCode !== 202) { let error = new Error(responseBody); error.statusCode = response.statusCode; error.request = msRest.stripRequest(httpRequest); @@ -392,6 +393,23 @@ function _createOrUpdate(vaultName, resourceGroupName, fabricName, containerName // 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['ProtectedItemResource']().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); }); @@ -737,7 +755,7 @@ class ProtectedItems { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error} - The error object. */ @@ -828,7 +846,7 @@ class ProtectedItems { * * {Promise} A promise is returned * - * @resolve {null} - The deserialized result object. + * @resolve {ProtectedItemResource} - The deserialized result object. * * @reject {Error} - The error object. * @@ -836,7 +854,8 @@ class ProtectedItems { * * {Error} err - The Error object if an error occurred, null otherwise. * - * {null} [result] - The deserialized result object if an error did not occur. + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ProtectedItemResource} for more information. * * {object} [request] - The HTTP Request object if an error did not occur. * diff --git a/lib/services/recoveryServicesBackupManagement/lib/operations/protectionContainers.js b/lib/services/recoveryServicesBackupManagement/lib/operations/protectionContainers.js index 16c9a84239..a6ecdf407e 100644 --- a/lib/services/recoveryServicesBackupManagement/lib/operations/protectionContainers.js +++ b/lib/services/recoveryServicesBackupManagement/lib/operations/protectionContainers.js @@ -521,11 +521,10 @@ function _unregister(vaultName, resourceGroupName, fabricName, containerName, op } /** - * @summary Inquires all the protectable item in the given container that can - * be protected. + * @summary Inquires all the protectable items under the given container. * - * Inquires all the protectable items that are protectable under the given - * container. + * This is an async operation and the results should be tracked using location + * header or Azure-async-url. * * @param {string} vaultName The name of the recovery services vault. * @@ -1195,11 +1194,10 @@ class ProtectionContainers { } /** - * @summary Inquires all the protectable item in the given container that can - * be protected. + * @summary Inquires all the protectable items under the given container. * - * Inquires all the protectable items that are protectable under the given - * container. + * This is an async operation and the results should be tracked using location + * header or Azure-async-url. * * @param {string} vaultName The name of the recovery services vault. * @@ -1239,11 +1237,10 @@ class ProtectionContainers { } /** - * @summary Inquires all the protectable item in the given container that can - * be protected. + * @summary Inquires all the protectable items under the given container. * - * Inquires all the protectable items that are protectable under the given - * container. + * This is an async operation and the results should be tracked using location + * header or Azure-async-url. * * @param {string} vaultName The name of the recovery services vault. * diff --git a/lib/services/recoveryServicesBackupManagement/lib/operations/protectionIntentOperations.js b/lib/services/recoveryServicesBackupManagement/lib/operations/protectionIntentOperations.js index 5156f2f0a9..bb07addeaa 100644 --- a/lib/services/recoveryServicesBackupManagement/lib/operations/protectionIntentOperations.js +++ b/lib/services/recoveryServicesBackupManagement/lib/operations/protectionIntentOperations.js @@ -33,8 +33,6 @@ const WebResource = msRest.WebResource; * * @param {string} [parameters.resourceId] ARM Virtual Machine Id * - * @param {string} [parameters.vaultId] ARM id of the Recovery Services Vault - * * @param {string} [parameters.properties] Configuration of VM if any needs to * be validated like OS type etc * @@ -188,6 +186,166 @@ function _validate(azureRegion, parameters, options, callback) { }); } +/** + * Provides the details of the protection intent up item. This is an + * asynchronous operation. To know the status of the operation, + * call the GetItemOperationResult API. + * + * @param {string} vaultName The name of the recovery services vault. + * + * @param {string} resourceGroupName The name of the resource group where the + * recovery services vault is present. + * + * @param {string} fabricName Fabric name associated with the backed up item. + * + * @param {string} intentObjectName Backed up item name whose details are to be + * fetched. + * + * @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 ProtectionIntentResource} 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(vaultName, resourceGroupName, fabricName, intentObjectName, 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-07-01'; + // Validate + try { + if (vaultName === null || vaultName === undefined || typeof vaultName.valueOf() !== 'string') { + throw new Error('vaultName cannot be null or undefined and it must be of type string.'); + } + 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 (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 (fabricName === null || fabricName === undefined || typeof fabricName.valueOf() !== 'string') { + throw new Error('fabricName cannot be null or undefined and it must be of type string.'); + } + if (intentObjectName === null || intentObjectName === undefined || typeof intentObjectName.valueOf() !== 'string') { + throw new Error('intentObjectName 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.RecoveryServices/vaults/{vaultName}/backupFabrics/{fabricName}/backupProtectionIntent/{intentObjectName}'; + requestUrl = requestUrl.replace('{vaultName}', encodeURIComponent(vaultName)); + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + requestUrl = requestUrl.replace('{fabricName}', encodeURIComponent(fabricName)); + requestUrl = requestUrl.replace('{intentObjectName}', encodeURIComponent(intentObjectName)); + 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['ProtectionIntentResource']().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); + }); +} + /** * Create Intent for Enabling backup of an item. This is a synchronous * operation. @@ -394,6 +552,144 @@ function _createOrUpdate(vaultName, resourceGroupName, fabricName, intentObjectN }); } +/** + * Used to remove intent from an item + * + * @param {string} vaultName The name of the recovery services vault. + * + * @param {string} resourceGroupName The name of the resource group where the + * recovery services vault is present. + * + * @param {string} fabricName Fabric name associated with the intent. + * + * @param {string} intentObjectName Intent to be deleted. + * + * @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. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {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 _deleteMethod(vaultName, resourceGroupName, fabricName, intentObjectName, 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-07-01'; + // Validate + try { + if (vaultName === null || vaultName === undefined || typeof vaultName.valueOf() !== 'string') { + throw new Error('vaultName cannot be null or undefined and it must be of type string.'); + } + 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 (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 (fabricName === null || fabricName === undefined || typeof fabricName.valueOf() !== 'string') { + throw new Error('fabricName cannot be null or undefined and it must be of type string.'); + } + if (intentObjectName === null || intentObjectName === undefined || typeof intentObjectName.valueOf() !== 'string') { + throw new Error('intentObjectName 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.RecoveryServices/vaults/{vaultName}/backupFabrics/{fabricName}/backupProtectionIntent/{intentObjectName}'; + requestUrl = requestUrl.replace('{vaultName}', encodeURIComponent(vaultName)); + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + requestUrl = requestUrl.replace('{fabricName}', encodeURIComponent(fabricName)); + requestUrl = requestUrl.replace('{intentObjectName}', encodeURIComponent(intentObjectName)); + 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 = 'DELETE'; + 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 !== 204) { + 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; + + return callback(null, result, httpRequest, response); + }); +} + /** Class representing a ProtectionIntentOperations. */ class ProtectionIntentOperations { /** @@ -403,7 +699,9 @@ class ProtectionIntentOperations { constructor(client) { this.client = client; this._validate = _validate; + this._get = _get; this._createOrUpdate = _createOrUpdate; + this._deleteMethod = _deleteMethod; } /** @@ -425,8 +723,6 @@ class ProtectionIntentOperations { * * @param {string} [parameters.resourceId] ARM Virtual Machine Id * - * @param {string} [parameters.vaultId] ARM id of the Recovery Services Vault - * * @param {string} [parameters.properties] Configuration of VM if any needs to * be validated like OS type etc * @@ -474,8 +770,6 @@ class ProtectionIntentOperations { * * @param {string} [parameters.resourceId] ARM Virtual Machine Id * - * @param {string} [parameters.vaultId] ARM id of the Recovery Services Vault - * * @param {string} [parameters.properties] Configuration of VM if any needs to * be validated like OS type etc * @@ -527,6 +821,109 @@ class ProtectionIntentOperations { } } + /** + * Provides the details of the protection intent up item. This is an + * asynchronous operation. To know the status of the operation, + * call the GetItemOperationResult API. + * + * @param {string} vaultName The name of the recovery services vault. + * + * @param {string} resourceGroupName The name of the resource group where the + * recovery services vault is present. + * + * @param {string} fabricName Fabric name associated with the backed up item. + * + * @param {string} intentObjectName Backed up item name whose details are to be + * fetched. + * + * @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(vaultName, resourceGroupName, fabricName, intentObjectName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(vaultName, resourceGroupName, fabricName, intentObjectName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Provides the details of the protection intent up item. This is an + * asynchronous operation. To know the status of the operation, + * call the GetItemOperationResult API. + * + * @param {string} vaultName The name of the recovery services vault. + * + * @param {string} resourceGroupName The name of the resource group where the + * recovery services vault is present. + * + * @param {string} fabricName Fabric name associated with the backed up item. + * + * @param {string} intentObjectName Backed up item name whose details are to be + * fetched. + * + * @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 {ProtectionIntentResource} - 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 ProtectionIntentResource} 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(vaultName, resourceGroupName, fabricName, intentObjectName, 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(vaultName, resourceGroupName, fabricName, intentObjectName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(vaultName, resourceGroupName, fabricName, intentObjectName, options, optionalCallback); + } + } + /** * Create Intent for Enabling backup of an item. This is a synchronous * operation. @@ -688,6 +1085,101 @@ class ProtectionIntentOperations { } } + /** + * Used to remove intent from an item + * + * @param {string} vaultName The name of the recovery services vault. + * + * @param {string} resourceGroupName The name of the resource group where the + * recovery services vault is present. + * + * @param {string} fabricName Fabric name associated with the intent. + * + * @param {string} intentObjectName Intent to be deleted. + * + * @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. + */ + deleteMethodWithHttpOperationResponse(vaultName, resourceGroupName, fabricName, intentObjectName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._deleteMethod(vaultName, resourceGroupName, fabricName, intentObjectName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Used to remove intent from an item + * + * @param {string} vaultName The name of the recovery services vault. + * + * @param {string} resourceGroupName The name of the resource group where the + * recovery services vault is present. + * + * @param {string} fabricName Fabric name associated with the intent. + * + * @param {string} intentObjectName Intent to be deleted. + * + * @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 {null} - 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. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + deleteMethod(vaultName, resourceGroupName, fabricName, intentObjectName, 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._deleteMethod(vaultName, resourceGroupName, fabricName, intentObjectName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._deleteMethod(vaultName, resourceGroupName, fabricName, intentObjectName, options, optionalCallback); + } + } + } module.exports = ProtectionIntentOperations; diff --git a/lib/services/recoveryServicesBackupManagement/lib/recoveryServicesBackupClient.d.ts b/lib/services/recoveryServicesBackupManagement/lib/recoveryServicesBackupClient.d.ts index 55d90ffa1f..54c8b954e5 100644 --- a/lib/services/recoveryServicesBackupManagement/lib/recoveryServicesBackupClient.d.ts +++ b/lib/services/recoveryServicesBackupManagement/lib/recoveryServicesBackupClient.d.ts @@ -63,6 +63,7 @@ export default class RecoveryServicesBackupClient extends AzureServiceClient { jobs: operations.Jobs; backupPolicies: operations.BackupPolicies; backupProtectedItems: operations.BackupProtectedItems; + backupProtectionIntent: operations.BackupProtectionIntent; backupUsageSummaries: operations.BackupUsageSummaries; operation: operations.Operation; backupResourceVaultConfigs: operations.BackupResourceVaultConfigs; diff --git a/lib/services/recoveryServicesBackupManagement/lib/recoveryServicesBackupClient.js b/lib/services/recoveryServicesBackupManagement/lib/recoveryServicesBackupClient.js index 0ce93c2c28..58f65a18ff 100644 --- a/lib/services/recoveryServicesBackupManagement/lib/recoveryServicesBackupClient.js +++ b/lib/services/recoveryServicesBackupManagement/lib/recoveryServicesBackupClient.js @@ -80,6 +80,7 @@ class RecoveryServicesBackupClient extends ServiceClient { this.jobs = new operations.Jobs(this); this.backupPolicies = new operations.BackupPolicies(this); this.backupProtectedItems = new operations.BackupProtectedItems(this); + this.backupProtectionIntent = new operations.BackupProtectionIntent(this); this.backupUsageSummaries = new operations.BackupUsageSummaries(this); this.operation = new operations.Operation(this); this.backupResourceVaultConfigs = new operations.BackupResourceVaultConfigs(this); diff --git a/lib/services/recoveryServicesBackupManagement/package.json b/lib/services/recoveryServicesBackupManagement/package.json index 2a338c30be..e2857105ba 100644 --- a/lib/services/recoveryServicesBackupManagement/package.json +++ b/lib/services/recoveryServicesBackupManagement/package.json @@ -14,7 +14,7 @@ "license": "MIT", "main": "./lib/recoveryServicesBackupClient.js", "types": "./lib/recoveryServicesBackupClient.d.ts", - "homepage": "https://github.com/azure/azure-sdk-for-node/lib/services/recoveryServicesBackupManagement", + "homepage": "https://github.com/azure/azure-sdk-for-node/tree/master/lib/services/recoveryServicesBackupManagement", "repository": { "type": "git", "url": "https://github.com/azure/azure-sdk-for-node.git"