internal static MetricSingleSeriesDetectionCondition DeserializeMetricSingleSeriesDetectionCondition(JsonElement element)
        {
            SeriesIdentity series = default;
            Optional <DetectionConditionOperator> conditionOperator        = default;
            Optional <SmartDetectionCondition>    smartDetectionCondition  = default;
            Optional <HardThresholdCondition>     hardThresholdCondition   = default;
            Optional <ChangeThresholdCondition>   changeThresholdCondition = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("series"))
                {
                    series = SeriesIdentity.DeserializeSeriesIdentity(property.Value);
                    continue;
                }
                if (property.NameEquals("conditionOperator"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    conditionOperator = new DetectionConditionOperator(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("smartDetectionCondition"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    smartDetectionCondition = Models.SmartDetectionCondition.DeserializeSmartDetectionCondition(property.Value);
                    continue;
                }
                if (property.NameEquals("hardThresholdCondition"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    hardThresholdCondition = Models.HardThresholdCondition.DeserializeHardThresholdCondition(property.Value);
                    continue;
                }
                if (property.NameEquals("changeThresholdCondition"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    changeThresholdCondition = Models.ChangeThresholdCondition.DeserializeChangeThresholdCondition(property.Value);
                    continue;
                }
            }
            return(new MetricSingleSeriesDetectionCondition(Optional.ToNullable(conditionOperator), smartDetectionCondition.Value, hardThresholdCondition.Value, changeThresholdCondition.Value, series));
        }
        internal static AnomalyIncident DeserializeAnomalyIncident(JsonElement element)
        {
            Optional <string> dataFeedId = default;
            Optional <string> metricId   = default;
            Optional <string> anomalyDetectionConfigurationId = default;
            string            incidentId = default;
            DateTimeOffset    startTime  = default;
            DateTimeOffset    lastTime   = default;
            SeriesIdentity    rootNode   = default;
            IncidentProperty  property   = default;

            foreach (var property0 in element.EnumerateObject())
            {
                if (property0.NameEquals("dataFeedId"))
                {
                    dataFeedId = property0.Value.GetString();
                    continue;
                }
                if (property0.NameEquals("metricId"))
                {
                    metricId = property0.Value.GetString();
                    continue;
                }
                if (property0.NameEquals("anomalyDetectionConfigurationId"))
                {
                    anomalyDetectionConfigurationId = property0.Value.GetString();
                    continue;
                }
                if (property0.NameEquals("incidentId"))
                {
                    incidentId = property0.Value.GetString();
                    continue;
                }
                if (property0.NameEquals("startTime"))
                {
                    startTime = property0.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property0.NameEquals("lastTime"))
                {
                    lastTime = property0.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property0.NameEquals("rootNode"))
                {
                    rootNode = SeriesIdentity.DeserializeSeriesIdentity(property0.Value);
                    continue;
                }
                if (property0.NameEquals("property"))
                {
                    property = IncidentProperty.DeserializeIncidentProperty(property0.Value);
                    continue;
                }
            }
            return(new AnomalyIncident(dataFeedId.Value, metricId.Value, anomalyDetectionConfigurationId.Value, incidentId, startTime, lastTime, rootNode, property));
        }
 internal MetricEnrichedSeriesData(SeriesIdentity series, IReadOnlyList <DateTimeOffset> timestamps, IReadOnlyList <double> values, IReadOnlyList <bool?> isAnomaly, IReadOnlyList <int?> periods, IReadOnlyList <double?> expectedValues, IReadOnlyList <double?> lowerBoundaries, IReadOnlyList <double?> upperBoundaries)
 {
     SeriesKey            = new DimensionKey(series.Dimension);
     Timestamps           = timestamps;
     MetricValues         = values;
     IsAnomaly            = isAnomaly;
     Periods              = periods;
     ExpectedMetricValues = expectedValues;
     LowerBoundaryValues  = lowerBoundaries;
     UpperBoundaryValues  = upperBoundaries;
 }
 internal MetricSingleSeriesDetectionCondition(DetectionConditionsOperator?crossConditionsOperator, SmartDetectionCondition smartDetectionCondition, HardThresholdCondition hardThresholdCondition, ChangeThresholdCondition changeThresholdCondition, SeriesIdentity series)
     : base(crossConditionsOperator, smartDetectionCondition, hardThresholdCondition, changeThresholdCondition)
 {
     SeriesKey = new DimensionKey(series.Dimension);
 }
Пример #5
0
        internal static MetricEnrichedSeriesData DeserializeMetricEnrichedSeriesData(JsonElement element)
        {
            SeriesIdentity series = default;
            IReadOnlyList <DateTimeOffset> timestampList     = default;
            IReadOnlyList <double>         valueList         = default;
            IReadOnlyList <bool?>          isAnomalyList     = default;
            IReadOnlyList <int?>           periodList        = default;
            IReadOnlyList <double?>        expectedValueList = default;
            IReadOnlyList <double?>        lowerBoundaryList = default;
            IReadOnlyList <double?>        upperBoundaryList = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("series"))
                {
                    series = SeriesIdentity.DeserializeSeriesIdentity(property.Value);
                    continue;
                }
                if (property.NameEquals("timestampList"))
                {
                    List <DateTimeOffset> array = new List <DateTimeOffset>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(item.GetDateTimeOffset("O"));
                    }
                    timestampList = array;
                    continue;
                }
                if (property.NameEquals("valueList"))
                {
                    List <double> array = new List <double>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(item.GetDouble());
                    }
                    valueList = array;
                    continue;
                }
                if (property.NameEquals("isAnomalyList"))
                {
                    List <bool?> array = new List <bool?>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(item.GetBoolean());
                        }
                    }
                    isAnomalyList = array;
                    continue;
                }
                if (property.NameEquals("periodList"))
                {
                    List <int?> array = new List <int?>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(item.GetInt32());
                        }
                    }
                    periodList = array;
                    continue;
                }
                if (property.NameEquals("expectedValueList"))
                {
                    List <double?> array = new List <double?>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(item.GetDouble());
                        }
                    }
                    expectedValueList = array;
                    continue;
                }
                if (property.NameEquals("lowerBoundaryList"))
                {
                    List <double?> array = new List <double?>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(item.GetDouble());
                        }
                    }
                    lowerBoundaryList = array;
                    continue;
                }
                if (property.NameEquals("upperBoundaryList"))
                {
                    List <double?> array = new List <double?>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(item.GetDouble());
                        }
                    }
                    upperBoundaryList = array;
                    continue;
                }
            }
            return(new MetricEnrichedSeriesData(series, timestampList, valueList, isAnomalyList, periodList, expectedValueList, lowerBoundaryList, upperBoundaryList));
        }
