Ejemplo n.º 1
0
 internal MultiMetricCriteria(CriterionType criterionType, string name, string metricName, string metricNamespace, AggregationTypeEnum timeAggregation, IList <MetricDimension> dimensions, bool?skipMetricValidation, IDictionary <string, BinaryData> additionalProperties)
 {
     CriterionType        = criterionType;
     Name                 = name;
     MetricName           = metricName;
     MetricNamespace      = metricNamespace;
     TimeAggregation      = timeAggregation;
     Dimensions           = dimensions;
     SkipMetricValidation = skipMetricValidation;
     AdditionalProperties = additionalProperties;
 }
Ejemplo n.º 2
0
        public MetricCriteria(string name, string metricName, AggregationTypeEnum timeAggregation, Operator @operator, double threshold) : base(name, metricName, timeAggregation)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }
            if (metricName == null)
            {
                throw new ArgumentNullException(nameof(metricName));
            }

            Operator      = @operator;
            Threshold     = threshold;
            CriterionType = CriterionType.StaticThresholdCriterion;
        }
Ejemplo n.º 3
0
        public MultiMetricCriteria(string name, string metricName, AggregationTypeEnum timeAggregation)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }
            if (metricName == null)
            {
                throw new ArgumentNullException(nameof(metricName));
            }

            Name                 = name;
            MetricName           = metricName;
            TimeAggregation      = timeAggregation;
            Dimensions           = new ChangeTrackingList <MetricDimension>();
            AdditionalProperties = new ChangeTrackingDictionary <string, BinaryData>();
        }
        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;
        }
Ejemplo n.º 5
0
 internal MetricCriteria(CriterionType criterionType, string name, string metricName, string metricNamespace, AggregationTypeEnum timeAggregation, IList <MetricDimension> dimensions, bool?skipMetricValidation, IDictionary <string, BinaryData> additionalProperties, Operator @operator, double threshold) : base(criterionType, name, metricName, metricNamespace, timeAggregation, dimensions, skipMetricValidation, additionalProperties)
 {
     Operator      = @operator;
     Threshold     = threshold;
     CriterionType = criterionType;
 }
        internal static MultiMetricCriteria DeserializeMultiMetricCriteria(JsonElement element)
        {
            if (element.TryGetProperty("criterionType", out JsonElement discriminator))
            {
                switch (discriminator.GetString())
                {
                case "DynamicThresholdCriterion": return(DynamicMetricCriteria.DeserializeDynamicMetricCriteria(element));

                case "StaticThresholdCriterion": return(MetricCriteria.DeserializeMetricCriteria(element));
                }
            }
            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("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 MultiMetricCriteria(criterionType, name, metricName, metricNamespace.Value, timeAggregation, Optional.ToList(dimensions), Optional.ToNullable(skipMetricValidation), additionalProperties));
        }
        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)));
        }
 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;
 }