internal static TriggerCondition DeserializeTriggerCondition(JsonElement element) { ConditionalOperator thresholdOperator = default; double threshold = default; Optional <LogMetricTrigger> metricTrigger = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("thresholdOperator")) { thresholdOperator = new ConditionalOperator(property.Value.GetString()); continue; } if (property.NameEquals("threshold")) { threshold = property.Value.GetDouble(); continue; } if (property.NameEquals("metricTrigger")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } metricTrigger = LogMetricTrigger.DeserializeLogMetricTrigger(property.Value); continue; } } return(new TriggerCondition(thresholdOperator, threshold, metricTrigger.Value)); }
internal static LogMetricTrigger DeserializeLogMetricTrigger(JsonElement element) { Optional <ConditionalOperator> thresholdOperator = default; Optional <double> threshold = default; Optional <MetricTriggerType> metricTriggerType = default; Optional <string> metricColumn = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("thresholdOperator")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } thresholdOperator = new ConditionalOperator(property.Value.GetString()); continue; } if (property.NameEquals("threshold")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } threshold = property.Value.GetDouble(); continue; } if (property.NameEquals("metricTriggerType")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } metricTriggerType = new MetricTriggerType(property.Value.GetString()); continue; } if (property.NameEquals("metricColumn")) { metricColumn = property.Value.GetString(); continue; } } return(new LogMetricTrigger(Optional.ToNullable(thresholdOperator), Optional.ToNullable(threshold), Optional.ToNullable(metricTriggerType), metricColumn.Value)); }