/// <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)); }
internal AnomalyFeedback(FeedbackType feedbackType, Guid?feedbackId, DateTimeOffset?createdTime, string userPrincipal, Guid metricId, FeedbackDimensionFilter dimensionFilter, DateTimeOffset startTime, DateTimeOffset endTime, AnomalyFeedbackValue value, Guid?anomalyDetectionConfigurationId, MetricAnomalyDetectionConfiguration anomalyDetectionConfigurationSnapshot) : base(feedbackType, feedbackId, createdTime, userPrincipal, metricId, dimensionFilter) { StartTime = startTime; EndTime = endTime; Value = value; AnomalyDetectionConfigurationId = anomalyDetectionConfigurationId; AnomalyDetectionConfigurationSnapshot = anomalyDetectionConfigurationSnapshot; FeedbackType = feedbackType; }
internal MetricAnomalyFeedback(FeedbackType type, string id, DateTimeOffset?createdTime, string userPrincipal, string metricId, FeedbackDimensionFilter dimensionFilter, DateTimeOffset startTime, DateTimeOffset endTime, AnomalyFeedbackValue valueInternal, string anomalyDetectionConfigurationId, AnomalyDetectionConfiguration anomalyDetectionConfigurationSnapshot) : base(type, id, createdTime, userPrincipal, metricId, dimensionFilter) { StartTime = startTime; EndTime = endTime; ValueInternal = valueInternal; AnomalyDetectionConfigurationId = anomalyDetectionConfigurationId; AnomalyDetectionConfigurationSnapshot = anomalyDetectionConfigurationSnapshot; Type = type; }
/// <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="AnomalyFeedbackValue"/> for the feedback. </param> /// <exception cref="ArgumentNullException"> <paramref name="dimensionFilter"/> or <paramref name="value"/> is null. </exception> internal MetricAnomalyFeedback(string metricId, FeedbackDimensionFilter dimensionFilter, DateTimeOffset startTime, DateTimeOffset endTime, AnomalyFeedbackValue value) : base(metricId, dimensionFilter) { if (value == null) { throw new ArgumentNullException(nameof(value)); } StartTime = startTime; EndTime = endTime; ValueInternal = value; Type = Models.FeedbackType.Anomaly; }
/// <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; }
internal static MetricAnomalyFeedback DeserializeMetricAnomalyFeedback(JsonElement element) { DateTimeOffset startTime = default; DateTimeOffset endTime = default; AnomalyFeedbackValue value = default; Optional <Guid?> anomalyDetectionConfigurationId = default; Optional <MetricAnomalyDetectionConfiguration> anomalyDetectionConfigurationSnapshot = default; FeedbackType feedbackType = default; Optional <string> feedbackId = default; Optional <DateTimeOffset> createdTime = default; Optional <string> userPrincipal = default; string metricId = default; FeedbackDimensionFilter dimensionFilter = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("startTime")) { startTime = property.Value.GetDateTimeOffset("O"); continue; } if (property.NameEquals("endTime")) { endTime = property.Value.GetDateTimeOffset("O"); continue; } if (property.NameEquals("value")) { value = AnomalyFeedbackValue.DeserializeAnomalyFeedbackValue(property.Value); continue; } if (property.NameEquals("anomalyDetectionConfigurationId")) { if (property.Value.ValueKind == JsonValueKind.Null) { anomalyDetectionConfigurationId = null; continue; } anomalyDetectionConfigurationId = property.Value.GetGuid(); continue; } if (property.NameEquals("anomalyDetectionConfigurationSnapshot")) { if (property.Value.ValueKind == JsonValueKind.Null) { anomalyDetectionConfigurationSnapshot = null; continue; } anomalyDetectionConfigurationSnapshot = MetricAnomalyDetectionConfiguration.DeserializeMetricAnomalyDetectionConfiguration(property.Value); continue; } if (property.NameEquals("feedbackType")) { feedbackType = new FeedbackType(property.Value.GetString()); continue; } if (property.NameEquals("feedbackId")) { feedbackId = property.Value.GetString(); continue; } if (property.NameEquals("createdTime")) { createdTime = property.Value.GetDateTimeOffset("O"); continue; } if (property.NameEquals("userPrincipal")) { userPrincipal = property.Value.GetString(); continue; } if (property.NameEquals("metricId")) { metricId = property.Value.GetString(); continue; } if (property.NameEquals("dimensionFilter")) { dimensionFilter = FeedbackDimensionFilter.DeserializeFeedbackDimensionFilter(property.Value); continue; } } return(new MetricAnomalyFeedback(feedbackType, feedbackId.Value, Optional.ToNullable(createdTime), userPrincipal.Value, metricId, dimensionFilter, startTime, endTime, value, Optional.ToNullable(anomalyDetectionConfigurationId), anomalyDetectionConfigurationSnapshot.Value)); }