Esempio n. 1
0
 public DpmBackupEngine(ServiceClientModel.BackupEngineResource backupEngine)
     : base(backupEngine)
 {
     ServiceClientModel.BackupEngineBase dpmBackupEngine = (ServiceClientModel.BackupEngineBase)backupEngine.Properties;
     FriendlyName = dpmBackupEngine.FriendlyName;
     Status = dpmBackupEngine.RegistrationStatus;
 }
Esempio n. 2
0
 public AzureBackupServerEngine(ServiceClientModel.BackupEngineResource backupEngine)
     : base(backupEngine)
 {
     ServiceClientModel.AzureBackupServerEngine azureBackupServerEngine = (ServiceClientModel.AzureBackupServerEngine)backupEngine.Properties;
     FriendlyName = azureBackupServerEngine.FriendlyName;
     Status = azureBackupServerEngine.RegistrationStatus;
 }
        /// <summary>
        /// Helper function to convert ps backup engine model from service response.
        /// </summary>
        public static BackupEngineBase GetBackupEngineModel(ServiceClientModel.BackupEngineResource backupEngine)
        {
            BackupEngineBase backupEngineModel = null;

            if (backupEngine != null &&
                backupEngine.Properties != null)
            {
                if (backupEngine.Properties.GetType() == (typeof(ServiceClientModel.DpmBackupEngine)))
                {
                    backupEngineModel = new DpmBackupEngine(backupEngine);
                }
                else if (backupEngine.Properties.GetType() == (typeof(ServiceClientModel.AzureBackupServerEngine)))
                {
                    backupEngineModel = new AzureBackupServerEngine(backupEngine);
                }
            }

            return backupEngineModel;
        }
        public static SimpleRetentionPolicy GetPSSimpleRetentionPolicy(
           ServiceClientModel.SimpleRetentionPolicy hydraRetPolicy)
        {
            if (hydraRetPolicy == null)
            {
                return null;
            }

            SimpleRetentionPolicy simplePolicy = new SimpleRetentionPolicy();

            if (hydraRetPolicy.RetentionDuration != null)
            {
                simplePolicy.RetentionDurationType = EnumUtils.GetEnum<RetentionDurationType>(
                    hydraRetPolicy.RetentionDuration.DurationType);
                simplePolicy.RetentionCount = hydraRetPolicy.RetentionDuration.Count;
            }

            simplePolicy.Validate();
            return simplePolicy;
        }
        // <summary>
        /// Helper function to convert ps simple schedule policy from service response.
        /// </summary>
        public static SimpleSchedulePolicy GetPSSimpleSchedulePolicy(
            ServiceClientModel.SimpleSchedulePolicy serviceClientPolicy)
        {
            if (serviceClientPolicy == null)
            {
                return null;
            }

            SimpleSchedulePolicy psPolicy = new SimpleSchedulePolicy();

            psPolicy.ScheduleRunDays = HelperUtils.GetEnumListFromStringList<DayOfWeek>(serviceClientPolicy.ScheduleRunDays);
            psPolicy.ScheduleRunFrequency = (ScheduleRunType)Enum.Parse(typeof(ScheduleRunType),
                                                                        serviceClientPolicy.ScheduleRunFrequency);
            psPolicy.ScheduleRunTimes = ParseDateTimesToUTC(serviceClientPolicy.ScheduleRunTimes);

            // safe side validation
            psPolicy.Validate();

            return psPolicy;
        }
        // <summary>
        /// Helper function to convert ps long term retention policy from service response.
        /// </summary>
        public static LongTermRetentionPolicy GetPSLongTermRetentionPolicy(
            ServiceClientModel.LongTermRetentionPolicy serviceClientRetPolicy)
        {
            if (serviceClientRetPolicy == null)
            {
                return null;
            }

            LongTermRetentionPolicy ltrPolicy = new LongTermRetentionPolicy();

            if (serviceClientRetPolicy.DailySchedule != null)
            {
                ltrPolicy.IsDailyScheduleEnabled = true;
                ltrPolicy.DailySchedule = GetPSLTRDailySchedule(serviceClientRetPolicy.DailySchedule);
            }

            if (serviceClientRetPolicy.WeeklySchedule != null)
            {
                ltrPolicy.IsWeeklyScheduleEnabled = true;
                ltrPolicy.WeeklySchedule = GetPSLTRWeeklySchedule(serviceClientRetPolicy.WeeklySchedule);
            }

            if (serviceClientRetPolicy.MonthlySchedule != null)
            {
                ltrPolicy.IsMonthlyScheduleEnabled = true;
                ltrPolicy.MonthlySchedule = GetPSLTRMonthlySchedule(serviceClientRetPolicy.MonthlySchedule);
            }

            if (serviceClientRetPolicy.YearlySchedule != null)
            {
                ltrPolicy.IsYearlyScheduleEnabled = true;
                ltrPolicy.YearlySchedule = GetPSLTRYearlySchedule(serviceClientRetPolicy.YearlySchedule);
            }

            // safe side validate
            ltrPolicy.Validate();

            return ltrPolicy;
        }
        /// <summary>
        /// Helper function to convert ps backup container model from service response.
        /// </summary>
        public static ContainerBase GetContainerModel(ServiceClientModel.ProtectionContainerResource protectionContainer)
        {
            ContainerBase containerModel = null;

            if (protectionContainer != null &&
                protectionContainer.Properties != null)
            {
                if (protectionContainer.Properties.GetType().IsSubclassOf(typeof(ServiceClientModel.AzureIaaSVMProtectionContainer)))
                {
                    containerModel = new AzureVmContainer(protectionContainer);
                }
                if (protectionContainer.Properties.GetType() == typeof(ServiceClientModel.MabProtectionContainer))
                {
                    containerModel = new MabContainer(protectionContainer);
                }
                else if (protectionContainer.Properties.GetType() ==
                    typeof(ServiceClientModel.AzureSqlProtectionContainer))
                {
                    containerModel = new AzureSqlContainer(protectionContainer);
                }
            }

            return containerModel;
        }
        private static DailyRetentionFormat GetPSLTRDailyRetentionFormat(
                                            ServiceClientModel.DailyRetentionFormat serviceClientFormat)
        {
            if (serviceClientFormat == null)
            {
                return null;
            }

            DailyRetentionFormat psFormat = new DailyRetentionFormat();

            if (serviceClientFormat.DaysOfTheMonth != null)
            {
                psFormat.DaysOfTheMonth = new List<Day>();

                foreach (ServiceClientModel.Day serviceClientDay in serviceClientFormat.DaysOfTheMonth)
                {
                    Day psDay = new Day()
                    {
                        Date = serviceClientDay.Date,
                        IsLast = serviceClientDay.IsLast
                    };

                    psFormat.DaysOfTheMonth.Add(psDay);
                }
            }

            return psFormat;
        }
        /// <summary>
        /// Helper function to convert ps backup policy list model from service response.
        /// </summary>
        public static List<PolicyBase> GetPolicyModelList(
            ServiceClientModel.ProtectionPolicyListResponse serviceClientListResponse)
        {
            if (serviceClientListResponse == null || serviceClientListResponse.ItemList == null ||
               serviceClientListResponse.ItemList.Value == null || serviceClientListResponse.ItemList.Value.Count == 0)
            {
                Logger.Instance.WriteDebug("Received empty list of policies from service");
                return null;
            }

            List<PolicyBase> policyModels = new List<PolicyBase>();
            PolicyBase policyModel = null;

            foreach (ServiceClientModel.ProtectionPolicyResource resource in serviceClientListResponse.ItemList.Value)
            {
                policyModel = GetPolicyModel(resource);
                if (policyModel != null)
                {
                    policyModels.Add(policyModel);
                }
            }

            Logger.Instance.WriteDebug("Total policies in list: " + policyModels.Count);
            return policyModels;
        }
