void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) { writer.WriteStartObject(); writer.WritePropertyName("startTime"); writer.WriteStringValue(StartTime, "O"); writer.WritePropertyName("endTime"); writer.WriteStringValue(EndTime, "O"); writer.WritePropertyName("value"); writer.WriteObjectValue(Value); if (Optional.IsDefined(AnomalyDetectionConfigurationId)) { if (AnomalyDetectionConfigurationId != null) { writer.WritePropertyName("anomalyDetectionConfigurationId"); writer.WriteStringValue(AnomalyDetectionConfigurationId.Value); } else { writer.WriteNull("anomalyDetectionConfigurationId"); } } if (Optional.IsDefined(AnomalyDetectionConfigurationSnapshot)) { if (AnomalyDetectionConfigurationSnapshot != null) { writer.WritePropertyName("anomalyDetectionConfigurationSnapshot"); writer.WriteObjectValue(AnomalyDetectionConfigurationSnapshot); } else { writer.WriteNull("anomalyDetectionConfigurationSnapshot"); } } writer.WritePropertyName("feedbackType"); writer.WriteStringValue(FeedbackType.ToString()); writer.WritePropertyName("metricId"); writer.WriteStringValue(MetricId); writer.WritePropertyName("dimensionFilter"); writer.WriteObjectValue(DimensionFilter); writer.WriteEndObject(); }
void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) { writer.WriteStartObject(); if (Optional.IsDefined(StartTime)) { if (StartTime != null) { writer.WritePropertyName("startTime"); writer.WriteStringValue(StartTime.Value, "O"); } else { writer.WriteNull("startTime"); } } if (Optional.IsDefined(EndTime)) { if (EndTime != null) { writer.WritePropertyName("endTime"); writer.WriteStringValue(EndTime.Value, "O"); } else { writer.WriteNull("endTime"); } } writer.WritePropertyName("value"); writer.WriteObjectValue(Value); writer.WritePropertyName("feedbackType"); writer.WriteStringValue(FeedbackType.ToString()); writer.WritePropertyName("metricId"); writer.WriteStringValue(MetricId); writer.WritePropertyName("dimensionFilter"); writer.WriteObjectValue(DimensionFilter); writer.WriteEndObject(); }
internal PeriodFeedback(FeedbackType feedbackType, Guid?feedbackId, DateTimeOffset?createdTime, string userPrincipal, Guid metricId, FeedbackDimensionFilter dimensionFilter, PeriodFeedbackValue value) : base(feedbackType, feedbackId, createdTime, userPrincipal, metricId, dimensionFilter) { Value = value; FeedbackType = feedbackType; }
internal static MetricChangePointFeedback DeserializeMetricChangePointFeedback(JsonElement element) { DateTimeOffset startTime = default; DateTimeOffset endTime = default; ChangePointFeedbackValue 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("startTime")) { startTime = property.Value.GetDateTimeOffset("O"); continue; } if (property.NameEquals("endTime")) { endTime = property.Value.GetDateTimeOffset("O"); continue; } if (property.NameEquals("value")) { value = ChangePointFeedbackValue.DeserializeChangePointFeedbackValue(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 MetricChangePointFeedback(feedbackType, feedbackId.Value, Optional.ToNullable(createdTime), userPrincipal.Value, metricId, dimensionFilter, startTime, endTime, value)); }
internal static CommentFeedback DeserializeCommentFeedback(JsonElement element) { Optional <DateTimeOffset?> startTime = default; Optional <DateTimeOffset?> endTime = default; CommentFeedbackValue value = default; FeedbackType feedbackType = default; Optional <Guid> feedbackId = default; Optional <DateTimeOffset> createdTime = default; Optional <string> userPrincipal = default; Guid metricId = default; FeedbackDimensionFilter dimensionFilter = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("startTime")) { if (property.Value.ValueKind == JsonValueKind.Null) { startTime = null; continue; } startTime = property.Value.GetDateTimeOffset("O"); continue; } if (property.NameEquals("endTime")) { if (property.Value.ValueKind == JsonValueKind.Null) { endTime = null; continue; } endTime = property.Value.GetDateTimeOffset("O"); continue; } if (property.NameEquals("value")) { value = CommentFeedbackValue.DeserializeCommentFeedbackValue(property.Value); continue; } if (property.NameEquals("feedbackType")) { feedbackType = new FeedbackType(property.Value.GetString()); continue; } if (property.NameEquals("feedbackId")) { feedbackId = property.Value.GetGuid(); 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.GetGuid(); continue; } if (property.NameEquals("dimensionFilter")) { dimensionFilter = FeedbackDimensionFilter.DeserializeFeedbackDimensionFilter(property.Value); continue; } } return(new CommentFeedback(feedbackType, Optional.ToNullable(feedbackId), Optional.ToNullable(createdTime), userPrincipal.Value, metricId, dimensionFilter, Optional.ToNullable(startTime), Optional.ToNullable(endTime), value)); }
internal static MetricFeedback DeserializeMetricFeedback(JsonElement element) { if (element.TryGetProperty("feedbackType", out JsonElement discriminator)) { switch (discriminator.GetString()) { case "Anomaly": return(MetricAnomalyFeedback.DeserializeMetricAnomalyFeedback(element)); case "ChangePoint": return(MetricChangePointFeedback.DeserializeMetricChangePointFeedback(element)); case "Comment": return(MetricCommentFeedback.DeserializeMetricCommentFeedback(element)); case "Period": return(MetricPeriodFeedback.DeserializeMetricPeriodFeedback(element)); } } 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("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 MetricFeedback(feedbackType, feedbackId.Value, Optional.ToNullable(createdTime), userPrincipal.Value, metricId, dimensionFilter)); }
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)); }
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; }