public async Task <RecoveryPointList> ListRecoveryPoints(string dpmServer, string protectionGroup, string vmId, string userName, string password) { RecoveryPointList recoveryPoints = new RecoveryPointList(); Collection <PSObject> returnData = await this.RunScriptAsync(PowerShellCommandFactory.GetListDataSourceRecoveryPointsScript(dpmServer, protectionGroup, vmId), dpmServer, userName, password); foreach (PSObject obj in returnData) { RecoveryPoint point = new RecoveryPoint(); Guid id; bool result = Guid.TryParse((string)obj.Members["ComponentName"].Value, out id); if (result) { point.VmId = id; } else { continue; } point.RecoveryPointId = (Guid)obj.Members["RecoverySourceId"].Value; point.RepresentedPointInTime = (DateTime)obj.Members["RepresentedPointInTime"].Value; point.Location = ((PSObject)obj.Members["Location"].Value).ToString(); recoveryPoints.Add(point); } return(recoveryPoints); }
public async Task <List <RecoveryPoint> > ListRecoveryPoints(string subscriptionId, string vmId) { var requestUrl = this.CreateRequestUri(string.Format(CultureInfo.InvariantCulture, VmBackupClient.TenantVirtualMachine, subscriptionId, vmId)); RecoveryPointList recoveryPoints = await this.restClient.GetResourceAsync <RecoveryPointList, VmBackupErrorResource>(requestUrl) .HandleException <RecoveryPointList>(this.HandleAggregateException); return(recoveryPoints.ToList()); }
public async Task <RecoveryPointList> ListVirtualMachineRestorePoints(string subscriptionId, string id) { try { Guid subId = Validator.ValidateSubscriptionId(subscriptionId); Guid vmId = Guid.Parse(id); VmBackupTarget target = await this.configStorageClient.SelectProtetionGroupByVirtualmachineAsync <VmBackupTarget>(subId, vmId, VirtualMachineMapping.CreateVmBackupTarget); RecoveryPointList recoveryPoints = await this.dpmServerClient.ListRecoveryPoints(target.BackupServerName, target.ProtectionGroupName, id, target.UserName, target.Password); return(recoveryPoints); } catch (Exception e) { VmBackupLog.Current.WriteErrorMessage("ListVirtualMachineRestorePoints", VmBackupEventId.UnexpectedTenantException, e, subscriptionId); string message = ErrorMessages.ListVirtualMachineRestorePointsFailed; throw Utility.CreateHttpResponseException(message, HttpStatusCode.BadRequest); } }