/// <summary> /// Constructor. Takes the service client object representing the protected item /// and converts it in to the PS protected item model /// </summary> /// <param name="protectedItemResource">Service client object representing the protected item resource</param> /// <param name="containerName">Name of the container associated with this protected item</param> /// <param name="containerType">Type of the container associated with this protected item</param> /// <param name="policyName">Name of the protection policy associated with this protected item</param> public AzureWorkloadSAPHanaDatabaseProtectedItem(CrrModel.ProtectedItemResource protectedItemResource, string containerName, ContainerType containerType, string policyName) : base(protectedItemResource, containerName, containerType, policyName) { CrrModel.AzureVmWorkloadSAPHanaDatabaseProtectedItem protectedItem = (CrrModel.AzureVmWorkloadSAPHanaDatabaseProtectedItem)protectedItemResource.Properties; FriendlyName = protectedItem.FriendlyName; ServerName = protectedItem.ServerName; ParentName = protectedItem.ParentName; ParentType = protectedItem.ParentType; if (protectedItem.LastBackupErrorDetail != null) { LastBackupErrorDetail = new ErrorDetail(protectedItem.LastBackupErrorDetail.Code, protectedItem.LastBackupErrorDetail.Message, protectedItem.LastBackupErrorDetail.Recommendations); } ProtectedItemDataSourceId = protectedItem.ProtectedItemDataSourceId; ProtectedItemHealthStatus = protectedItem.ProtectedItemHealthStatus; LastBackupStatus = protectedItem.LastBackupStatus; LastBackupTime = protectedItem.LastBackupTime; ProtectionState = EnumUtils.GetEnum <ItemProtectionState>(protectedItem.ProtectionState.ToString()); ProtectionStatus = EnumUtils.GetEnum <ItemProtectionStatus>(protectedItem.ProtectionStatus); DateOfPurge = null; DeleteState = EnumUtils.GetEnum <ItemDeleteState>("NotDeleted"); if (protectedItem.IsScheduledForDeferredDelete.HasValue) { DateOfPurge = protectedItem.DeferredDeleteTimeInUTC.Value.AddDays(14); DeleteState = EnumUtils.GetEnum <ItemDeleteState>("ToBeDeleted"); } }
private static ItemBase GetAzureVmItemModelCrr(CrrModel.ProtectedItemResource protectedItem) { ItemBase itemModel; string policyName = null; string policyId = ((CrrModel.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); return(itemModel); }
private static ItemBase GetAzureVmWorkloadSAPHanaItemModelCrr(CrrModel.ProtectedItemResource protectedItem) { ItemBase itemModel; string policyName = null; // can also be type-casted to AzureVmWorkloadProtectedItem string policyId = ((CrrModel.AzureVmWorkloadSAPHanaDatabaseProtectedItem)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 AzureWorkloadSAPHanaDatabaseProtectedItem( protectedItem, containerUri, ContainerType.AzureVMAppContainer, policyName); return(itemModel); }
/// <summary> /// Constructor. Takes the service client object representing the protected item /// and converts it in to the PS protected item model /// </summary> /// <param name="protectedItemResource">Service client object representing the protected item resource</param> /// <param name="containerName">Name of the container associated with this protected item</param> /// <param name="containerType">Type of the container associated with this protected item</param> /// <param name="policyName">Name of the protection policy associated with this protected item</param> public AzureVmItem(CrrModel.ProtectedItemResource protectedItemResource, string containerName, ContainerType containerType, string policyName) : base(protectedItemResource, containerName, containerType, policyName) { CrrModel.AzureIaaSVMProtectedItem protectedItem = (CrrModel.AzureIaaSVMProtectedItem)protectedItemResource.Properties; LastBackupStatus = protectedItem.LastBackupStatus; LastBackupTime = protectedItem.LastBackupTime; ProtectionState = EnumUtils.GetEnum <ItemProtectionState>(protectedItem.ProtectionState.ToString()); ProtectionStatus = EnumUtils.GetEnum <ItemProtectionStatus>(protectedItem.ProtectionStatus); VirtualMachineId = protectedItem.VirtualMachineId; HealthStatus = protectedItem.HealthStatus; DateOfPurge = null; DeleteState = EnumUtils.GetEnum <ItemDeleteState>("NotDeleted"); if (protectedItem.IsScheduledForDeferredDelete.HasValue) { DateOfPurge = protectedItem.DeferredDeleteTimeInUTC.Value.AddDays(14); DeleteState = EnumUtils.GetEnum <ItemDeleteState>("ToBeDeleted"); } if (protectedItem.ExtendedProperties != null && protectedItem.ExtendedProperties.DiskExclusionProperties != null) { CrrModel.DiskExclusionProperties diskExclusionProperties = protectedItem.ExtendedProperties.DiskExclusionProperties; IsInclusionList = diskExclusionProperties.IsInclusionList; DiskLunList = diskExclusionProperties.DiskLunList; } }
public AzureItem(CrrModel.ProtectedItemResource protectedItemResource, string containerName, ContainerType containerType, string policyName) : base(protectedItemResource, containerName, containerType) { ProtectionPolicyName = policyName; PolicyId = protectedItemResource.Properties.PolicyId; DeleteState = ItemDeleteState.NotDeleted; }
public ItemBase(CrrModel.ProtectedItemResource protectedItemResource, string containerName, ContainerType containerType) : base(protectedItemResource.Properties, containerName, containerType) { CrrModel.ProtectedItem protectedItem = protectedItemResource.Properties; Name = protectedItemResource.Name; Id = protectedItemResource.Id; LatestRecoveryPoint = protectedItem.LastRecoveryPoint; SourceResourceId = protectedItem.SourceResourceId; }
/// <summary> /// Helper function to convert ps backup item from service response. /// </summary> public static ItemBase GetItemModelCrr(CrrModel.ProtectedItemResource protectedItem) { ItemBase itemModel = null; if (protectedItem != null && protectedItem.Properties != null) { if (protectedItem.Properties.GetType().IsSubclassOf(typeof(CrrModel.AzureIaaSVMProtectedItem))) { itemModel = GetAzureVmItemModelCrr(protectedItem); } /*if (protectedItem.Properties.GetType() == * typeof(CrrModel.AzureFileshareProtectedItem)) * { * itemModel = GetAzureFileShareItemModel(protectedItem); * }*/ if (protectedItem.Properties.GetType() == typeof(CrrModel.AzureVmWorkloadSQLDatabaseProtectedItem)) { itemModel = GetAzureVmWorkloadItemModelCrr(protectedItem); } if (protectedItem.Properties.GetType() == typeof(CrrModel.AzureVmWorkloadSAPHanaDatabaseProtectedItem)) { itemModel = GetAzureVmWorkloadSAPHanaItemModelCrr(protectedItem); } /*if (protectedItem.Properties.GetType() == * typeof(CrrModel.MabFileFolderProtectedItem)) * { * itemModel = GetMabItemModel(protectedItem); * }*/ } return(itemModel); }