Example #1
0
        internal static MetricAnomalyAlertConfiguration DeserializeMetricAnomalyAlertConfiguration(JsonElement element)
        {
            string anomalyDetectionConfigurationId                    = default;
            MetricAnomalyAlertScopeType  anomalyScopeType             = default;
            Optional <bool>              negationOperation            = default;
            Optional <DimensionKey>      dimensionAnomalyScope        = default;
            Optional <TopNGroupScope>    topNAnomalyScope             = default;
            Optional <SeverityCondition> severityFilter               = default;
            Optional <MetricAnomalyAlertSnoozeCondition> snoozeFilter = default;
            Optional <MetricBoundaryCondition>           valueFilter  = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("anomalyDetectionConfigurationId"))
                {
                    anomalyDetectionConfigurationId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("anomalyScopeType"))
                {
                    anomalyScopeType = new MetricAnomalyAlertScopeType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("negationOperation"))
                {
                    negationOperation = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("dimensionAnomalyScope"))
                {
                    dimensionAnomalyScope = DimensionKey.DeserializeDimensionKey(property.Value);
                    continue;
                }
                if (property.NameEquals("topNAnomalyScope"))
                {
                    topNAnomalyScope = TopNGroupScope.DeserializeTopNGroupScope(property.Value);
                    continue;
                }
                if (property.NameEquals("severityFilter"))
                {
                    severityFilter = SeverityCondition.DeserializeSeverityCondition(property.Value);
                    continue;
                }
                if (property.NameEquals("snoozeFilter"))
                {
                    snoozeFilter = MetricAnomalyAlertSnoozeCondition.DeserializeMetricAnomalyAlertSnoozeCondition(property.Value);
                    continue;
                }
                if (property.NameEquals("valueFilter"))
                {
                    valueFilter = MetricBoundaryCondition.DeserializeMetricBoundaryCondition(property.Value);
                    continue;
                }
            }
            return(new MetricAnomalyAlertConfiguration(anomalyDetectionConfigurationId, anomalyScopeType, Optional.ToNullable(negationOperation), dimensionAnomalyScope.Value, topNAnomalyScope.Value, severityFilter.Value, snoozeFilter.Value, valueFilter.Value));
        }
Example #2
0
 internal MetricAnomalyAlertConfiguration(string detectionConfigurationId, MetricAnomalyAlertScopeType anomalyScopeType, bool? useDetectionResultToFilterAnomalies, DimensionKey dimensionAnomalyScope, TopNGroupScope topNAnomalyScope, SeverityCondition severityFilter, MetricAnomalyAlertSnoozeCondition alertSnoozeCondition, MetricBoundaryCondition valueFilter)
 {
     DetectionConfigurationId = detectionConfigurationId;
     AlertScope = new MetricAnomalyAlertScope(anomalyScopeType, dimensionAnomalyScope, topNAnomalyScope);
     UseDetectionResultToFilterAnomalies = useDetectionResultToFilterAnomalies;
     AlertConditions = new MetricAnomalyAlertConditions()
     {
         MetricBoundaryCondition = valueFilter,
         SeverityCondition = severityFilter
     };
     AlertSnoozeCondition = alertSnoozeCondition;
 }