internal static AnomalyProperty DeserializeAnomalyProperty(JsonElement element)
        {
            AnomalySeverity          anomalySeverity = default;
            Optional <AnomalyStatus> anomalyStatus   = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("anomalySeverity"))
                {
                    anomalySeverity = new AnomalySeverity(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("anomalyStatus"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    anomalyStatus = new AnomalyStatus(property.Value.GetString());
                    continue;
                }
            }
            return(new AnomalyProperty(anomalySeverity, Optional.ToNullable(anomalyStatus)));
        }
Пример #2
0
        internal static IncidentProperty DeserializeIncidentProperty(JsonElement element)
        {
            AnomalySeverity       maxSeverity             = default;
            AnomalyIncidentStatus incidentStatus          = default;
            Optional <double>     valueOfRootNode         = default;
            Optional <double>     expectedValueOfRootNode = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("maxSeverity"))
                {
                    maxSeverity = new AnomalySeverity(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("incidentStatus"))
                {
                    incidentStatus = new AnomalyIncidentStatus(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("valueOfRootNode"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    valueOfRootNode = property.Value.GetDouble();
                    continue;
                }
                if (property.NameEquals("expectedValueOfRootNode"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    expectedValueOfRootNode = property.Value.GetDouble();
                    continue;
                }
            }
            return(new IncidentProperty(maxSeverity, incidentStatus, Optional.ToNullable(valueOfRootNode), Optional.ToNullable(expectedValueOfRootNode)));
        }
        internal static SeverityCondition DeserializeSeverityCondition(JsonElement element)
        {
            AnomalySeverity minAlertSeverity = default;
            AnomalySeverity maxAlertSeverity = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("minAlertSeverity"))
                {
                    minAlertSeverity = new AnomalySeverity(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("maxAlertSeverity"))
                {
                    maxAlertSeverity = new AnomalySeverity(property.Value.GetString());
                    continue;
                }
            }
            return(new SeverityCondition(minAlertSeverity, maxAlertSeverity));
        }
Пример #4
0
        internal static IncidentProperty DeserializeIncidentProperty(JsonElement element)
        {
            AnomalySeverity           maxSeverity    = default;
            Optional <IncidentStatus> incidentStatus = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("maxSeverity"))
                {
                    maxSeverity = new AnomalySeverity(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("incidentStatus"))
                {
                    incidentStatus = new IncidentStatus(property.Value.GetString());
                    continue;
                }
            }
            return(new IncidentProperty(maxSeverity, Optional.ToNullable(incidentStatus)));
        }
