Пример #1
0
 internal Metrics(string version, bool enabled, bool?includeAPIs, RetentionPolicy retentionPolicy)
 {
     Version         = version;
     Enabled         = enabled;
     IncludeAPIs     = includeAPIs;
     RetentionPolicy = retentionPolicy;
 }
Пример #2
0
 public StreamConfigurationBuilder(StreamConfiguration sc)
 {
     if (sc == null)
     {
         return;
     }
     _name        = sc.Name;
     _description = sc.Description;
     WithSubjects(sc.Subjects); // handles null
     _retentionPolicy   = sc.RetentionPolicy;
     _maxConsumers      = sc.MaxConsumers;
     _maxMsgs           = sc.MaxMsgs;
     _maxMsgsPerSubject = sc.MaxMsgsPerSubject;
     _maxBytes          = sc.MaxBytes;
     _maxAge            = sc.MaxAge;
     _maxMsgSize        = sc.MaxValueSize;
     _storageType       = sc.StorageType;
     _replicas          = sc.Replicas;
     _noAck             = sc.NoAck;
     _templateOwner     = sc.TemplateOwner;
     _discardPolicy     = sc.DiscardPolicy;
     _duplicateWindow   = sc.DuplicateWindow;
     _placement         = sc.Placement;
     _mirror            = sc.Mirror;
     WithSources(sc.Sources);
     _sealed      = sc.Sealed;
     _allowRollup = sc.AllowRollup;
     _denyDelete  = sc.DenyDelete;
     _denyPurge   = sc.DenyPurge;
 }
Пример #3
0
        private void SetRetention(DiagnosticSettingsResource properties)
        {
            var retentionPolicy = new RetentionPolicy
            {
                Enabled = this.RetentionEnabled.Value,
                Days    = this.RetentionInDays.Value
            };

            if (properties.Logs != null && this.IsParameterBound(c => c.Category))
            {
                WriteDebugWithTimestamp("Setting retention policy for logs");
                properties.Logs = properties.Logs.Select(setting =>
                {
                    if (setting != null)
                    {
                        setting.RetentionPolicy = this.Category.Contains(setting.Category) ? retentionPolicy : (setting.RetentionPolicy == null ? null : setting.RetentionPolicy);
                    }
                    return(setting);
                }).ToList();
            }

            if (properties.Metrics != null && this.IsParameterBound(c => c.MetricCategory))
            {
                WriteDebugWithTimestamp("Setting retention policy for metrics");
                properties.Metrics = properties.Metrics.Select(setting =>
                {
                    if (setting != null)
                    {
                        setting.RetentionPolicy = this.MetricCategory.Contains(setting.Category) ? retentionPolicy : (setting.RetentionPolicy == null ? null : setting.RetentionPolicy);
                    }
                    return(setting);
                }).ToList();
            }
        }
Пример #4
0
        public async Task CleanupExecutor_should_delete_expired_files(
            string rulesData,
            string resourceDetails,
            string expectedRetainedFiles)
        {
            // Arrange.
            var expectedRetainedFileNames = expectedRetainedFiles.Split(' ', RemoveEmptyEntries);

            var rules  = rulesData.ParseRules();
            var policy = new RetentionPolicy(rules);

            CreateFilesInStorage(resourceDetails);

            var storage = new DirectoryFileStorage(new SystemClock(), _settings);

            // Act.
            await new CleanupExecutor().ExecuteStorageCleanup(storage, policy);

            // Assert.
            var actualRetainedFileNames = Directory
                                          .GetFiles(_settings.DirectoryPath)
                                          .Select(Path.GetFileNameWithoutExtension);

            actualRetainedFileNames.Should().BeEquivalentTo(expectedRetainedFileNames);
        }
