Esempio n. 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MetricAnomalyFeedback"/> class.
 /// </summary>
 /// <param name="metricId">The identifier of the metric to which the <see cref="MetricAnomalyFeedback"/> applies.</param>
 /// <param name="dimensionKey">
 /// A key that identifies a set of time series to which the <see cref="MetricAnomalyFeedback"/> applies.
 /// If all possible dimensions are set, this key uniquely identifies a single time series
 /// for the specified <paramref name="metricId"/>. If only a subset of dimensions are set, this
 /// key uniquely identifies a group of time series.
 /// </param>
 /// <param name="startsOn">The start timestamp of feedback time range.</param>
 /// <param name="endsOn">The end timestamp of feedback time range. When this is equal to <paramref name="startsOn"/> it indicates a single timestamp.</param>
 /// <param name="value">Indicates whether or not the data points should have been labeled as anomalies by the service.</param>
 /// <exception cref="ArgumentNullException"><paramref name="metricId"/> or <paramref name="dimensionKey"/> is <c>null</c>.</exception>
 /// <exception cref="ArgumentException"><paramref name="metricId"/> is empty.</exception>
 public MetricAnomalyFeedback(string metricId, DimensionKey dimensionKey, DateTimeOffset startsOn, DateTimeOffset endsOn, AnomalyValue value)
     : base(metricId, dimensionKey)
 {
     StartsOn      = startsOn;
     EndsOn        = endsOn;
     ValueInternal = new AnomalyFeedbackValue(value);
     FeedbackKind  = MetricFeedbackKind.Anomaly;
 }
 internal MetricAnomalyFeedback(MetricFeedbackKind feedbackKind, string id, DateTimeOffset?createdOn, string userPrincipal, string metricId, FeedbackFilter dimensionFilter, DateTimeOffset startsOn, DateTimeOffset endsOn, AnomalyFeedbackValue valueInternal, string detectionConfigurationId, AnomalyDetectionConfiguration detectionConfigurationSnapshot) : base(feedbackKind, id, createdOn, userPrincipal, metricId, dimensionFilter)
 {
     StartsOn                       = startsOn;
     EndsOn                         = endsOn;
     ValueInternal                  = valueInternal;
     DetectionConfigurationId       = detectionConfigurationId;
     DetectionConfigurationSnapshot = detectionConfigurationSnapshot;
     FeedbackKind                   = feedbackKind;
 }
Esempio n. 3
0
 internal MetricAnomalyFeedback(FeedbackType type, string id, DateTimeOffset?createdTime, string userPrincipal, string metricId, FeedbackDimensionFilter dimensionFilter, DateTimeOffset startTime, DateTimeOffset endTime, AnomalyFeedbackValue valueInternal, string anomalyDetectionConfigurationId, AnomalyDetectionConfiguration anomalyDetectionConfigurationSnapshot) : base(type, id, createdTime, userPrincipal, metricId, dimensionFilter)
 {
     StartTime     = startTime;
     EndTime       = endTime;
     ValueInternal = valueInternal;
     AnomalyDetectionConfigurationId       = anomalyDetectionConfigurationId;
     AnomalyDetectionConfigurationSnapshot = anomalyDetectionConfigurationSnapshot;
     Type = type;
 }
Esempio n. 4
0
        /// <summary> Initializes a new instance of <see cref="MetricAnomalyFeedback"/>. </summary>
        /// <param name="metricId"> The metric unique id. </param>
        /// <param name="dimensionFilter"> The dimension filter. </param>
        /// <param name="startTime"> The start timestamp of feedback timerange. </param>
        /// <param name="endTime"> The end timestamp of feedback timerange. When this is equal to <paramref name="startTime"/> it indicates a single timestamp. </param>
        /// <param name="value"> The <see cref="AnomalyFeedbackValue"/> for the feedback. </param>
        /// <exception cref="ArgumentNullException"> <paramref name="dimensionFilter"/> or <paramref name="value"/> is null. </exception>
        internal MetricAnomalyFeedback(string metricId, FeedbackDimensionFilter dimensionFilter, DateTimeOffset startTime, DateTimeOffset endTime, AnomalyFeedbackValue value) : base(metricId, dimensionFilter)
        {
            if (value == null)
            {
                throw new ArgumentNullException(nameof(value));
            }

            StartTime     = startTime;
            EndTime       = endTime;
            ValueInternal = value;
            Type          = Models.FeedbackType.Anomaly;
        }
