private static ItemBase GetAzureSqlItemModel(ServiceClientModel.ProtectedItemResource protectedItem) { ItemBase itemModel; ServiceClientModel.AzureSqlProtectedItem azureSqlProtectedItem = (ServiceClientModel.AzureSqlProtectedItem)protectedItem.Properties; string policyName = null; string policyId = azureSqlProtectedItem.PolicyId; if (!string.IsNullOrEmpty(policyId)) { Dictionary <UriEnums, string> keyVauleDict = HelperUtils.ParseUri(policyId); policyName = HelperUtils.GetPolicyNameFromPolicyId(keyVauleDict, policyId); } string containerUri = HelperUtils.GetContainerUri( HelperUtils.ParseUri(protectedItem.Id), protectedItem.Id); itemModel = new AzureSqlItem( protectedItem, IdUtils.GetNameFromUri(containerUri), ContainerType.AzureSQL, policyName); return(itemModel); }
/// <summary> /// Lists recovery points generated for the given item /// </summary> /// <returns>List of recovery point PowerShell model objects</returns> public List <RecoveryPointBase> ListRecoveryPoints() { DateTime startDate = (DateTime)(ProviderData[RecoveryPointParams.StartDate]); DateTime endDate = (DateTime)(ProviderData[RecoveryPointParams.EndDate]); AzureSqlItem item = ProviderData[RecoveryPointParams.Item] as AzureSqlItem; 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 > maxRestoreDiskTimeRange) { throw new Exception(Resources.RestoreDiskTimeRangeError); } //we need to fetch the list of RPs var queryFilterString = QueryBuilder.Instance.GetQueryString(new BMSRPQueryObject() { StartDate = startDate, EndDate = endDate }); ODataQuery <BMSRPQueryObject> queryFilter = new ODataQuery <BMSRPQueryObject>(); queryFilter.Filter = queryFilterString; List <RecoveryPointResource> rpListResponse = ServiceClientAdapter.GetRecoveryPoints( containerUri, protectedItemName, queryFilter); return(RecoveryPointConversions.GetPSAzureRecoveryPoints(rpListResponse, item)); }
/// <summary> /// Lists recovery points generated for the given item /// </summary> /// <returns>List of recovery point PowerShell model objects</returns> public List <CmdletModel.RecoveryPointBase> ListRecoveryPoints() { DateTime startDate = (DateTime)(ProviderData[RecoveryPointParams.StartDate]); DateTime endDate = (DateTime)(ProviderData[RecoveryPointParams.EndDate]); AzureSqlItem item = ProviderData[RecoveryPointParams.Item] as AzureSqlItem; 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 > maxRestoreDiskTimeRange) { throw new Exception(Resources.RestoreDiskTimeRangeError); } //we need to fetch the list of RPs RecoveryPointQueryParameters queryFilter = new RecoveryPointQueryParameters(); queryFilter.StartDate = CommonHelpers.GetDateTimeStringForService(startDate); queryFilter.EndDate = CommonHelpers.GetDateTimeStringForService(endDate); RecoveryPointListResponse rpListResponse = null; rpListResponse = ServiceClientAdapter.GetRecoveryPoints( containerUri, protectedItemName, queryFilter); return(RecoveryPointConversions.GetPSAzureRecoveryPoints(rpListResponse, item)); }
/// <summary> /// Helper function to convert ps backup policy item from service response. /// </summary> public static ItemBase GetItemModel(ServiceClientModel.ProtectedItemResource protectedItem) { ItemBase itemModel = null; if (protectedItem != null && protectedItem.Properties != null) { if (protectedItem.Properties.GetType().IsSubclassOf(typeof(ServiceClientModel.AzureIaaSVMProtectedItem))) { string policyName = null; string policyId = ((ServiceClientModel.AzureIaaSVMProtectedItem)protectedItem.Properties).PolicyId; if (!string.IsNullOrEmpty(policyId)) { Dictionary <UriEnums, string> keyValueDict = HelperUtils.ParseUri(policyId); policyName = HelperUtils.GetPolicyNameFromPolicyId(keyValueDict, policyId); } string containerUri = HelperUtils.GetContainerUri( HelperUtils.ParseUri(protectedItem.Id), protectedItem.Id); itemModel = new AzureVmItem( protectedItem, IdUtils.GetNameFromUri(containerUri), ContainerType.AzureVM, policyName); } if (protectedItem.Properties.GetType() == typeof(ServiceClientModel.AzureSqlProtectedItem)) { ServiceClientModel.AzureSqlProtectedItem azureSqlProtectedItem = (ServiceClientModel.AzureSqlProtectedItem)protectedItem.Properties; string policyName = null; string policyId = azureSqlProtectedItem.PolicyId; if (!string.IsNullOrEmpty(policyId)) { Dictionary <UriEnums, string> keyVauleDict = HelperUtils.ParseUri(policyId); policyName = HelperUtils.GetPolicyNameFromPolicyId(keyVauleDict, policyId); } string containerUri = HelperUtils.GetContainerUri( HelperUtils.ParseUri(protectedItem.Id), protectedItem.Id); itemModel = new AzureSqlItem( protectedItem, IdUtils.GetNameFromUri(containerUri), ContainerType.AzureSQL, policyName); } } return(itemModel); }
/// <summary> /// Fetches the detail info for the given recovery point /// </summary> /// <returns>Recovery point detail as returned by the service</returns> public RecoveryPointBase GetRecoveryPointDetails() { AzureSqlItem item = ProviderData[RecoveryPointParams.Item] as AzureSqlItem; string recoveryPointId = ProviderData[RecoveryPointParams.RecoveryPointId].ToString(); Dictionary <UriEnums, string> uriDict = HelperUtils.ParseUri(item.Id); string containerUri = HelperUtils.GetContainerUri(uriDict, item.Id); string protectedItemName = HelperUtils.GetProtectedItemUri(uriDict, item.Id); var rpResponse = ServiceClientAdapter.GetRecoveryPointDetails( containerUri, protectedItemName, recoveryPointId); return(RecoveryPointConversions.GetPSAzureRecoveryPoints(rpResponse, item)); }