Пример #6
0
 internal AnomalyIncident(string dataFeedId, string metricId, string detectionConfigurationId, string id, DateTimeOffset startTime, DateTimeOffset endTime, SeriesIdentity rootNode, IncidentProperty property)
 {
     DataFeedId = dataFeedId;
     MetricId   = metricId;
     DetectionConfigurationId = detectionConfigurationId;
     Id                      = id;
     StartTime               = startTime;
     LastTime                = endTime;
     RootDimensionKey        = new DimensionKey(rootNode.Dimension);
     Severity                = property.MaxSeverity;
     Status                  = property.IncidentStatus;
     ValueOfRootNode         = property.ValueOfRootNode;
     ExpectedValueOfRootNode = property.ExpectedValueOfRootNode;
 }
 internal AnomalyIncident(string metricId, string detectionConfigurationId, string id, DateTimeOffset startTime, DateTimeOffset endTime, SeriesIdentity rootNode, IncidentProperty property)
 {
     MetricId = metricId;
     DetectionConfigurationId = detectionConfigurationId;
     Id             = id;
     StartTime      = startTime;
     EndTime        = endTime;
     DimensionKey   = new DimensionKey(rootNode.Dimension);
     Severity       = property.MaxSeverity;
     IncidentStatus = property.IncidentStatus;
 }