Esempio n. 5
0
        /// <summary> Initializes a new instance of <see cref="MetricAnomalyFeedback"/>. </summary>
        /// <param name="metricId"> The metric unique id. </param>
        /// <param name="feedbackFilter"> The dimension filter. </param>
        /// <param name="startsOn"> The start timestamp of feedback timerange. </param>
        /// <param name="endsOn"> The end timestamp of feedback timerange. When this is equal to <paramref name="startsOn"/> it indicates a single timestamp. </param>
        /// <param name="value"> The <see cref="AnomalyFeedbackValue"/> for the feedback. </param>
        /// <exception cref="ArgumentNullException"> <paramref name="feedbackFilter"/> or <paramref name="value"/> is null. </exception>
        internal MetricAnomalyFeedback(string metricId, FeedbackFilter feedbackFilter, DateTimeOffset startsOn, DateTimeOffset endsOn, AnomalyFeedbackValue value)
            : base(metricId, feedbackFilter.DimensionKey)
        {
            if (value == null)
            {
                throw new ArgumentNullException(nameof(value));
            }

            StartsOn      = startsOn;
            EndsOn        = endsOn;
            ValueInternal = value;
            FeedbackKind  = MetricFeedbackKind.Anomaly;
        }
Esempio n. 6
0
        /// <summary> Initializes a new instance of <see cref="MetricAnomalyFeedback"/>. </summary>
        /// <param name="metricId"> The metric unique id. </param>
        /// <param name="dimensionFilter"> The dimension filter. </param>
        /// <param name="startTime"> The start timestamp of feedback timerange. </param>
        /// <param name="endTime"> The end timestamp of feedback timerange. When this is equal to <paramref name="startTime"/> it indicates a single timestamp. </param>
        /// <param name="value"> The <see cref="Models.AnomalyValue"/> for the feedback. </param>
        /// <exception cref="ArgumentNullException"> <paramref name="dimensionFilter"/> or <paramref name="value"/> is null. </exception>
        public MetricAnomalyFeedback(string metricId, FeedbackDimensionFilter dimensionFilter, DateTimeOffset startTime, DateTimeOffset endTime, AnomalyValue value) : base(metricId, dimensionFilter)
        {
            if (value == default)
            {
                throw new ArgumentNullException(nameof(value));
            }

            DimensionFilter = dimensionFilter;
            StartTime       = startTime;
            EndTime         = endTime;
            ValueInternal   = new AnomalyFeedbackValue(value);
            Type            = FeedbackType.Anomaly;
        }
Esempio n. 7
0
        internal static MetricAnomalyFeedback DeserializeMetricAnomalyFeedback(JsonElement element)
        {
            DateTimeOffset       startTime = default;
            DateTimeOffset       endTime   = default;
            AnomalyFeedbackValue value     = default;
            Optional <string>    anomalyDetectionConfigurationId = default;
            Optional <AnomalyDetectionConfiguration> anomalyDetectionConfigurationSnapshot = default;
            FeedbackType              feedbackType  = default;
            Optional <string>         feedbackId    = default;
            Optional <DateTimeOffset> createdTime   = default;
            Optional <string>         userPrincipal = default;
            string metricId = default;
            FeedbackDimensionFilter dimensionFilter = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("startTime"))
                {
                    startTime = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property.NameEquals("endTime"))
                {
                    endTime = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property.NameEquals("value"))
                {
                    value = AnomalyFeedbackValue.DeserializeAnomalyFeedbackValue(property.Value);
                    continue;
                }
                if (property.NameEquals("anomalyDetectionConfigurationId"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        anomalyDetectionConfigurationId = null;
                        continue;
                    }
                    anomalyDetectionConfigurationId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("anomalyDetectionConfigurationSnapshot"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        anomalyDetectionConfigurationSnapshot = null;
                        continue;
                    }
                    anomalyDetectionConfigurationSnapshot = AnomalyDetectionConfiguration.DeserializeAnomalyDetectionConfiguration(property.Value);
                    continue;
                }
                if (property.NameEquals("feedbackType"))
                {
                    feedbackType = new FeedbackType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("feedbackId"))
                {
                    feedbackId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("createdTime"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    createdTime = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property.NameEquals("userPrincipal"))
                {
                    userPrincipal = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("metricId"))
                {
                    metricId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("dimensionFilter"))
                {
                    dimensionFilter = FeedbackDimensionFilter.DeserializeFeedbackDimensionFilter(property.Value);
                    continue;
                }
            }
            return(new MetricAnomalyFeedback(feedbackType, feedbackId.Value, Optional.ToNullable(createdTime), userPrincipal.Value, metricId, dimensionFilter, startTime, endTime, value, anomalyDetectionConfigurationId.Value, anomalyDetectionConfigurationSnapshot.Value));
        }