public List <SQLDataDirectory> GetDataDirectory(string vaultName, string resourceGroupName, string itemId, DateTime pointInTime) { Dictionary <UriEnums, string> uriDict = HelperUtils.ParseUri(itemId); string containerUri = HelperUtils.GetContainerUri(uriDict, itemId); string protectedItemName = HelperUtils.GetProtectedItemUri(uriDict, itemId); var queryFilterString = QueryBuilder.Instance.GetQueryString(new BMSRPQueryObject() { RestorePointQueryType = RestorePointQueryType.Log, ExtendedInfo = true }); ODataQuery <BMSRPQueryObject> queryFilter = new ODataQuery <BMSRPQueryObject>(); queryFilter.Filter = queryFilterString; var rpResponse = ServiceClientAdapter.GetRecoveryPoints( containerUri, protectedItemName, queryFilter, vaultName: vaultName, resourceGroupName: resourceGroupName); List <SQLDataDirectory> dataDirectoryPaths = new List <SQLDataDirectory>(); if (rpResponse[0].Properties.GetType() == typeof(AzureWorkloadSQLPointInTimeRecoveryPoint)) { AzureWorkloadSQLPointInTimeRecoveryPoint recoveryPoint = rpResponse[0].Properties as AzureWorkloadSQLPointInTimeRecoveryPoint; if (recoveryPoint.ExtendedInfo != null) { foreach (SQLDataDirectory dataDirectoryPath in recoveryPoint.ExtendedInfo.DataDirectoryPaths) { dataDirectoryPaths.Add(dataDirectoryPath); } } } return(dataDirectoryPaths); }
public List <PointInTimeBase> ListLogChains(Dictionary <Enum, object> ProviderData) { string vaultName = (string)ProviderData[VaultParams.VaultName]; string resourceGroupName = (string)ProviderData[VaultParams.ResourceGroupName]; DateTime startDate = (DateTime)(ProviderData[RecoveryPointParams.StartDate]); DateTime endDate = (DateTime)(ProviderData[RecoveryPointParams.EndDate]); string restorePointQueryType = (string)ProviderData[RecoveryPointParams.RestorePointQueryType]; ItemBase item = ProviderData[RecoveryPointParams.Item] as ItemBase; Dictionary <UriEnums, string> uriDict = HelperUtils.ParseUri(item.Id); string containerUri = HelperUtils.GetContainerUri(uriDict, item.Id); string protectedItemName = HelperUtils.GetProtectedItemUri(uriDict, item.Id); TimeSpan duration = endDate - startDate; if (duration.TotalDays > 30) { throw new Exception(Resources.RestoreDiskTimeRangeError); } //we need to fetch the list of RPs var queryFilterString = QueryBuilder.Instance.GetQueryString(new BMSRPQueryObject() { ExtendedInfo = true, StartDate = startDate, EndDate = endDate, RestorePointQueryType = restorePointQueryType }); ODataQuery <BMSRPQueryObject> queryFilter = new ODataQuery <BMSRPQueryObject>(); queryFilter.Filter = queryFilterString; List <RecoveryPointResource> rpListResponse = ServiceClientAdapter.GetRecoveryPoints( containerUri, protectedItemName, queryFilter, vaultName: vaultName, resourceGroupName: resourceGroupName); List <PointInTimeBase> timeRanges = new List <PointInTimeBase>(); foreach (RecoveryPointResource rp in rpListResponse) { if (rp.Properties.GetType() == typeof(AzureWorkloadSQLPointInTimeRecoveryPoint)) { AzureWorkloadSQLPointInTimeRecoveryPoint recoveryPoint = rp.Properties as AzureWorkloadSQLPointInTimeRecoveryPoint; foreach (PointInTimeRange timeRange in recoveryPoint.TimeRanges) { timeRanges.Add(new PointInTimeBase() { StartTime = timeRange.StartTime, EndTime = timeRange.EndTime, ItemName = item.Name }); } } } return(timeRanges); }
public List <PointInTimeBase> ListLogChains(Dictionary <Enum, object> ProviderData) { string vaultName = (string)ProviderData[VaultParams.VaultName]; string resourceGroupName = (string)ProviderData[VaultParams.ResourceGroupName]; DateTime startDate = (DateTime)(ProviderData[RecoveryPointParams.StartDate]); DateTime endDate = (DateTime)(ProviderData[RecoveryPointParams.EndDate]); string restorePointQueryType = (string)ProviderData[RecoveryPointParams.RestorePointQueryType]; bool secondaryRegion = (bool)ProviderData[CRRParams.UseSecondaryRegion]; ItemBase item = ProviderData[RecoveryPointParams.Item] as ItemBase; Dictionary <UriEnums, string> uriDict = HelperUtils.ParseUri(item.Id); string containerUri = HelperUtils.GetContainerUri(uriDict, item.Id); string protectedItemName = HelperUtils.GetProtectedItemUri(uriDict, item.Id); //we need to fetch the list of RPs var queryFilterString = QueryBuilder.Instance.GetQueryString(new BMSRPQueryObject() { ExtendedInfo = true, StartDate = startDate, EndDate = endDate, RestorePointQueryType = restorePointQueryType }); List <PointInTimeBase> timeRanges = new List <PointInTimeBase>(); if (secondaryRegion) { ODataQuery <CrrModel.BMSRPQueryObject> queryFilter = new ODataQuery <CrrModel.BMSRPQueryObject>(); queryFilter.Filter = queryFilterString; //fetch recovery points Log Chain from secondary region List <CrrModel.RecoveryPointResource> rpListResponse = ServiceClientAdapter.GetRecoveryPointsFromSecondaryRegion( containerUri, protectedItemName, queryFilter, vaultName: vaultName, resourceGroupName: resourceGroupName); foreach (CrrModel.RecoveryPointResource rp in rpListResponse) { if (rp.Properties.GetType() == typeof(CrrModel.AzureWorkloadSQLPointInTimeRecoveryPoint)) { CrrModel.AzureWorkloadSQLPointInTimeRecoveryPoint recoveryPoint = rp.Properties as CrrModel.AzureWorkloadSQLPointInTimeRecoveryPoint; foreach (CrrModel.PointInTimeRange timeRange in recoveryPoint.TimeRanges) { timeRanges.Add(new PointInTimeBase() { StartTime = timeRange.StartTime, EndTime = timeRange.EndTime, ItemName = item.Name }); } } } } else { ODataQuery <BMSRPQueryObject> queryFilter = new ODataQuery <BMSRPQueryObject>(); queryFilter.Filter = queryFilterString; List <RecoveryPointResource> rpListResponse = ServiceClientAdapter.GetRecoveryPoints( containerUri, protectedItemName, queryFilter, vaultName: vaultName, resourceGroupName: resourceGroupName); foreach (RecoveryPointResource rp in rpListResponse) { if (rp.Properties.GetType() == typeof(AzureWorkloadSQLPointInTimeRecoveryPoint)) { AzureWorkloadSQLPointInTimeRecoveryPoint recoveryPoint = rp.Properties as AzureWorkloadSQLPointInTimeRecoveryPoint; foreach (PointInTimeRange timeRange in recoveryPoint.TimeRanges) { timeRanges.Add(new PointInTimeBase() { StartTime = timeRange.StartTime, EndTime = timeRange.EndTime, ItemName = item.Name }); } } } } return(timeRanges); }