public virtual Response Restore(DeletedShare deletedShare, CancellationToken cancellationToken = default) { Argument.AssertNotNull(deletedShare, nameof(deletedShare)); using var scope = _fileShareClientDiagnostics.CreateScope("FileShareResource.Restore"); scope.Start(); try { var response = _fileShareRestClient.Restore(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Name, deletedShare, cancellationToken); return(response); } catch (Exception e) { scope.Failed(e); throw; } }
public async Task RestoreFileShare() { //enable soft delete in service property FileServiceData parameter = new FileServiceData() { ShareDeleteRetentionPolicy = new DeleteRetentionPolicy() { Enabled = true, Days = 5 } }; _fileService = (await _fileService.CreateOrUpdateAsync(true, parameter)).Value; //create file share string fileShareName = Recording.GenerateAssetName("testfileshare"); FileShare share1 = (await _fileShareCollection.CreateOrUpdateAsync(true, fileShareName, new FileShareData())).Value; Assert.AreEqual(share1.Id.Name, fileShareName); //delete this share await share1.DeleteAsync(true); //get the deleted share version string deletedShareVersion = null; List <FileShare> fileShares = await _fileShareCollection.GetAllAsync(expand : "deleted").ToEnumerableAsync(); deletedShareVersion = fileShares[0].Data.Version; //restore file share //Don't need sleep when playback, or test will be very slow. Need sleep when live and record. if (Mode != RecordedTestMode.Playback) { await Task.Delay(30000); } DeletedShare deletedShare = new DeletedShare(fileShareName, deletedShareVersion); await share1.RestoreAsync(deletedShare); //validate fileShares = await _fileShareCollection.GetAllAsync().ToEnumerableAsync(); Assert.AreEqual(fileShares.Count, 1); }
public virtual Response Restore(DeletedShare deletedShare, CancellationToken cancellationToken = default) { if (deletedShare == null) { throw new ArgumentNullException(nameof(deletedShare)); } using var scope = _clientDiagnostics.CreateScope("FileShare.Restore"); scope.Start(); try { var response = _restClient.Restore(Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, deletedShare, cancellationToken); return(response); } catch (Exception e) { scope.Failed(e); throw; } }
public async virtual Task <Response> RestoreAsync(DeletedShare deletedShare, CancellationToken cancellationToken = default) { if (deletedShare == null) { throw new ArgumentNullException(nameof(deletedShare)); } using var scope = _fileShareClientDiagnostics.CreateScope("FileShare.Restore"); scope.Start(); try { var response = await _fileShareRestClient.RestoreAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Name, deletedShare, cancellationToken).ConfigureAwait(false); return(response); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual Response Restore(string resourceGroupName, string accountName, string shareName, DeletedShare deletedShare, CancellationToken cancellationToken = default) { using var scope = _clientDiagnostics.CreateScope("FileSharesOperations.Restore"); scope.Start(); try { return(RestClient.Restore(resourceGroupName, accountName, shareName, deletedShare, cancellationToken)); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual async Task <Response> RestoreAsync(string resourceGroupName, string accountName, string shareName, DeletedShare deletedShare, CancellationToken cancellationToken = default) { using var scope = _clientDiagnostics.CreateScope("FileSharesClient.Restore"); scope.Start(); try { return(await RestClient.RestoreAsync(resourceGroupName, accountName, shareName, deletedShare, cancellationToken).ConfigureAwait(false)); } catch (Exception e) { scope.Failed(e); throw; } }