public async Task AddFeedbackAsync() { string endpoint = MetricsAdvisorUri; string subscriptionKey = MetricsAdvisorSubscriptionKey; string apiKey = MetricsAdvisorApiKey; var credential = new MetricsAdvisorKeyCredential(subscriptionKey, apiKey); var client = new MetricsAdvisorClient(new Uri(endpoint), credential); string metricId = MetricId; FeedbackDimensionFilter filter = new FeedbackDimensionFilter(); filter.DimensionFilter.AddDimensionColumn("city", "Belo Horizonte"); var startTime = DateTimeOffset.Parse("2020-02-01T00:00:00Z"); var endTime = DateTimeOffset.Parse("2020-02-03T00:00:00Z"); // Other types of feedback, such as MetricCommentFeedback, MetricChangePointFeedback, // and MetricPeriodFeedback are supported as well. var anomalyFeedback = new MetricAnomalyFeedback(metricId, filter, startTime, endTime, AnomalyValue.NotAnomaly); Response <MetricFeedback> response = await client.AddFeedbackAsync(anomalyFeedback); MetricFeedback addedFeedback = response.Value; Console.WriteLine($"Feedback ID: {addedFeedback.Id}"); }
public async Task AddAndGetCommentFeedbackWithOptionalTimeFilters() { MetricsAdvisorClient client = GetMetricsAdvisorClient(); var filter = new FeedbackDimensionFilter(); filter.DimensionFilter.AddDimensionColumn("city", ExpectedCity); filter.DimensionFilter.AddDimensionColumn("category", ExpectedCategory); var comment = "Feedback created in a .NET test."; var feedbackToAdd = new MetricCommentFeedback(MetricId, filter, comment) { StartTime = CreatedFeedbackStartTime, EndTime = CreatedFeedbackEndTime }; MetricFeedback addedFeedback = await client.AddFeedbackAsync(feedbackToAdd); ValidateMetricFeedback(addedFeedback); Assert.That(addedFeedback.Type, Is.EqualTo(FeedbackType.Comment)); var commentFeedback = addedFeedback as MetricCommentFeedback; Assert.That(commentFeedback, Is.Not.Null); Assert.That(commentFeedback.Comment, Is.EqualTo(comment)); Assert.That(commentFeedback.StartTime, Is.EqualTo(CreatedFeedbackStartTime)); Assert.That(commentFeedback.EndTime, Is.EqualTo(CreatedFeedbackEndTime)); }
public async Task AddAndGetPeriodFeedback() { MetricsAdvisorClient client = GetMetricsAdvisorClient(); var filter = new FeedbackDimensionFilter(); filter.DimensionFilter.AddDimensionColumn("city", ExpectedCity); filter.DimensionFilter.AddDimensionColumn("category", ExpectedCategory); var periodValue = 10; var feedbackToAdd = new MetricPeriodFeedback(MetricId, filter, PeriodType.AutoDetect, periodValue); MetricFeedback addedFeedback = await client.AddFeedbackAsync(feedbackToAdd); ValidateMetricFeedback(addedFeedback); Assert.That(addedFeedback.Type, Is.EqualTo(FeedbackType.Period)); var periodFeedback = addedFeedback as MetricPeriodFeedback; Assert.That(periodFeedback, Is.Not.Null); Assert.That(periodFeedback.PeriodType, Is.EqualTo(PeriodType.AutoDetect)); Assert.That(periodFeedback.PeriodValue, Is.EqualTo(periodValue)); }
/// <summary> Initializes a new <see cref="MetricCommentFeedback"/> instance. </summary> /// <param name="metricId"> The metric unique id. </param> /// <param name="dimensionFilter"> The <see cref="FeedbackDimensionFilter"/> to apply to the feedback. </param> /// <param name="comment"> The comment content for the feedback. </param> /// <exception cref="ArgumentNullException"> <paramref name="dimensionFilter"/> or <paramref name="comment"/> is null. </exception> public MetricCommentFeedback(string metricId, FeedbackDimensionFilter dimensionFilter, string comment) : base(metricId, dimensionFilter) { Argument.AssertNotNullOrEmpty(comment, nameof(comment)); ValueInternal = new CommentFeedbackValue(comment); Type = FeedbackType.Comment; }
public async Task AddAndGetPeriodFeedback() { MetricsAdvisorClient client = GetMetricsAdvisorClient(); var dimensionKey = new DimensionKey(); dimensionKey.AddDimensionColumn("city", "Delhi"); dimensionKey.AddDimensionColumn("category", "Handmade"); var filter = new FeedbackDimensionFilter(dimensionKey); var periodValue = 10; var feedbackToAdd = new MetricPeriodFeedback(MetricId, filter, PeriodType.AutoDetect, periodValue); string feedbackId = await client.AddFeedbackAsync(feedbackToAdd); Assert.That(feedbackId, Is.Not.Null); MetricFeedback addedFeedback = await client.GetFeedbackAsync(feedbackId); ValidateMetricFeedback(addedFeedback, feedbackId, dimensionKey); Assert.That(addedFeedback.Type, Is.EqualTo(FeedbackType.Period)); var periodFeedback = addedFeedback as MetricPeriodFeedback; Assert.That(periodFeedback, Is.Not.Null); Assert.That(periodFeedback.PeriodType, Is.EqualTo(PeriodType.AutoDetect)); Assert.That(periodFeedback.PeriodValue, Is.EqualTo(periodValue)); }
public async Task AddAndGetCommentFeedbackWithOptionalTimeFilters() { MetricsAdvisorClient client = GetMetricsAdvisorClient(); var dimensionKey = new DimensionKey(); dimensionKey.AddDimensionColumn("city", "Delhi"); dimensionKey.AddDimensionColumn("category", "Handmade"); var filter = new FeedbackDimensionFilter(dimensionKey); var comment = "Feedback created in a .NET test."; var feedbackToAdd = new MetricCommentFeedback(MetricId, filter, comment) { StartTime = CreatedFeedbackStartTime, EndTime = CreatedFeedbackEndTime }; string feedbackId = await client.AddFeedbackAsync(feedbackToAdd); Assert.That(feedbackId, Is.Not.Null); MetricFeedback addedFeedback = await client.GetFeedbackAsync(feedbackId); ValidateMetricFeedback(addedFeedback, feedbackId, dimensionKey); Assert.That(addedFeedback.Type, Is.EqualTo(FeedbackType.Comment)); var commentFeedback = addedFeedback as MetricCommentFeedback; Assert.That(commentFeedback, Is.Not.Null); Assert.That(commentFeedback.Comment, Is.EqualTo(comment)); Assert.That(commentFeedback.StartTime, Is.EqualTo(CreatedFeedbackStartTime)); Assert.That(commentFeedback.EndTime, Is.EqualTo(CreatedFeedbackEndTime)); }
public async Task AddAndGetAnomalyFeedbackWithOptionalDetectionConfigurationFilter() { MetricsAdvisorClient client = GetMetricsAdvisorClient(); var dimensionKey = new DimensionKey(); dimensionKey.AddDimensionColumn("city", "Delhi"); dimensionKey.AddDimensionColumn("category", "Handmade"); var filter = new FeedbackDimensionFilter(dimensionKey); var feedbackToAdd = new MetricAnomalyFeedback(MetricId, filter, CreatedFeedbackStartTime, CreatedFeedbackEndTime, AnomalyValue.AutoDetect) { AnomalyDetectionConfigurationId = DetectionConfigurationId }; string feedbackId = await client.AddFeedbackAsync(feedbackToAdd); Assert.That(feedbackId, Is.Not.Null); MetricFeedback addedFeedback = await client.GetFeedbackAsync(feedbackId); ValidateMetricFeedback(addedFeedback, feedbackId, dimensionKey); Assert.That(addedFeedback.Type, Is.EqualTo(FeedbackType.Anomaly)); var anomalyFeedback = addedFeedback as MetricAnomalyFeedback; Assert.That(anomalyFeedback, Is.Not.Null); Assert.That(anomalyFeedback.AnomalyValue, Is.EqualTo(AnomalyValue.AutoDetect)); Assert.That(anomalyFeedback.StartTime, Is.EqualTo(CreatedFeedbackStartTime)); Assert.That(anomalyFeedback.EndTime, Is.EqualTo(CreatedFeedbackEndTime)); Assert.That(anomalyFeedback.AnomalyDetectionConfigurationId, Is.EqualTo(DetectionConfigurationId)); // TODO: Add snapshot validation (https://github.com/azure/azure-sdk-for-net/issues/15915) }
public async Task AddAndGetAnomalyFeedbackWithMinimumSetup(bool useTokenCredential) { MetricsAdvisorClient client = GetMetricsAdvisorClient(useTokenCredential); var dimensionKey = new DimensionKey(); dimensionKey.AddDimensionColumn("city", "Delhi"); dimensionKey.AddDimensionColumn("category", "Handmade"); var filter = new FeedbackDimensionFilter(dimensionKey); var feedbackToAdd = new MetricAnomalyFeedback(MetricId, filter, CreatedFeedbackStartTime, CreatedFeedbackEndTime, AnomalyValue.AutoDetect); string feedbackId = await client.AddFeedbackAsync(feedbackToAdd); Assert.That(feedbackId, Is.Not.Null); MetricFeedback addedFeedback = await client.GetFeedbackAsync(feedbackId); ValidateMetricFeedback(addedFeedback, feedbackId, dimensionKey); Assert.That(addedFeedback.Type, Is.EqualTo(FeedbackType.Anomaly)); var anomalyFeedback = addedFeedback as MetricAnomalyFeedback; Assert.That(anomalyFeedback, Is.Not.Null); Assert.That(anomalyFeedback.AnomalyValue, Is.EqualTo(AnomalyValue.AutoDetect)); Assert.That(anomalyFeedback.StartTime, Is.EqualTo(CreatedFeedbackStartTime)); Assert.That(anomalyFeedback.EndTime, Is.EqualTo(CreatedFeedbackEndTime)); Assert.That(anomalyFeedback.AnomalyDetectionConfigurationId, Is.Null); Assert.That(anomalyFeedback.AnomalyDetectionConfigurationSnapshot, Is.Null); }
/// <summary> Initializes a new <see cref="MetricCommentFeedback"/> instance. </summary> /// <param name="metricId"> The metric unique id. </param> /// <param name="dimensionFilter"> The <see cref="FeedbackDimensionFilter"/> to apply to the feedback. </param> /// <param name="comment"> The comment content for the feedback. </param> /// <exception cref="ArgumentNullException"> <paramref name="dimensionFilter"/> or <paramref name="comment"/> is null. </exception> internal MetricCommentFeedback(string metricId, FeedbackDimensionFilter dimensionFilter, CommentFeedbackValue comment) : base(metricId, dimensionFilter) { Argument.AssertNotNullOrEmpty(comment?.CommentValue, nameof(comment.CommentValue)); ValueInternal = comment; Type = FeedbackType.Comment; }
public async Task AddAndGetChangePointFeedback() { MetricsAdvisorClient client = GetMetricsAdvisorClient(); var dimensionKey = new DimensionKey(); dimensionKey.AddDimensionColumn("city", "Delhi"); dimensionKey.AddDimensionColumn("category", "Handmade"); var filter = new FeedbackDimensionFilter(dimensionKey); var feedbackToAdd = new MetricChangePointFeedback(MetricId, filter, CreatedFeedbackStartTime, CreatedFeedbackEndTime, ChangePointValue.AutoDetect); string feedbackId = await client.AddFeedbackAsync(feedbackToAdd); Assert.That(feedbackId, Is.Not.Null); MetricFeedback addedFeedback = await client.GetFeedbackAsync(feedbackId); ValidateMetricFeedback(addedFeedback, feedbackId, dimensionKey); Assert.That(addedFeedback.Type, Is.EqualTo(FeedbackType.ChangePoint)); var changePointFeedback = addedFeedback as MetricChangePointFeedback; Assert.That(changePointFeedback, Is.Not.Null); Assert.That(changePointFeedback.ChangePointValue, Is.EqualTo(ChangePointValue.AutoDetect)); Assert.That(changePointFeedback.StartTime, Is.EqualTo(CreatedFeedbackStartTime)); Assert.That(changePointFeedback.EndTime, Is.EqualTo(CreatedFeedbackEndTime)); }
/// <summary> Initializes a new <see cref="MetricPeriodFeedback"/> instance. </summary> /// <param name="metricId"> The metric unique id. </param> /// <param name="dimensionFilter"> The <see cref="FeedbackDimensionFilter"/> to apply to the feedback. </param> /// <param name="periodType"> The <see cref="Models.PeriodType"/>. </param> /// <param name="periodValue"> The period value. </param> /// <exception cref="ArgumentNullException"> <paramref name="metricId"/> or <paramref name="dimensionFilter"/> is null. </exception> /// <exception cref="ArgumentException"> <paramref name="metricId"/> is empty. </exception> public MetricPeriodFeedback(string metricId, FeedbackDimensionFilter dimensionFilter, PeriodType periodType, int periodValue) : base(metricId, dimensionFilter) { Argument.AssertNotNullOrEmpty(metricId, nameof(metricId)); Argument.AssertNotNull(dimensionFilter, nameof(dimensionFilter)); ValueInternal = new PeriodFeedbackValue(periodType, periodValue); Type = FeedbackType.Period; }
/// <summary> Initializes a new instance of the <see cref="MetricFeedback"/> class. </summary> /// <param name="metricId"> The metric unique Id. </param> /// <param name="dimensionFilter"> The <see cref="FeedbackDimensionFilter" /> to apply to the feedback. </param> /// <exception cref="ArgumentNullException"> <paramref name="dimensionFilter"/> is null. </exception> internal MetricFeedback(string metricId, FeedbackDimensionFilter dimensionFilter) { Argument.AssertNotNullOrEmpty(metricId, nameof(metricId)); Argument.AssertNotNull(dimensionFilter, nameof(dimensionFilter)); MetricId = metricId; DimensionFilter = dimensionFilter; }
internal MetricFeedback(FeedbackType type, string id, DateTimeOffset?createdTime, string userPrincipal, string metricId, FeedbackDimensionFilter dimensionFilter) { Type = type; Id = id; CreatedTime = createdTime; UserPrincipal = userPrincipal; MetricId = metricId; DimensionFilter = dimensionFilter; }
/// <summary> Initializes a new <see cref="MetricChangePointFeedback"/> instance. </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.ChangePointFeedbackValue"/> for the feedback. </param> internal MetricChangePointFeedback(string metricId, FeedbackDimensionFilter dimensionFilter, DateTimeOffset startTime, DateTimeOffset endTime, ChangePointFeedbackValue value) : base(metricId, dimensionFilter) { Argument.AssertNotNull(value, nameof(value)); StartTime = startTime; EndTime = endTime; ValueInternal = value; Type = Models.FeedbackType.ChangePoint; }
internal static MetricPeriodFeedback DeserializeMetricPeriodFeedback(JsonElement element) { PeriodFeedbackValue value = 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("value")) { value = PeriodFeedbackValue.DeserializePeriodFeedbackValue(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")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } 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 MetricPeriodFeedback(feedbackType, feedbackId.Value, Optional.ToNullable(createdTime), userPrincipal.Value, metricId, dimensionFilter, value)); }
/// <summary> Initializes a new <see cref="MetricChangePointFeedback"/> instance. </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.ChangePointValue"/> for the feedback. </param> /// <exception cref="ArgumentNullException"> <paramref name="dimensionFilter"/> or <paramref name="value"/> is null. </exception> public MetricChangePointFeedback(string metricId, FeedbackDimensionFilter dimensionFilter, DateTimeOffset startTime, DateTimeOffset endTime, ChangePointValue value) : base(metricId, dimensionFilter) { if (value == default) { throw new ArgumentNullException(nameof(value)); } StartTime = startTime; EndTime = endTime; ValueInternal = new ChangePointFeedbackValue(value); Type = FeedbackType.ChangePoint; }
/// <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; }
public void AddFeedbackRespectsTheCancellationToken() { MetricsAdvisorClient client = GetMetricsAdvisorClient(); var filter = new FeedbackDimensionFilter(new DimensionKey()); var feedback = new MetricCommentFeedback(FakeGuid, filter, "comment"); using var cancellationSource = new CancellationTokenSource(); cancellationSource.Cancel(); Assert.That(() => client.AddFeedbackAsync(feedback, cancellationSource.Token), Throws.InstanceOf <OperationCanceledException>()); Assert.That(() => client.AddFeedback(feedback, cancellationSource.Token), Throws.InstanceOf <OperationCanceledException>()); }
/// <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; }
/// <summary> Initializes a new instance of MetricPeriodFeedback. </summary> /// <param name="metricId"> metric unique id. </param> /// <param name="dimensionFilter"> . </param> /// <param name="valueInternal"> . </param> /// <exception cref="ArgumentNullException"> <paramref name="metricId"/>, <paramref name="dimensionFilter"/>, or <paramref name="valueInternal"/> is null. </exception> internal MetricPeriodFeedback(string metricId, FeedbackDimensionFilter dimensionFilter, PeriodFeedbackValue valueInternal) : base(metricId, dimensionFilter) { if (metricId == null) { throw new ArgumentNullException(nameof(metricId)); } if (dimensionFilter == null) { throw new ArgumentNullException(nameof(dimensionFilter)); } if (valueInternal == null) { throw new ArgumentNullException(nameof(valueInternal)); } ValueInternal = valueInternal; Type = FeedbackType.Period; }
public async Task CreateMetricFeedback() { var client = GetMetricsAdvisorClient(); FeedbackDimensionFilter dimensionFilter = new FeedbackDimensionFilter( new DimensionKey( new Dictionary <string, string> { { "Dim1", "Common Lime" }, { "Dim2", "Ant" } })); DateTimeOffset start = Recording.UtcNow.AddMonths(-4); DateTimeOffset end = Recording.UtcNow; MetricAnomalyFeedback anomalyFeedback = new MetricAnomalyFeedback(MetricId, dimensionFilter, start, end, AnomalyValue.NotAnomaly); MetricChangePointFeedback changePointFeedback = new MetricChangePointFeedback(MetricId, dimensionFilter, start, end, ChangePointValue.NotChangePoint); MetricPeriodFeedback periodFeedback = new MetricPeriodFeedback(MetricId, dimensionFilter, PeriodType.AssignValue, 5); MetricCommentFeedback commentFeedback = new MetricCommentFeedback(MetricId, dimensionFilter, "my comment"); var feedbacks = new List <MetricFeedback> { anomalyFeedback, changePointFeedback, periodFeedback, commentFeedback }; foreach (var feedback in feedbacks) { MetricFeedback createdFeedback = await client.CreateMetricFeedbackAsync(feedback).ConfigureAwait(false); Assert.That(createdFeedback.MetricId, Is.EqualTo(MetricId)); Assert.That(createdFeedback.Id, Is.Not.Null); MetricFeedback getFeedback = await client.GetMetricFeedbackAsync(feedbackId : createdFeedback.Id).ConfigureAwait(false); Assert.That(getFeedback.Id, Is.EqualTo(createdFeedback.Id)); } }
public async Task AddAndGetChangePointFeedback() { MetricsAdvisorClient client = GetMetricsAdvisorClient(); var filter = new FeedbackDimensionFilter(); filter.DimensionFilter.AddDimensionColumn("city", ExpectedCity); filter.DimensionFilter.AddDimensionColumn("category", ExpectedCategory); var feedbackToAdd = new MetricChangePointFeedback(MetricId, filter, CreatedFeedbackStartTime, CreatedFeedbackEndTime, ChangePointValue.AutoDetect); MetricFeedback addedFeedback = await client.AddFeedbackAsync(feedbackToAdd); ValidateMetricFeedback(addedFeedback); Assert.That(addedFeedback.Type, Is.EqualTo(FeedbackType.ChangePoint)); var changePointFeedback = addedFeedback as MetricChangePointFeedback; Assert.That(changePointFeedback, Is.Not.Null); Assert.That(changePointFeedback.ChangePointValue, Is.EqualTo(ChangePointValue.AutoDetect)); Assert.That(changePointFeedback.StartTime, Is.EqualTo(CreatedFeedbackStartTime)); Assert.That(changePointFeedback.EndTime, Is.EqualTo(CreatedFeedbackEndTime)); }
internal MetricPeriodFeedback(FeedbackType type, string id, DateTimeOffset?createdTime, string userPrincipal, string metricId, FeedbackDimensionFilter dimensionFilter, PeriodFeedbackValue valueInternal) : base(type, id, createdTime, userPrincipal, metricId, dimensionFilter) { ValueInternal = valueInternal; Type = type; }
internal static MetricAnomalyFeedback DeserializeMetricAnomalyFeedback(JsonElement element) { DateTimeOffset startTime = default; DateTimeOffset endTime = default; AnomalyFeedbackValue value = default; Optional <string> anomalyDetectionConfigurationId = default; Optional <AnomalyDetectionConfiguration> 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.GetString(); continue; } if (property.NameEquals("anomalyDetectionConfigurationSnapshot")) { if (property.Value.ValueKind == JsonValueKind.Null) { anomalyDetectionConfigurationSnapshot = null; continue; } anomalyDetectionConfigurationSnapshot = AnomalyDetectionConfiguration.DeserializeAnomalyDetectionConfiguration(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")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } 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, anomalyDetectionConfigurationId.Value, anomalyDetectionConfigurationSnapshot.Value)); }
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; }
internal MetricChangePointFeedback(FeedbackType type, string id, DateTimeOffset?createdTime, string userPrincipal, string metricId, FeedbackDimensionFilter dimensionFilter, DateTimeOffset startTime, DateTimeOffset endTime, ChangePointFeedbackValue valueInternal) : base(type, id, createdTime, userPrincipal, metricId, dimensionFilter) { StartTime = startTime; EndTime = endTime; ValueInternal = valueInternal; Type = type; }