Exemplo n.º 1
0
        internal static IncidentProperty DeserializeIncidentProperty(JsonElement element)
        {
            AnomalySeverity maxSeverity = default;
            Optional <AnomalyIncidentStatus> incidentStatus = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("maxSeverity"))
                {
                    maxSeverity = new AnomalySeverity(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("incidentStatus"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    incidentStatus = new AnomalyIncidentStatus(property.Value.GetString());
                    continue;
                }
            }
            return(new IncidentProperty(maxSeverity, Optional.ToNullable(incidentStatus)));
        }
Exemplo n.º 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 IncidentProperty DeserializeIncidentProperty(JsonElement element)
        {
            AnomalySeverity       maxSeverity    = default;
            AnomalyIncidentStatus 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 AnomalyIncidentStatus(property.Value.GetString());
                    continue;
                }
            }
            return(new IncidentProperty(maxSeverity, incidentStatus));
        }
        /// <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));
        }