Пример #5
0
        /// <summary>
        /// Gets Invoked When a policy is created.
        /// </summary>
        /// <returns></returns>
        internal async Task CreatePolicyAsync(BackupPolicy backupPolicy, TimeSpan timeout, CancellationToken cancellationToken, ITransaction transaction)
        {
            // create a metadata and initialise the RetentionMetadata.
            BackupRestoreTrace.TraceSource.WriteInfo(TraceType, "Scheduling retention for backupPolicy : {0}", backupPolicy.Name);
            RetentionPolicy retentionPolicy = backupPolicy.RetentionPolicy;

            if (null == retentionPolicy)
            {
                // there is nothing to be done.
                BackupRestoreTrace.TraceSource.WriteInfo(TraceType, "RetentionPolicy for backupPolicy : {0} is not defined.", backupPolicy.Name);
            }
            else
            {
                RetentionMetadata retentionMetadata = new RetentionMetadata(backupPolicy.RetentionPolicy);
                await this.RetentionStore.AddAsync(backupPolicy.Name, retentionMetadata, timeout, cancellationToken, transaction);

                RetentionScheduler retentionScheduler = new RetentionScheduler(backupPolicy.Name, backupPolicy.RetentionPolicy, timerCallback);

                if (!RetentionSchedulerDict.TryAdd(backupPolicy.Name, retentionScheduler))
                {
                    BackupRestoreTrace.TraceSource.WriteError(TraceType, "CreatePolicyAsync: Not able to add retention scheduler for backupPolicy : {0}", backupPolicy.Name);
                    throw new InvalidOperationException(string.Format("{0}: Key already exists ", backupPolicy.Name));
                }
                retentionScheduler.ArmTimer(retentionMetadata);
            }
        }
Пример #6
0
 internal RetentionScheduler(string backupPolicyName, RetentionPolicy retentionPolicy, Action <string> callback)
 {
     this.backupPolicyName         = backupPolicyName;
     this.retentionTimer           = new RetentionTimer(this.timerCallback, retentionPolicy);
     this.retentionRescheduleTimer = new RescheduleTimer(this.timerCallback, "RetentionRescheduler");
     this.callback = callback;
 }
Пример #7
0
 /**
  * Update Builder, useful if you need to update a configuration
  * @param sc the configuration to copy
  */
 internal JetStreamConfigBuilder(JetStreamConfig jetStreamConfig)
 {
     if (jetStreamConfig != null)
     {
         Name = jetStreamConfig.Name;
         SetSubjects(jetStreamConfig.Subjects);
         this.RetentionPolicy = jetStreamConfig.RetentionPolicy;
         this.MaxConsumers    = jetStreamConfig.MaxConsumers;
         this.MaxMsgs         = jetStreamConfig.MaxMsgs;
         this.MaxBytes        = jetStreamConfig.MaxBytes;
         this.MaxAge          = TimeSpan.FromMilliseconds(NATSJetStreamDuration.OfNanos(jetStreamConfig.MaxAge).Millis);
         this.MaxMsgSize      = jetStreamConfig.MaxMsgSize;
         this.StorageType     = jetStreamConfig.StorageType;
         this.Replicas        = jetStreamConfig.Replicas;
         this.NoAck           = jetStreamConfig.NoAck;
         this.TemplateOwner   = jetStreamConfig.TemplateOwner;
         this.DiscardPolicy   = jetStreamConfig.DiscardPolicy;
         if (jetStreamConfig.DuplicateWindow.HasValue)
         {
             this.DuplicateWindow = TimeSpan.FromMilliseconds(NATSJetStreamDuration.OfNanos(jetStreamConfig.DuplicateWindow.Value).Millis);
         }
         this.Placement = jetStreamConfig.Placement;
         this.Mirror    = jetStreamConfig.Mirror;
         SetSources(jetStreamConfig.Sources);
     }
 }
Пример #8
0
        public override int Execute(string[] commandLineArguments)
        {
            Options.Parse(commandLineArguments);

            Guard.NotNullOrWhiteSpace(retentionPolicySet, "No retention-policy-set was specified. Please pass --retentionPolicySet \"Environments-2/projects-161/Step-Package B/machines-65/<default>\"");

            if (days <= 0 && releases <= 0)
            {
                throw new CommandException("A value must be provided for either --days or --releases");
            }

            var variables = new CalamariVariableDictionary();

            variables.EnrichWithEnvironmentVariables();

            var fileSystem        = CalamariPhysicalFileSystem.GetPhysicalFileSystem();
            var deploymentJournal = new DeploymentJournal(fileSystem, new SystemSemaphore(), variables);
            var clock             = new SystemClock();

            var retentionPolicy = new RetentionPolicy(fileSystem, deploymentJournal, clock);

            retentionPolicy.ApplyRetentionPolicy(retentionPolicySet, days, releases);

            return(0);
        }
        private void SetRetention(DiagnosticSettingsResource properties)
        {
            var retentionPolicy = new RetentionPolicy
            {
                Enabled = this.RetentionEnabled.Value,
                Days    = this.RetentionInDays.Value
            };

            if (properties.Logs != null)
            {
                WriteDebugWithTimestamp("Setting retention policy for logs");
                foreach (LogSettings logSettings in properties.Logs)
                {
                    logSettings.RetentionPolicy = retentionPolicy;
                }
            }

            if (properties.Metrics != null)
            {
                WriteDebugWithTimestamp("Setting retention policy for metrics");
                foreach (MetricSettings metricSettings in properties.Metrics)
                {
                    metricSettings.RetentionPolicy = retentionPolicy;
                }
            }
        }
