internal DynamicMetricCriteria(CriterionType criterionType, string name, string metricName, string metricNamespace, AggregationType timeAggregation, IList <MetricDimension> dimensions, IDictionary <string, object> additionalProperties, DynamicThresholdOperator @operator, DynamicThresholdSensitivity alertSensitivity, DynamicThresholdFailingPeriods failingPeriods, DateTimeOffset?ignoreDataBefore) : base(criterionType, name, metricName, metricNamespace, timeAggregation, dimensions, additionalProperties) { Operator = @operator; AlertSensitivity = alertSensitivity; FailingPeriods = failingPeriods; IgnoreDataBefore = ignoreDataBefore; CriterionType = criterionType; }
public DynamicMetricCriteria(string name, string metricName, AggregationType timeAggregation, DynamicThresholdOperator @operator, DynamicThresholdSensitivity alertSensitivity, DynamicThresholdFailingPeriods failingPeriods) : base(name, metricName, timeAggregation) { if (name == null) { throw new ArgumentNullException(nameof(name)); } if (metricName == null) { throw new ArgumentNullException(nameof(metricName)); } if (failingPeriods == null) { throw new ArgumentNullException(nameof(failingPeriods)); } Operator = @operator; AlertSensitivity = alertSensitivity; FailingPeriods = failingPeriods; CriterionType = CriterionType.DynamicThresholdCriterion; }
internal static DynamicMetricCriteria DeserializeDynamicMetricCriteria(JsonElement element) { DynamicThresholdOperator @operator = default; DynamicThresholdSensitivity alertSensitivity = default; DynamicThresholdFailingPeriods failingPeriods = default; Optional <DateTimeOffset> ignoreDataBefore = default; CriterionType criterionType = default; string name = default; string metricName = default; Optional <string> metricNamespace = default; AggregationType timeAggregation = default; Optional <IList <MetricDimension> > dimensions = default; IDictionary <string, object> additionalProperties = default; Dictionary <string, object> additionalPropertiesDictionary = new Dictionary <string, object>(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("operator")) { @operator = new DynamicThresholdOperator(property.Value.GetString()); continue; } if (property.NameEquals("alertSensitivity")) { alertSensitivity = new DynamicThresholdSensitivity(property.Value.GetString()); continue; } if (property.NameEquals("failingPeriods")) { failingPeriods = DynamicThresholdFailingPeriods.DeserializeDynamicThresholdFailingPeriods(property.Value); continue; } if (property.NameEquals("ignoreDataBefore")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } ignoreDataBefore = property.Value.GetDateTimeOffset("O"); continue; } if (property.NameEquals("criterionType")) { criterionType = new CriterionType(property.Value.GetString()); continue; } if (property.NameEquals("name")) { name = property.Value.GetString(); continue; } if (property.NameEquals("metricName")) { metricName = property.Value.GetString(); continue; } if (property.NameEquals("metricNamespace")) { metricNamespace = property.Value.GetString(); continue; } if (property.NameEquals("timeAggregation")) { timeAggregation = property.Value.GetString().ToAggregationType(); continue; } if (property.NameEquals("dimensions")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } List <MetricDimension> array = new List <MetricDimension>(); foreach (var item in property.Value.EnumerateArray()) { array.Add(MetricDimension.DeserializeMetricDimension(item)); } dimensions = array; continue; } additionalPropertiesDictionary.Add(property.Name, property.Value.GetObject()); } additionalProperties = additionalPropertiesDictionary; return(new DynamicMetricCriteria(criterionType, name, metricName, metricNamespace.Value, timeAggregation, Optional.ToList(dimensions), additionalProperties, @operator, alertSensitivity, failingPeriods, Optional.ToNullable(ignoreDataBefore))); }