/// <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));
        }
        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));
        }
Пример #3
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;
 }