Пример #10
0
        public void SetUp()
        {
            fileSystem        = Substitute.For <ICalamariFileSystem>();
            deploymentJournal = Substitute.For <IDeploymentJournal>();
            clock             = Substitute.For <IClock>();
            retentionPolicy   = new RetentionPolicy(fileSystem, deploymentJournal, clock);

            now = new DateTimeOffset(new DateTime(2015, 01, 15), new TimeSpan(0, 0, 0));
            clock.GetUtcTime().Returns(now);

            // Deployed 4 days prior to 'now'
            fourDayOldDeployment = new JournalEntry("fourDayOld", "blah", "blah", "blah", "blah", "blah", policySet1,
                                                    now.AddDays(-4).LocalDateTime,
                                                    "C:\\packages\\Acme.1.0.0.nupkg", "C:\\Applications\\Acme.1.0.0", null, true);

            // Deployed 4 days prior to 'now' but to the same location as the latest successful deployment
            fourDayOldSameLocationDeployment = new JournalEntry("twoDayOld", "blah", "blah", "blah", "blah", "blah", policySet1,
                                                                now.AddDays(-4).LocalDateTime,
                                                                "C:\\packages\\Acme.1.2.0.nupkg", "C:\\Applications\\Acme.1.2.0", null, true);

            // Deployed 3 days prior to 'now'
            threeDayOldDeployment = new JournalEntry("threeDayOld", "blah", "blah", "blah", "blah", "blah", policySet1,
                                                     now.AddDays(-3).LocalDateTime,
                                                     "C:\\packages\\Acme.1.1.0.nupkg", "C:\\Applications\\Acme.1.1.0", null, true);

            // Deployed 2 days prior to 'now'
            twoDayOldDeployment = new JournalEntry("twoDayOld", "blah", "blah", "blah", "blah", "blah", policySet1,
                                                   now.AddDays(-2).LocalDateTime,
                                                   "C:\\packages\\Acme.1.2.0.nupkg", "C:\\Applications\\Acme.1.2.0", null, true);

            // Deployed (unsuccessfully) 1 day prior to 'now'
            oneDayOldUnsuccessfulDeployment = new JournalEntry("oneDayOldUnsuccessful", "blah", "blah", "blah", "blah", "blah", policySet1,
                                                               now.AddDays(-1).LocalDateTime,
                                                               "C:\\packages\\Acme.1.3.0.nupkg", "C:\\Applications\\Acme.1.3.0", null, false);

            // Deployed 5 days prior to 'now', but has a different policy-set
            fiveDayOldNonMatchingDeployment = new JournalEntry("fiveDayOld", "blah", "blah", "blah", "blah", "blah", policySet2,
                                                               now.AddDays(-5).LocalDateTime,
                                                               "C:\\packages\\Beta.1.0.0.nupkg", "C:\\Applications\\Beta.1.0.0", null, true);

            var journalEntries = new List <JournalEntry>
            {
                fiveDayOldNonMatchingDeployment,
                fourDayOldDeployment,
                threeDayOldDeployment,
                twoDayOldDeployment,
                oneDayOldUnsuccessfulDeployment
            };

            deploymentJournal.GetAllJournalEntries().Returns(journalEntries);

            foreach (var journalEntry in journalEntries)
            {
                fileSystem.FileExists(journalEntry.ExtractedFrom).Returns(true);
                fileSystem.DirectoryExists(journalEntry.ExtractedTo).Returns(true);
            }

            Environment.SetEnvironmentVariable("TentacleHome", @"Q:\TentacleHome");
        }
