internal static MetricAnomalyDetectionConditions DeserializeMetricAnomalyDetectionConditions(JsonElement element)
        {
            Optional <DetectionConditionsOperator> conditionOperator        = default;
            Optional <SmartDetectionCondition>     smartDetectionCondition  = default;
            Optional <HardThresholdCondition>      hardThresholdCondition   = default;
            Optional <ChangeThresholdCondition>    changeThresholdCondition = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("conditionOperator"))
                {
                    conditionOperator = new DetectionConditionsOperator(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("smartDetectionCondition"))
                {
                    smartDetectionCondition = Models.SmartDetectionCondition.DeserializeSmartDetectionCondition(property.Value);
                    continue;
                }
                if (property.NameEquals("hardThresholdCondition"))
                {
                    hardThresholdCondition = Models.HardThresholdCondition.DeserializeHardThresholdCondition(property.Value);
                    continue;
                }
                if (property.NameEquals("changeThresholdCondition"))
                {
                    changeThresholdCondition = Models.ChangeThresholdCondition.DeserializeChangeThresholdCondition(property.Value);
                    continue;
                }
            }
            return(new MetricAnomalyDetectionConditions(Optional.ToNullable(conditionOperator), smartDetectionCondition.Value, hardThresholdCondition.Value, changeThresholdCondition.Value));
        }
Ejemplo n.º 2
0
        internal static MetricSeriesGroupDetectionCondition DeserializeMetricSeriesGroupDetectionCondition(JsonElement element)
        {
            DimensionKey group = default;
            Optional <DetectionConditionsOperator> conditionOperator        = default;
            Optional <SmartDetectionCondition>     smartDetectionCondition  = default;
            Optional <HardThresholdCondition>      hardThresholdCondition   = default;
            Optional <ChangeThresholdCondition>    changeThresholdCondition = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("group"))
                {
                    group = DimensionKey.DeserializeDimensionKey(property.Value);
                    continue;
                }
                if (property.NameEquals("conditionOperator"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    conditionOperator = new DetectionConditionsOperator(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("smartDetectionCondition"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    smartDetectionCondition = Models.SmartDetectionCondition.DeserializeSmartDetectionCondition(property.Value);
                    continue;
                }
                if (property.NameEquals("hardThresholdCondition"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    hardThresholdCondition = Models.HardThresholdCondition.DeserializeHardThresholdCondition(property.Value);
                    continue;
                }
                if (property.NameEquals("changeThresholdCondition"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    changeThresholdCondition = Models.ChangeThresholdCondition.DeserializeChangeThresholdCondition(property.Value);
                    continue;
                }
            }
            return(new MetricSeriesGroupDetectionCondition(Optional.ToNullable(conditionOperator), smartDetectionCondition.Value, hardThresholdCondition.Value, changeThresholdCondition.Value, group));
        }