Esempio n. 10
0
        /// <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;
        }
        /// <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;
        }
Esempio n. 12
0
        /// <summary>
        /// Helper function to convert ps backup policy model from service response.
        /// </summary>
        public static PolicyBase GetPolicyModel(ServiceClientModel.ProtectionPolicyResource serviceClientResponse)
        {
            PolicyBase policyModel = null;

            if (serviceClientResponse == null || serviceClientResponse.Properties == null)
            {
                Logger.Instance.WriteDebug("Policy Service Client response is Null/Empty");
                throw new ArgumentException(Resources.EmptyServiceClientResponseException);
            }

            if (serviceClientResponse.Properties.GetType() == typeof(ServiceClientModel.AzureIaaSVMProtectionPolicy))
            {
                if (((ServiceClientModel.AzureIaaSVMProtectionPolicy)serviceClientResponse.Properties).RetentionPolicy.GetType() !=
                                                                           typeof(ServiceClientModel.LongTermRetentionPolicy))
                {
                    Logger.Instance.WriteDebug("Unknown RetentionPolicy object received: " +
                               ((ServiceClientModel.AzureIaaSVMProtectionPolicy)serviceClientResponse.Properties).RetentionPolicy.GetType());
                    Logger.Instance.WriteWarning(Resources.UpdateToNewAzurePowershellWarning);
                    return null;
                }

                if (((ServiceClientModel.AzureIaaSVMProtectionPolicy)serviceClientResponse.Properties).SchedulePolicy.GetType() !=
                                                                            typeof(ServiceClientModel.SimpleSchedulePolicy))
                {
                    Logger.Instance.WriteDebug("Unknown SchedulePolicy object received: " +
                               ((ServiceClientModel.AzureIaaSVMProtectionPolicy)serviceClientResponse.Properties).SchedulePolicy.GetType());
                    Logger.Instance.WriteWarning(Resources.UpdateToNewAzurePowershellWarning);
                    return null;
                }

                policyModel = new AzureVmPolicy();
                AzureVmPolicy iaasPolicyModel = policyModel as AzureVmPolicy;
                iaasPolicyModel.WorkloadType = Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models.WorkloadType.AzureVM;
                iaasPolicyModel.BackupManagementType = Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models.BackupManagementType.AzureVM;
                iaasPolicyModel.RetentionPolicy = PolicyHelpers.GetPSLongTermRetentionPolicy((ServiceClientModel.LongTermRetentionPolicy)
                                                  ((ServiceClientModel.AzureIaaSVMProtectionPolicy)serviceClientResponse.Properties).RetentionPolicy);
                iaasPolicyModel.SchedulePolicy = PolicyHelpers.GetPSSimpleSchedulePolicy((ServiceClientModel.SimpleSchedulePolicy)
                                                 ((ServiceClientModel.AzureIaaSVMProtectionPolicy)serviceClientResponse.Properties).SchedulePolicy);
            }
            else if (serviceClientResponse.Properties.GetType() ==
                typeof(ServiceClientModel.AzureSqlProtectionPolicy))
            {
                ServiceClientModel.AzureSqlProtectionPolicy azureSqlPolicy =
                    (ServiceClientModel.AzureSqlProtectionPolicy)serviceClientResponse.Properties;

                if (azureSqlPolicy.RetentionPolicy.GetType() !=
                    typeof(ServiceClientModel.SimpleRetentionPolicy))
                {
                    Logger.Instance.WriteDebug("Unknown RetentionPolicy object received: " +
                        azureSqlPolicy.RetentionPolicy.GetType());
                    Logger.Instance.WriteWarning(Resources.UpdateToNewAzurePowershellWarning);
                    return null;
                }

                policyModel = new AzureSqlPolicy();
                AzureSqlPolicy sqlPolicyModel = policyModel as AzureSqlPolicy;
                sqlPolicyModel.WorkloadType = CmdletModels.WorkloadType.AzureSQLDatabase;
                sqlPolicyModel.BackupManagementType = CmdletModels.BackupManagementType.AzureSQL;

                ServiceClientModel.SimpleRetentionPolicy azureSqlRetentionPolicy =
                    (ServiceClientModel.SimpleRetentionPolicy)azureSqlPolicy.RetentionPolicy;
                sqlPolicyModel.RetentionPolicy =
                    PolicyHelpers.GetPSSimpleRetentionPolicy(azureSqlRetentionPolicy);
            }
            else
            {
                // we will enter this case when service supports new workload and customer 
                // still using old version of azure powershell. Trace warning message, ignore and return
                Logger.Instance.WriteDebug("Unknown Policy object received: " +
                                           serviceClientResponse.Properties.GetType());
                Logger.Instance.WriteWarning(Resources.UpdateToNewAzurePowershellWarning);
                return null;
            }

            policyModel.Name = serviceClientResponse.Name;
            policyModel.Id = serviceClientResponse.Id;

            return policyModel;
        }
        private static DailyRetentionSchedule GetPSLTRDailySchedule(ServiceClientModel.DailyRetentionSchedule serviceClientDaily)
        {
            if (serviceClientDaily == null)
            {
                return null;
            }

            DailyRetentionSchedule psDaily = new DailyRetentionSchedule();

            psDaily.DurationCountInDays = GetRetentionDurationInDays(serviceClientDaily.RetentionDuration);
            psDaily.RetentionTimes = ParseDateTimesToUTC(serviceClientDaily.RetentionTimes);

            return psDaily;
        }
        private static int GetRetentionDurationInYears(ServiceClientModel.RetentionDuration retentionDuration)
        {
            int yearsCount = 0;

            switch (retentionDuration.DurationType)
            {
                case ServiceClientModel.RetentionDurationType.Days:
                    yearsCount = retentionDuration.Count / PolicyConstants.NumOfDaysInYear;
                    break;

                case ServiceClientModel.RetentionDurationType.Weeks:
                    yearsCount = retentionDuration.Count / PolicyConstants.NumOfWeeksInYear;
                    break;

                case ServiceClientModel.RetentionDurationType.Months:
                    yearsCount = retentionDuration.Count / PolicyConstants.NumOfMonthsInYear;
                    break;

                case ServiceClientModel.RetentionDurationType.Years:
                    yearsCount = retentionDuration.Count;
                    break;

                default:
                    throw new ArgumentException(Resources.InvalidDurationTypeException,
                                                retentionDuration.DurationType.ToString());
            }

            return yearsCount;
        }