Пример #11
0
        public override void ExecuteCmdlet()
        {
            ExecutionBlock(() =>
            {
                base.ExecuteCmdlet();

                ResourceIdentifier resourceIdentifier = new ResourceIdentifier(VaultId);
                string vaultName         = resourceIdentifier.ResourceName;
                string resourceGroupName = resourceIdentifier.ResourceGroupName;

                WriteDebug(string.Format("Input params - Name:{0}, WorkloadType:{1}, " +
                                         "BackupManagementType: {2}, " +
                                         "RetentionPolicy:{3}, SchedulePolicy:{4}",
                                         Name, WorkloadType.ToString(),
                                         BackupManagementType.HasValue ? BackupManagementType.ToString() : "NULL",
                                         RetentionPolicy == null ? "NULL" : RetentionPolicy.ToString(),
                                         SchedulePolicy == null ? "NULL" : SchedulePolicy.ToString()));

                // validate policy name
                PolicyCmdletHelpers.ValidateProtectionPolicyName(Name);

                // Validate if policy already exists
                if (PolicyCmdletHelpers.GetProtectionPolicyByName(
                        Name,
                        ServiceClientAdapter,
                        vaultName: vaultName,
                        resourceGroupName: resourceGroupName) != null)
                {
                    throw new ArgumentException(string.Format(Resources.PolicyAlreadyExistException, Name));
                }

                Dictionary <Enum, object> providerParameters = new Dictionary <Enum, object>();
                providerParameters.Add(VaultParams.VaultName, vaultName);
                providerParameters.Add(VaultParams.ResourceGroupName, resourceGroupName);
                providerParameters.Add(PolicyParams.PolicyName, Name);
                providerParameters.Add(PolicyParams.WorkloadType, WorkloadType);
                providerParameters.Add(PolicyParams.RetentionPolicy, RetentionPolicy);
                providerParameters.Add(PolicyParams.SchedulePolicy, SchedulePolicy);

                PsBackupProviderManager providerManager = new PsBackupProviderManager(providerParameters, ServiceClientAdapter);

                IPsBackupProvider psBackupProvider =
                    providerManager.GetProviderInstance(WorkloadType, BackupManagementType);

                psBackupProvider.CreatePolicy();

                WriteDebug("Successfully created policy, now fetching it from service: " + Name);

                // now get the created policy and return
                ServiceClientModel.ProtectionPolicyResource policy = PolicyCmdletHelpers.GetProtectionPolicyByName(
                    Name,
                    ServiceClientAdapter,
                    vaultName: vaultName,
                    resourceGroupName: resourceGroupName);

                // now convert service Policy to PSObject
                WriteObject(ConversionHelpers.GetPolicyModel(policy));
            }, ShouldProcess(Name, VerbsCommon.New));
        }
Пример #12
0
 public Measurement(string sensorId, MeasurementType measurementType, RetentionPolicy retentionPolicy, double value, DateTime created)
 {
     SensorId        = sensorId;
     MeasurementType = measurementType;
     RetentionPolicy = retentionPolicy;
     Value           = value;
     Created         = created;
 }
Пример #13
0
 internal LogProfileData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary <string, string> tags, AzureLocation location, string storageAccountId, string serviceBusRuleId, IList <string> locations, IList <string> categories, RetentionPolicy retentionPolicy) : base(id, name, resourceType, systemData, tags, location)
 {
     StorageAccountId = storageAccountId;
     ServiceBusRuleId = serviceBusRuleId;
     Locations        = locations;
     Categories       = categories;
     RetentionPolicy  = retentionPolicy;
 }
Пример #14
0
 protected RetentionPolicyRunnerBase(RetentionPolicyBaseParameters parameters)
 {
     _retentionPolicy  = parameters.RetentionPolicy;
     _databaseName     = parameters.DatabaseName;
     _isFullBackup     = parameters.IsFullBackup;
     _onProgress       = parameters.OnProgress;
     CancellationToken = parameters.CancellationToken;
 }
Пример #15
0
 /// <summary>
 /// Initializes a new instance of the LogSettings class.
 /// </summary>
 /// <param name="logSettings">The log settings</param>
 public LogSettings(Monitor.Models.LogSettings logSettings)
     : base(
         enabled: logSettings == null ? default(bool) : logSettings.Enabled,
         category: logSettings?.Category,
         retentionPolicy: logSettings?.RetentionPolicy)
 {
     this.RetentionPolicy = new RetentionPolicy(logSettings?.RetentionPolicy);
 }
        private static void ValidateNoOverlappingMessageClass(RetentionPolicy retentionPolicy, IEnumerable <PresentationRetentionPolicyTag> defaultTags, Task.TaskErrorLoggingDelegate writeError)
        {
            IEnumerable <IGrouping <string, string> > source = defaultTags.SelectMany((PresentationRetentionPolicyTag x) => x.MessageClass.Split(ElcMessageClass.MessageClassDelims, StringSplitOptions.RemoveEmptyEntries)).GroupBy((string x) => x, StringComparer.OrdinalIgnoreCase);
            IGrouping <string, string> grouping = source.FirstOrDefault((IGrouping <string, string> x) => x.Count <string>() > 1);

            if (grouping != null)
            {
                writeError(new RetentionPolicyTagTaskException(Strings.ErrorDefaultTagHasConflictedMessageClasses(retentionPolicy.Id.ToString(), grouping.Key)), ErrorCategory.InvalidOperation, retentionPolicy);
            }
        }
