public List <CmdletModel.RecoveryPointBase> ListRecoveryPoints(Dictionary <Enum, object> ProviderData) { string vaultName = (string)ProviderData[CmdletModel.VaultParams.VaultName]; string resourceGroupName = (string)ProviderData[CmdletModel.VaultParams.ResourceGroupName]; DateTime startDate = (DateTime)(ProviderData[CmdletModel.RecoveryPointParams.StartDate]); DateTime endDate = (DateTime)(ProviderData[CmdletModel.RecoveryPointParams.EndDate]); CmdletModel.ItemBase item = ProviderData[CmdletModel.RecoveryPointParams.Item] as CmdletModel.ItemBase; Dictionary <CmdletModel.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() { StartDate = startDate, EndDate = endDate }); ODataQuery <BMSRPQueryObject> queryFilter = new ODataQuery <BMSRPQueryObject>(); queryFilter.Filter = queryFilterString; List <RecoveryPointResource> rpListResponse = ServiceClientAdapter.GetRecoveryPoints( containerUri, protectedItemName, queryFilter, vaultName: vaultName, resourceGroupName: resourceGroupName); return(RecoveryPointConversions.GetPSAzureRecoveryPoints(rpListResponse, item)); }
public CmdletModel.RecoveryPointBase GetRecoveryPointDetails(Dictionary <Enum, object> ProviderData) { string vaultName = (string)ProviderData[CmdletModel.VaultParams.VaultName]; string resourceGroupName = (string)ProviderData[CmdletModel.VaultParams.ResourceGroupName]; CmdletModel.ItemBase item = ProviderData[CmdletModel.RecoveryPointParams.Item] as CmdletModel.ItemBase; string recoveryPointId = ProviderData[CmdletModel.RecoveryPointParams.RecoveryPointId].ToString(); Dictionary <CmdletModel.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, vaultName: vaultName, resourceGroupName: resourceGroupName); return(RecoveryPointConversions.GetPSAzureRecoveryPoints(rpResponse, item)); }
private void ValidateAzureVMDisableProtectionRequest(ItemBase itemBase) { if (itemBase == null || itemBase.GetType() != typeof(AzureVmItem)) { throw new ArgumentException(string.Format(Resources.InvalidProtectionPolicyException, typeof(AzureVmItem).ToString())); } if (string.IsNullOrEmpty(((AzureVmItem)itemBase).VirtualMachineId)) { throw new ArgumentException(Resources.VirtualMachineIdIsEmptyOrNull); } ValidateAzureVMWorkloadType(itemBase.WorkloadType); ValidateAzureVMContainerType(itemBase.ContainerType); }
private void ValidateAzureVMModifyProtectionRequest(ItemBase itemBase, PolicyBase policy) { if (itemBase == null || itemBase.GetType() != typeof(AzureVmItem)) { throw new ArgumentException(string.Format(Resources.InvalidProtectionPolicyException, typeof(AzureVmItem).ToString())); } if (string.IsNullOrEmpty(((AzureVmItem)itemBase).VirtualMachineId)) { throw new ArgumentException(Resources.VirtualMachineIdIsEmptyOrNull); } }
/// <summary> /// Helper function to convert ps recovery points list model from service response. /// </summary> public static List<RecoveryPointBase> GetPSAzureRecoveryPoints( ServiceClientModel.RecoveryPointListResponse rpList, ItemBase item) { if (rpList == null || rpList.RecoveryPointList == null || rpList.RecoveryPointList.RecoveryPoints == null) { throw new ArgumentNullException("RPList"); } Dictionary<UriEnums, string> uriDict = HelperUtils.ParseUri(item.Id); string containerUri = HelperUtils.GetContainerUri(uriDict, item.Id); string protectedItemName = HelperUtils.GetProtectedItemUri(uriDict, item.Id); List<RecoveryPointBase> result = new List<RecoveryPointBase>(); foreach (ServiceClientModel.RecoveryPointResource rp in rpList.RecoveryPointList.RecoveryPoints) { if (rp.Properties.GetType() == typeof(ServiceClientModel.RecoveryPoint)) { ServiceClientModel.RecoveryPoint recPoint = rp.Properties as ServiceClientModel.RecoveryPoint; DateTime recPointTime = DateTime.ParseExact( recPoint.RecoveryPointTime, @"MM/dd/yyyy HH:mm:ss", CultureInfo.InvariantCulture); AzureVmRecoveryPoint rpBase = new AzureVmRecoveryPoint() { RecoveryPointId = rp.Name, BackupManagementType = item.BackupManagementType, ItemName = protectedItemName, ContainerName = containerUri, ContainerType = item.ContainerType, RecoveryPointTime = recPointTime, RecoveryPointType = recPoint.RecoveryPointType, Id = rp.Id, WorkloadType = item.WorkloadType, RecoveryPointAdditionalInfo = recPoint.RecoveryPointAdditionalInfo, SourceVMStorageType = recPoint.SourceVMStorageType, SourceResourceId = item.SourceResourceId, EncryptionEnabled = recPoint.IsSourceVMEncrypted.HasValue ? recPoint.IsSourceVMEncrypted.Value : false, IlrSessionActive = recPoint.IsInstantILRSessionActive, }; if (rpBase.EncryptionEnabled) { rpBase.KeyAndSecretDetails = new KeyAndSecretDetails() { SecretUrl = recPoint.KeyAndSecret.BekDetails.SecretUrl, KeyUrl = recPoint.KeyAndSecret.KekDetails.KeyUrl, SecretData = recPoint.KeyAndSecret.BekDetails.SecretData, KeyBackupData = recPoint.KeyAndSecret.KekDetails.KeyBackupData, KeyVaultId = recPoint.KeyAndSecret.KekDetails.KeyVaultId, SecretVaultId = recPoint.KeyAndSecret.BekDetails.SecretVaultId, }; } result.Add(rpBase); } if (rp.Properties.GetType() == typeof(ServiceClientModel.GenericRecoveryPoint)) { ServiceClientModel.GenericRecoveryPoint recPoint = rp.Properties as ServiceClientModel.GenericRecoveryPoint; DateTime recPointTime = DateTime.ParseExact( recPoint.RecoveryPointTime, @"MM/dd/yyyy HH:mm:ss", CultureInfo.InvariantCulture); AzureSqlRecoveryPoint rpBase = new AzureSqlRecoveryPoint() { RecoveryPointId = rp.Name, BackupManagementType = item.BackupManagementType, ItemName = protectedItemName, ContainerName = containerUri, ContainerType = item.ContainerType, RecoveryPointTime = recPointTime, RecoveryPointType = recPoint.RecoveryPointType, Id = rp.Id, WorkloadType = item.WorkloadType, RecoveryPointAdditionalInfo = recPoint.RecoveryPointAdditionalInfo, FriendlyName = recPoint.FriendlyName, }; result.Add(rpBase); } } return result; }
private void ValidateAzureSQLDisableProtectionRequest(ItemBase itemBase) { if (itemBase == null || itemBase.GetType() != typeof(AzureSqlItem)) { throw new ArgumentException( string.Format( Resources.InvalidProtectionItemException, typeof(AzureSqlItem).ToString())); } ValidateAzureSqlWorkloadType(itemBase.WorkloadType); ValidateAzureSqlContainerType(itemBase.ContainerType); }