public override void ExecuteCmdlet() { ExecutionBlock(() => { base.ExecuteCmdlet(); Guid operationId = Guid.Empty; WriteDebug(Resources.MakingClientCall); if (!this.DeleteBackupData) { //Calling update protection with policy Id as empty. CSMUpdateProtectionRequest input = new CSMUpdateProtectionRequest() { Properties = new CSMUpdateProtectionRequestProperties(string.Empty) }; operationId = AzureBackupClient.UpdateProtection(Item.ResourceGroupName, Item.ResourceName, Item.ContainerUniqueName, Item.ItemName, input); } else { //Calling disable protection operationId = AzureBackupClient.DisableProtection(Item.ResourceGroupName, Item.ResourceName, Item.ContainerUniqueName, Item.ItemName); } WriteDebug(Resources.DisableAzureBackupProtection); var operationStatus = TrackOperation(Item.ResourceGroupName, Item.ResourceName, operationId); this.WriteObject(GetCreatedJobs(Item.ResourceGroupName, Item.ResourceName, new Models.AzureRMBackupVault(Item.ResourceGroupName, Item.ResourceName, Item.Location), operationStatus.JobList).FirstOrDefault()); }); }
//[Fact] public void UpdateAzureBackupProtectionTest() { using (UndoContext context = UndoContext.Current) { context.Start(); var client = GetServiceClient<BackupServicesManagementClient>(); CSMUpdateProtectionRequest input = new CSMUpdateProtectionRequest(); input.Properties = new CSMUpdateProtectionRequestProperties(); string itemName = ConfigurationManager.AppSettings["AzureBackupItemName"]; string containerName = ConfigurationManager.AppSettings["ContainerName"]; input.Properties.PolicyId = string.Empty; var response = client.DataSource.UpdateProtectionCSM(BackupServicesTestsBase.ResourceGroupName, BackupServicesTestsBase.ResourceName, GetCustomRequestHeaders(), containerName, itemName, input); Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); } }
/// <summary> /// Update Protection /// </summary> /// <param name="request"></param> /// <returns></returns> public Guid UpdateProtection(string resourceGroupName, string resourceName, string containerName, string itemName, CSMUpdateProtectionRequest request) { var response = AzureBackupClient.DataSource.UpdateProtectionCSMAsync(resourceGroupName, resourceName, GetCustomRequestHeaders(), containerName, itemName, request, CmdletCancellationToken).Result; return response.OperationId; }
/// <summary> /// Enable protection for given item. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.Azure.Management.BackupServices.IDataSourceOperations. /// </param> /// <param name='resourceGroupName'> /// Required. /// </param> /// <param name='resourceName'> /// Required. /// </param> /// <param name='customRequestHeaders'> /// Optional. Request header parameters. /// </param> /// <param name='containerName'> /// Required. containerName. /// </param> /// <param name='itemName'> /// Required. itemName. /// </param> /// <param name='csmparameters'> /// Required. Set protection request input. /// </param> /// <returns> /// The definition of a Operation Response. /// </returns> public static Task<OperationResponse> UpdateProtectionCSMAsync(this IDataSourceOperations operations, string resourceGroupName, string resourceName, CustomRequestHeaders customRequestHeaders, string containerName, string itemName, CSMUpdateProtectionRequest csmparameters) { return operations.UpdateProtectionCSMAsync(resourceGroupName, resourceName, customRequestHeaders, containerName, itemName, csmparameters, CancellationToken.None); }
/// <summary> /// Enable protection for given item. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.Azure.Management.BackupServices.IDataSourceOperations. /// </param> /// <param name='resourceGroupName'> /// Required. /// </param> /// <param name='resourceName'> /// Required. /// </param> /// <param name='customRequestHeaders'> /// Optional. Request header parameters. /// </param> /// <param name='containerName'> /// Required. containerName. /// </param> /// <param name='itemName'> /// Required. itemName. /// </param> /// <param name='csmparameters'> /// Required. Set protection request input. /// </param> /// <returns> /// The definition of a Operation Response. /// </returns> public static OperationResponse UpdateProtectionCSM(this IDataSourceOperations operations, string resourceGroupName, string resourceName, CustomRequestHeaders customRequestHeaders, string containerName, string itemName, CSMUpdateProtectionRequest csmparameters) { return Task.Factory.StartNew((object s) => { return ((IDataSourceOperations)s).UpdateProtectionCSMAsync(resourceGroupName, resourceName, customRequestHeaders, containerName, itemName, csmparameters); } , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); }