Пример #17
0
        /// <summary>
        /// A string representation of the PSLogSettings
        /// </summary>
        /// <returns>A string representation of the PSLogSettings</returns>
        public override string ToString()
        {
            StringBuilder output = new StringBuilder();

            output.AppendLine();
            output.AppendLine("Enabled         : " + Enabled);
            output.AppendLine("Category        : " + Category);
            output.Append("RetentionPolicy : " + RetentionPolicy.ToString(1));
            return(output.ToString());
        }
        /// <summary>
        /// A string representation of the PSMetricSettings
        /// </summary>
        /// <returns>A string representation of the PSMetricSettings</returns>
        public override string ToString()
        {
            StringBuilder output = new StringBuilder();

            output.AppendLine();
            output.AppendLine("Enabled         : " + Enabled);
            output.AppendLine("TimeGrain       : " + XmlConvert.ToString(TimeGrain));
            output.Append("RetentionPolicy : " + RetentionPolicy.ToString(1));
            return(output.ToString());
        }
Пример #19
0
        public async Task UpdateRetentionPolicyAsync(string company, RetentionPolicy retentionPolicy)
        {
            var queryParameters = new DynamicParameters();
            queryParameters.Add("@CompanyId", company);
            queryParameters.Add("@WeekendDay", retentionPolicy.WeekendDay);
            queryParameters.Add("@DailyFreezeRetention", retentionPolicy.DailyFreezeRetention);
            queryParameters.Add("@WeeklyFreezeRetention", retentionPolicy.WeeklyFreezeRetention);
            queryParameters.Add("@MonthlyFreezeRetention", retentionPolicy.MonthlyFreezeRetention);

            await ExecuteNonQueryAsync(StoredProcedureNames.UpdateRetentionPolicy, queryParameters, true);
        }
        private static void AssertFindExpiredResourcesThrows <TException>(
            IReadOnlyCollection <IResource <string> > resources)
            where TException : Exception
        {
            // Arrange.
            var validRules = "5:4 10:2".ParseRules();
            var policy     = new RetentionPolicy(validRules);

            // Act + Assert.
            Assert.Throws <TException>(
                () => policy.FindExpiredResources(resources));
        }
Пример #21
0
        public static string GetString(this RetentionPolicy retentionPolicy)
        {
            switch (retentionPolicy)
            {
            case RetentionPolicy.Limits:    return("limits");

            case RetentionPolicy.Interest:  return("interest");

            case RetentionPolicy.WorkQueue: return("workqueue");
            }
            return(null);
        }
Пример #22
0
 private static void VerifyRetentionPolicy(RetentionPolicy expected, RetentionPolicy actual)
 {
     if (expected == null)
     {
         Assert.Null(actual);
     }
     else
     {
         Assert.Equal(expected.Days, actual.Days);
         Assert.Equal(expected.Enabled, actual.Enabled);
     }
 }
Пример #23
0
        public static YamlRetentionPolicy FromModel(RetentionPolicy model)
        {
            if (model == null)
            {
                return(null);
            }

            return(new YamlRetentionPolicy
            {
                Unit = model.Unit,
                QuantityToKeep = model.QuantityToKeep
            });
        }
Пример #24
0
        /// <summary>
        /// A string representation of the RetentionPolicy including indentation
        /// </summary>
        /// <param name="retentionPolicy">The RetentionPolicy object</param>
        /// <param name="indentationTabs">The number of tabs to insert in front of each member</param>
        /// <returns>A string representation of the RecurrentSchedule including indentation</returns>
        public static string ToString(this RetentionPolicy retentionPolicy, int indentationTabs)
        {
            StringBuilder output = new StringBuilder();

            if (retentionPolicy != null)
            {
                output.AppendLine();
                output.AddSpacesInFront(indentationTabs).AppendLine("Enabled  : " + string.Join(",", retentionPolicy.Enabled));
                output.AddSpacesInFront(indentationTabs).Append("Days     : " + string.Join(",", retentionPolicy.Days));
            }

            return(output.ToString());
        }
