void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
 {
     writer.WriteStartObject();
     writer.WritePropertyName("anomalyValue");
     writer.WriteStringValue(AnomalyValue.ToString());
     writer.WriteEndObject();
 }
        internal static AnomalyFeedbackValue DeserializeAnomalyFeedbackValue(JsonElement element)
        {
            AnomalyValue anomalyValue = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("anomalyValue"))
                {
                    anomalyValue = new AnomalyValue(property.Value.GetString());
                    continue;
                }
            }
            return(new AnomalyFeedbackValue(anomalyValue));
        }
        /// <summary>
        /// Initializes a new instance of <see cref="MetricsAdvisor.MetricAnomalyFeedback"/> for mocking purposes.
        /// </summary>
        /// <param name="id">Sets the <see cref="MetricFeedback.Id"/> property.</param>
        /// <param name="createdOn">Sets the <see cref="MetricFeedback.CreatedOn"/> property.</param>
        /// <param name="userPrincipal">Sets the <see cref="MetricFeedback.UserPrincipal"/> property.</param>
        /// <param name="metricId">Sets the <see cref="MetricFeedback.MetricId"/> property.</param>
        /// <param name="dimensionKey">Sets the <see cref="MetricFeedback.DimensionKey"/> property.</param>
        /// <param name="startsOn">Sets the <see cref="MetricAnomalyFeedback.StartsOn"/> property.</param>
        /// <param name="endsOn">Sets the <see cref="MetricAnomalyFeedback.EndsOn"/> property.</param>
        /// <param name="anomalyValue">Sets the <see cref="MetricAnomalyFeedback.AnomalyValue"/> property.</param>
        /// <param name="detectionConfigurationId">Sets the <see cref="MetricAnomalyFeedback.DetectionConfigurationId"/> property.</param>
        /// <param name="detectionConfigurationSnapshot">Sets the <see cref="MetricAnomalyFeedback.DetectionConfigurationSnapshot"/> property.</param>
        /// <returns>A new instance of <see cref="MetricsAdvisor.MetricAnomalyFeedback"/> for mocking purposes.</returns>
        public static MetricAnomalyFeedback MetricAnomalyFeedback(string id = null, DateTimeOffset?createdOn = null, string userPrincipal = null, string metricId = null, DimensionKey dimensionKey = null, DateTimeOffset startsOn = default, DateTimeOffset endsOn = default, AnomalyValue anomalyValue = default, string detectionConfigurationId = null, AnomalyDetectionConfiguration detectionConfigurationSnapshot = null)
        {
            Dictionary <string, string> dimensions = dimensionKey?.ToDictionary(key => key.Key, key => key.Value);
            FeedbackFilter       filter            = new FeedbackFilter(dimensions);
            AnomalyFeedbackValue feedbackValue     = new AnomalyFeedbackValue(anomalyValue);

            return(new MetricAnomalyFeedback(MetricFeedbackKind.Anomaly, id, createdOn, userPrincipal, metricId, filter, startsOn, endsOn, feedbackValue, detectionConfigurationId, detectionConfigurationSnapshot));
        }
        /// <summary> Initializes a new instance of <see cref="MetricAnomalyFeedback"/>. </summary>
        /// <param name="metricId"> The metric unique id. </param>
        /// <param name="dimensionFilter"> The dimension filter. </param>
        /// <param name="startTime"> The start timestamp of feedback timerange. </param>
        /// <param name="endTime"> The end timestamp of feedback timerange. When this is equal to <paramref name="startTime"/> it indicates a single timestamp. </param>
        /// <param name="value"> The <see cref="Models.AnomalyValue"/> for the feedback. </param>
        /// <exception cref="ArgumentNullException"> <paramref name="dimensionFilter"/> or <paramref name="value"/> is null. </exception>
        public MetricAnomalyFeedback(string metricId, FeedbackDimensionFilter dimensionFilter, DateTimeOffset startTime, DateTimeOffset endTime, AnomalyValue value) : base(metricId, dimensionFilter)
        {
            if (value == default)
            {
                throw new ArgumentNullException(nameof(value));
            }

            DimensionFilter = dimensionFilter;
            StartTime       = startTime;
            EndTime         = endTime;
            ValueInternal   = new AnomalyFeedbackValue(value);
            Type            = FeedbackType.Anomaly;
        }