/// <summary> /// Fetches the detail info for the given recovery point /// </summary> /// <returns>Recovery point detail as returned by the service</returns> public CmdletModel.RecoveryPointBase GetRecoveryPointDetails() { CmdletModel.AzureSqlItem item = ProviderData[RecoveryPointParams.Item] as CmdletModel.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)); }
/// <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), Cmdlets.Models.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), Cmdlets.Models.ContainerType.AzureSQL, policyName); } } return itemModel; }