Пример #25
0
        public IActionResult Create(RetentionPolicy retentionPolicy)
        {
            if (ModelState.IsValid)
            {
                _dbContext.RetentionPolicies.Add(retentionPolicy);
                _dbContext.SaveChanges();

                return(RedirectToAction("Index"));
            }
            else
            {
                return(View(retentionPolicy));
            }
        }
        internal static void ValidateSystemFolderTags(RetentionPolicy retentionPolicy, PresentationRetentionPolicyTag[] retentionTags, Task.TaskErrorLoggingDelegate writeError)
        {
            IEnumerable <PresentationRetentionPolicyTag> source = from x in retentionTags
                                                                  where x.RetentionEnabled && x.Type != ElcFolderType.Personal && x.Type != ElcFolderType.All
                                                                  select x;
            IGrouping <ElcFolderType, PresentationRetentionPolicyTag> grouping = (from x in source
                                                                                  group x by x.Type).FirstOrDefault((IGrouping <ElcFolderType, PresentationRetentionPolicyTag> y) => y.Count <PresentationRetentionPolicyTag>() > 1);

            if (grouping != null)
            {
                PresentationRetentionPolicyTag presentationRetentionPolicyTag = grouping.First <PresentationRetentionPolicyTag>();
                writeError(new RetentionPolicyTagTaskException(Strings.ErrorMultipleSystemFolderTagConfliction(retentionPolicy.Id.ToString(), presentationRetentionPolicyTag.Type.ToString())), ErrorCategory.InvalidOperation, retentionPolicy);
            }
        }
Пример #27
0
        public override DynamicJsonValue ToJson()
        {
            var json = base.ToJson();

            json[nameof(BackupType)]            = BackupType;
            json[nameof(BackupDestinations)]    = new DynamicJsonArray(BackupDestinations);
            json[nameof(LastFullBackup)]        = LastFullBackup;
            json[nameof(LastIncrementalBackup)] = LastIncrementalBackup;
            json[nameof(OnGoingBackup)]         = OnGoingBackup?.ToJson();
            json[nameof(NextBackup)]            = NextBackup?.ToJson();
            json[nameof(RetentionPolicy)]       = RetentionPolicy?.ToJson();
            json[nameof(IsEncrypted)]           = IsEncrypted;
            return(json);
        }
 protected override void InternalBeginProcessing()
 {
     TaskLogger.LogEnter();
     base.InternalBeginProcessing();
     if (this.RetentionPolicy != null)
     {
         if (SharedConfiguration.IsDehydratedConfiguration(base.CurrentOrganizationId))
         {
             base.WriteError(new LocalizedException(Strings.ErrorLinkOpOnDehydratedTenant("RetentionPolicy")), ExchangeErrorCategory.Client, null);
         }
         RetentionPolicy retentionPolicy = (RetentionPolicy)base.GetDataObject <RetentionPolicy>(this.RetentionPolicy, this.ConfigurationSession, null, new LocalizedString?(Strings.ErrorRetentionPolicyNotFound(this.RetentionPolicy.ToString())), new LocalizedString?(Strings.ErrorRetentionPolicyNotUnique(this.RetentionPolicy.ToString())));
         this.retentionPolicyId = (ADObjectId)retentionPolicy.Identity;
     }
     TaskLogger.LogExit();
 }
Пример #29
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PSLogProfile"/> class.
        /// </summary>
        public PSLogProfile(string id, string name, LogProfile logProfile)
        {
            this.Id = id;

            this.Name = name;

            this.Categories      = logProfile.Categories.Select(x => x).ToList();
            this.Locations       = logProfile.Locations.Select(x => x).ToList();
            this.RetentionPolicy = new RetentionPolicy()
            {
                Days    = logProfile.RetentionPolicy.Days,
                Enabled = logProfile.RetentionPolicy.Enabled
            };
            this.ServiceBusRuleId = logProfile.ServiceBusRuleId;
            this.StorageAccountId = logProfile.StorageAccountId;
        }
Пример #30
0
        public static RetentionPolicy GetValueOrDefault(string value, RetentionPolicy aDefault)
        {
            if (value != null)
            {
                switch (value)
                {
                case "limits": return(RetentionPolicy.Limits);

                case "interest": return(RetentionPolicy.Interest);

                case "workqueue": return(RetentionPolicy.WorkQueue);
                }
            }

            return(aDefault);
        }
Пример #31
0
 public Retention(RetentionPolicy newPolicy)
 {
     this.policy = newPolicy;
 }