Esempio n. 15
0
 public ItemContext(ServiceClientModel.ProtectedItem protectedItem,
     string containerName, ContainerType containerType)
     : base(containerType, protectedItem.BackupManagementType)
 {
     WorkloadType = ConversionUtils.GetPsWorkloadType(protectedItem.WorkloadType);
     ContainerName = containerName;
 }
Esempio n. 16
0
 public ContainerBase(ServiceClientModel.ProtectionContainerResource protectionContainer)
     : base(ConversionUtils.GetPsContainerType(((ServiceClientModel.ProtectionContainer)protectionContainer.Properties).ContainerType),
            ((ServiceClientModel.ProtectionContainer)protectionContainer.Properties).BackupManagementType)
 {
     Name = IdUtils.GetNameFromUri(protectionContainer.Name);
 }
        private static YearlyRetentionSchedule GetPSLTRYearlySchedule(ServiceClientModel.YearlyRetentionSchedule serviceClientYearly)
        {
            if (serviceClientYearly == null)
            {
                return null;
            }

            YearlyRetentionSchedule psYearly = new YearlyRetentionSchedule();

            psYearly.DurationCountInYears = GetRetentionDurationInYears(serviceClientYearly.RetentionDuration);
            psYearly.RetentionTimes = ParseDateTimesToUTC(serviceClientYearly.RetentionTimes);
            psYearly.RetentionScheduleFormatType = (RetentionScheduleFormat)Enum.Parse(typeof(RetentionScheduleFormat),
                                                                                   serviceClientYearly.RetentionScheduleFormatType);
            psYearly.RetentionScheduleDaily = GetPSLTRDailyRetentionFormat(serviceClientYearly.RetentionScheduleDaily);
            psYearly.RetentionScheduleWeekly = GetPSLTRWeeklyRetentionFormat(serviceClientYearly.RetentionScheduleWeekly);
            psYearly.MonthsOfYear = HelperUtils.GetEnumListFromStringList<Month>(serviceClientYearly.MonthsOfYear);

            return psYearly;
        }
        private static MonthlyRetentionSchedule GetPSLTRMonthlySchedule(ServiceClientModel.MonthlyRetentionSchedule serviceClientMonthly)
        {
            if (serviceClientMonthly == null)
            {
                return null;
            }

            MonthlyRetentionSchedule psMonthly = new MonthlyRetentionSchedule();

            psMonthly.DurationCountInMonths = GetRetentionDurationInMonths(serviceClientMonthly.RetentionDuration);
            psMonthly.RetentionTimes = ParseDateTimesToUTC(serviceClientMonthly.RetentionTimes);
            psMonthly.RetentionScheduleFormatType = (RetentionScheduleFormat)Enum.Parse(typeof(RetentionScheduleFormat),
                                                                                   serviceClientMonthly.RetentionScheduleFormatType);
            psMonthly.RetentionScheduleDaily = GetPSLTRDailyRetentionFormat(serviceClientMonthly.RetentionScheduleDaily);
            psMonthly.RetentionScheduleWeekly = GetPSLTRWeeklyRetentionFormat(serviceClientMonthly.RetentionScheduleWeekly);

            return psMonthly;
        }
        private static WeeklyRetentionSchedule GetPSLTRWeeklySchedule(ServiceClientModel.WeeklyRetentionSchedule serviceClientWeekly)
        {
            if (serviceClientWeekly == null)
            {
                return null;
            }

            WeeklyRetentionSchedule psWeekly = new WeeklyRetentionSchedule();

            psWeekly.DurationCountInWeeks = GetRetentionDurationInWeeks(serviceClientWeekly.RetentionDuration);
            psWeekly.RetentionTimes = ParseDateTimesToUTC(serviceClientWeekly.RetentionTimes);
            psWeekly.DaysOfTheWeek = HelperUtils.GetEnumListFromStringList<DayOfWeek>(serviceClientWeekly.DaysOfTheWeek);

            return psWeekly;
        }
