Ejemplo n.º 1
0
        internal static AnomalyDetectionConfiguration DeserializeAnomalyDetectionConfiguration(JsonElement element)
        {
            Optional <string> anomalyDetectionConfigurationId = default;
            string            name        = default;
            Optional <string> description = default;
            string            metricId    = default;
            MetricWholeSeriesDetectionCondition wholeMetricConfiguration = default;
            Optional <IList <MetricSeriesGroupDetectionCondition> >  dimensionGroupOverrideConfigurations = default;
            Optional <IList <MetricSingleSeriesDetectionCondition> > seriesOverrideConfigurations         = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("anomalyDetectionConfigurationId"))
                {
                    anomalyDetectionConfigurationId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("description"))
                {
                    description = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("metricId"))
                {
                    metricId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("wholeMetricConfiguration"))
                {
                    wholeMetricConfiguration = MetricWholeSeriesDetectionCondition.DeserializeMetricWholeSeriesDetectionCondition(property.Value);
                    continue;
                }
                if (property.NameEquals("dimensionGroupOverrideConfigurations"))
                {
                    List <MetricSeriesGroupDetectionCondition> array = new List <MetricSeriesGroupDetectionCondition>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(MetricSeriesGroupDetectionCondition.DeserializeMetricSeriesGroupDetectionCondition(item));
                    }
                    dimensionGroupOverrideConfigurations = array;
                    continue;
                }
                if (property.NameEquals("seriesOverrideConfigurations"))
                {
                    List <MetricSingleSeriesDetectionCondition> array = new List <MetricSingleSeriesDetectionCondition>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(MetricSingleSeriesDetectionCondition.DeserializeMetricSingleSeriesDetectionCondition(item));
                    }
                    seriesOverrideConfigurations = array;
                    continue;
                }
            }
            return(new AnomalyDetectionConfiguration(anomalyDetectionConfigurationId.Value, name, description.Value, metricId, wholeMetricConfiguration, Optional.ToList(dimensionGroupOverrideConfigurations), Optional.ToList(seriesOverrideConfigurations)));
        }
 internal AnomalyDetectionConfiguration(string id, string name, string description, string metricId, MetricWholeSeriesDetectionCondition wholeSeriesDetectionConditions, IList <MetricSeriesGroupDetectionCondition> seriesGroupDetectionConditions, IList <MetricSingleSeriesDetectionCondition> seriesDetectionConditions)
 {
     Id          = id;
     Name        = name;
     Description = description;
     MetricId    = metricId;
     WholeSeriesDetectionConditions = wholeSeriesDetectionConditions;
     SeriesGroupDetectionConditions = seriesGroupDetectionConditions;
     SeriesDetectionConditions      = seriesDetectionConditions;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Creates a new instance of the <see cref="AnomalyDetectionConfiguration"/> class.
        /// </summary>
        /// <param name="metricId">The identifier of the metric to which this configuration applies.</param>
        /// <param name="name">A custom name for this <see cref="AnomalyDetectionConfiguration"/> to be displayed on the web portal.</param>
        /// <param name="wholeSeriesDetectionConditions">The default anomaly detection conditions to be applied to all series associated with this configuration's <paramref name="metricId"/>.</param>
        /// <exception cref="ArgumentNullException"><paramref name="metricId"/>, <paramref name="name"/>, or <paramref name="wholeSeriesDetectionConditions"/> is null.</exception>
        /// <exception cref="ArgumentException"><paramref name="metricId"/> or <paramref name="name"/> is empty.</exception>
        public AnomalyDetectionConfiguration(string metricId, string name, MetricWholeSeriesDetectionCondition wholeSeriesDetectionConditions)
        {
            Argument.AssertNotNullOrEmpty(metricId, nameof(metricId));
            Argument.AssertNotNullOrEmpty(name, nameof(name));
            Argument.AssertNotNull(wholeSeriesDetectionConditions, nameof(wholeSeriesDetectionConditions));

            MetricId = metricId;
            Name     = name;
            WholeSeriesDetectionConditions = wholeSeriesDetectionConditions;
            SeriesDetectionConditions      = new ChangeTrackingList <MetricSingleSeriesDetectionCondition>();
            SeriesGroupDetectionConditions = new ChangeTrackingList <MetricSeriesGroupDetectionCondition>();
        }
Ejemplo n.º 4
0
        public static AnomalyDetectionConfiguration AnomalyDetectionConfiguration(string id = null, string name = null, string description = null, string metricId = null, MetricWholeSeriesDetectionCondition wholeSeriesDetectionConditions = null, IEnumerable <MetricSeriesGroupDetectionCondition> seriesGroupDetectionConditions = null, IEnumerable <MetricSingleSeriesDetectionCondition> seriesDetectionConditions = null)
        {
            seriesGroupDetectionConditions ??= new List <MetricSeriesGroupDetectionCondition>();
            seriesDetectionConditions ??= new List <MetricSingleSeriesDetectionCondition>();

            return(new AnomalyDetectionConfiguration(id, name, description, metricId, wholeSeriesDetectionConditions, seriesGroupDetectionConditions?.ToList(), seriesDetectionConditions?.ToList()));
        }