Пример #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SeverityCondition"/> class.
 /// </summary>
 /// <param name="minimumAlertSeverity">The minimum severity an anomaly must have to be included in an alert.</param>
 /// <param name="maximumAlertSeverity">The maximum severity an anomaly must have to be included in an alert.</param>
 public SeverityCondition(AnomalySeverity minimumAlertSeverity, AnomalySeverity maximumAlertSeverity)
 {
     MinimumAlertSeverity = minimumAlertSeverity;
     MaximumAlertSeverity = maximumAlertSeverity;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="GetAnomaliesForDetectionConfigurationFilter"/> class.
 /// </summary>
 /// <param name="minimumSeverity">The minimum severity level an anomaly must have to be returned.</param>
 /// <param name="maximumSeverity">The maximum severity level an anomaly must have to be returned.</param>
 public GetAnomaliesForDetectionConfigurationFilter(AnomalySeverity minimumSeverity, AnomalySeverity maximumSeverity)
 {
     MinimumSeverity = minimumSeverity;
     MaximumSeverity = maximumSeverity;
     SeriesGroupKeys = new ChangeTrackingList <DimensionKey>();
 }
        /// <summary>
        /// Initializes a new instance of <see cref="Models.AnomalyIncident"/> for mocking purposes.
        /// </summary>
        /// <param name="dataFeedId">Sets the <see cref="AnomalyIncident.DataFeedId"/> property.</param>
        /// <param name="metricId">Sets the <see cref="AnomalyIncident.MetricId"/> property.</param>
        /// <param name="detectionConfigurationId">Sets the <see cref="AnomalyIncident.DetectionConfigurationId"/> property.</param>
        /// <param name="id">Sets the <see cref="AnomalyIncident.Id"/> property.</param>
        /// <param name="startedOn">Sets the <see cref="AnomalyIncident.StartedOn"/> property.</param>
        /// <param name="lastDetectedOn">Sets the <see cref="AnomalyIncident.LastDetectedOn"/> property.</param>
        /// <param name="rootSeriesKey">Sets the <see cref="AnomalyIncident.RootSeriesKey"/> property.</param>
        /// <param name="severity">Sets the <see cref="AnomalyIncident.Severity"/> property.</param>
        /// <param name="status">Sets the <see cref="AnomalyIncident.Status"/> property.</param>
        /// <param name="valueOfRootNode">Sets the <see cref="AnomalyIncident.ValueOfRootNode"/> property.</param>
        /// <param name="expectedValueOfRootNode">Sets the <see cref="AnomalyIncident.ExpectedValueOfRootNode"/> property.</param>
        /// <returns>A new instance of <see cref="Models.AnomalyIncident"/> for mocking purposes.</returns>
        public static AnomalyIncident AnomalyIncident(string dataFeedId = null, string metricId = null, string detectionConfigurationId = null, string id = null, DateTimeOffset startedOn = default, DateTimeOffset lastDetectedOn = default, DimensionKey rootSeriesKey = null, AnomalySeverity severity = default, AnomalyIncidentStatus status = default, double valueOfRootNode = default, double?expectedValueOfRootNode = null)
        {
            Dictionary <string, string> dimensions       = rootSeriesKey?.ToDictionary(key => key.Key, key => key.Value);
            IncidentProperty            incidentProperty = new IncidentProperty(severity, status, valueOfRootNode, expectedValueOfRootNode);

            return(new AnomalyIncident(dataFeedId, metricId, detectionConfigurationId, id, startedOn, lastDetectedOn, new SeriesIdentity(dimensions), incidentProperty));
        }
        /// <summary>
        /// Initializes a new instance of <see cref="Models.DataPointAnomaly"/> for mocking purposes.
        /// </summary>
        /// <param name="dataFeedId">Sets the <see cref="DataPointAnomaly.DataFeedId"/> property.</param>
        /// <param name="metricId">Sets the <see cref="DataPointAnomaly.MetricId"/> property.</param>
        /// <param name="detectionConfigurationId">Sets the <see cref="DataPointAnomaly.DetectionConfigurationId"/> property.</param>
        /// <param name="timestamp">Sets the <see cref="DataPointAnomaly.Timestamp"/> property.</param>
        /// <param name="createdOn">Sets the <see cref="DataPointAnomaly.CreatedOn"/> property.</param>
        /// <param name="lastModified">Sets the <see cref="DataPointAnomaly.LastModified"/> property.</param>
        /// <param name="seriesKey">Sets the <see cref="DataPointAnomaly.SeriesKey"/> property.</param>
        /// <param name="severity">Sets the <see cref="DataPointAnomaly.Severity"/> property.</param>
        /// <param name="status">Sets the <see cref="DataPointAnomaly.Status"/> property.</param>
        /// <param name="value">Sets the <see cref="DataPointAnomaly.Value"/> property.</param>
        /// <param name="expectedValue">Sets the <see cref="DataPointAnomaly.ExpectedValue"/> property.</param>
        /// <returns>A new instance of <see cref="Models.DataPointAnomaly"/> for mocking purposes.</returns>
        public static DataPointAnomaly DataPointAnomaly(string dataFeedId = null, string metricId = null, string detectionConfigurationId = null, DateTimeOffset timestamp = default, DateTimeOffset?createdOn = null, DateTimeOffset?lastModified = null, DimensionKey seriesKey = null, AnomalySeverity severity = default, AnomalyStatus?status = null, double value = default, double?expectedValue = null)
        {
            Dictionary <string, string> dimensions      = seriesKey?.ToDictionary(key => key.Key, key => key.Value);
            AnomalyProperty             anomalyProperty = new AnomalyProperty(severity, status, value, expectedValue);

            return(new DataPointAnomaly(dataFeedId, metricId, detectionConfigurationId, timestamp, createdOn, lastModified, dimensions, anomalyProperty));
        }