internal static MetricAnomalyAlertSnoozeCondition DeserializeMetricAnomalyAlertSnoozeCondition(JsonElement element) { int autoSnooze = default; SnoozeScope snoozeScope = default; bool onlyForSuccessive = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("autoSnooze")) { autoSnooze = property.Value.GetInt32(); continue; } if (property.NameEquals("snoozeScope")) { snoozeScope = new SnoozeScope(property.Value.GetString()); continue; } if (property.NameEquals("onlyForSuccessive")) { onlyForSuccessive = property.Value.GetBoolean(); continue; } } return(new MetricAnomalyAlertSnoozeCondition(autoSnooze, snoozeScope, onlyForSuccessive)); }
void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) { writer.WriteStartObject(); writer.WritePropertyName("autoSnooze"); writer.WriteNumberValue(AutoSnooze); writer.WritePropertyName("snoozeScope"); writer.WriteStringValue(SnoozeScope.ToString()); writer.WritePropertyName("onlyForSuccessive"); writer.WriteBooleanValue(IsOnlyForSuccessive); writer.WriteEndObject(); }
/// <summary> /// Initializes a new instance of the <see cref="MetricAnomalyAlertSnoozeCondition"/> class. /// </summary> /// <param name="autoSnooze">The number of data points to be ingested before alerts are enabled again.</param> /// <param name="snoozeScope"> /// Defines the set of time series to which this <see cref="MetricAnomalyAlertSnoozeCondition"/> /// applies. Anomalies detected out of the specified scope can be added to alerts normally. /// </param> /// <param name="isOnlyForSuccessive"> /// If <c>true</c>, snoozing only continues as long as the subsequent data points are anomalies. It will stop /// as soon as a data point that's not an anomaly is found. If <c>false</c>, snoozing only stops when the /// amount of points specified by <paramref name="autoSnooze"/> have been ingested. /// </param> public MetricAnomalyAlertSnoozeCondition(int autoSnooze, SnoozeScope snoozeScope, bool isOnlyForSuccessive) { AutoSnooze = autoSnooze; SnoozeScope = snoozeScope; IsOnlyForSuccessive = isOnlyForSuccessive; }