コード例 #1
0
 internal DynamicMetricCriteria(CriterionType criterionType, string name, string metricName, string metricNamespace, AggregationTypeEnum timeAggregation, IList <MetricDimension> dimensions, bool?skipMetricValidation, IDictionary <string, BinaryData> additionalProperties, DynamicThresholdOperator @operator, DynamicThresholdSensitivity alertSensitivity, DynamicThresholdFailingPeriods failingPeriods, DateTimeOffset?ignoreDataBefore) : base(criterionType, name, metricName, metricNamespace, timeAggregation, dimensions, skipMetricValidation, additionalProperties)
 {
     Operator         = @operator;
     AlertSensitivity = alertSensitivity;
     FailingPeriods   = failingPeriods;
     IgnoreDataBefore = ignoreDataBefore;
     CriterionType    = criterionType;
 }
コード例 #2
0
        public DynamicMetricCriteria(string name, string metricName, AggregationTypeEnum 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;
            AggregationTypeEnum timeAggregation                             = default;
            Optional <IList <MetricDimension> > dimensions                  = default;
            Optional <bool> skipMetricValidation                            = default;
            IDictionary <string, BinaryData> additionalProperties           = default;
            Dictionary <string, BinaryData>  additionalPropertiesDictionary = new Dictionary <string, BinaryData>();

            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 = new AggregationTypeEnum(property.Value.GetString());
                    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;
                }
                if (property.NameEquals("skipMetricValidation"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    skipMetricValidation = property.Value.GetBoolean();
                    continue;
                }
                additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText()));
            }
            additionalProperties = additionalPropertiesDictionary;
            return(new DynamicMetricCriteria(criterionType, name, metricName, metricNamespace.Value, timeAggregation, Optional.ToList(dimensions), Optional.ToNullable(skipMetricValidation), additionalProperties, @operator, alertSensitivity, failingPeriods, Optional.ToNullable(ignoreDataBefore)));
        }