Esempio n. 20
0
 public BackupEngineBase(ServiceClientModel.BackupEngineResource backupEngine)
     : base(((ServiceClientModel.BackupEngineBase)backupEngine.Properties).BackupEngineType,
            ((ServiceClientModel.BackupEngineBase)backupEngine.Properties).BackupManagementType)
 {
     Name = backupEngine.Name;
 }
        private static WeeklyRetentionFormat GetPSLTRWeeklyRetentionFormat(
                                             ServiceClientModel.WeeklyRetentionFormat serviceClientFormat)
        {
            if (serviceClientFormat == null)
            {
                return null;
            }

            WeeklyRetentionFormat psFormat = new WeeklyRetentionFormat();
            if (serviceClientFormat.DaysOfTheWeek != null)
            {
                psFormat.DaysOfTheWeek = HelperUtils.GetEnumListFromStringList<DayOfWeek>(serviceClientFormat.DaysOfTheWeek);
            }
            if (serviceClientFormat.WeeksOfTheMonth != null)
            {
                psFormat.WeeksOfTheMonth = HelperUtils.GetEnumListFromStringList<WeekOfMonth>(serviceClientFormat.WeeksOfTheMonth);
            }

            return psFormat;
        }
Esempio n. 22
0
 public ItemBase(ServiceClientModel.ProtectedItemResource protectedItemResource,
     string containerName, ContainerType containerType)
     : base((ServiceClientModel.ProtectedItem)protectedItemResource.Properties, containerName, containerType)
 {
     ServiceClientModel.ProtectedItem protectedItem = (ServiceClientModel.ProtectedItem)protectedItemResource.Properties;
     Name = protectedItemResource.Name;
     Id = protectedItemResource.Id;
     LatestRecoveryPoint = protectedItem.LastRecoveryPoint;
     SourceResourceId = protectedItem.SourceResourceId;
 }
 // <summary>
 /// Helper function to convert ps simple retention policy from service response.
 /// </summary>
 public static LongTermRetentionPolicy GetPSSimpleRetentionPolicy(
    ServiceClientModel.SimpleRetentionPolicy serviceClientRetPolicy)
 {
     throw new NotSupportedException();
 }