use serde::{Deserialize, Serialize}; /*
                                      * Service Control API
                                      *
                                      * Provides admission control and telemetry reporting for services integrated with Service Infrastructure.
                                      *
                                      * The version of the OpenAPI document: v1
                                      *
                                      * Generated by: https://openapi-generator.tech
                                      */

use crate::google_rest_apis::servicecontrol_v1::models;

/// Distribution : Distribution represents a frequency distribution of double-valued sample points. It contains the size of the population of sample points plus additional optional information: * the arithmetic mean of the samples * the minimum and maximum of the samples * the sum-squared-deviation of the samples, used to compute variance * a histogram of the values of the sample points
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct Distribution {
    /// The number of samples in each histogram bucket. `bucket_counts` are optional. If present, they must sum to the `count` value. The buckets are defined below in `bucket_option`. There are N buckets. `bucket_counts[0]` is the number of samples in the underflow bucket. `bucket_counts[1]` to `bucket_counts[N-1]` are the numbers of samples in each of the finite buckets. And `bucket_counts[N] is the number of samples in the overflow bucket. See the comments of `bucket_option` below for more details. Any suffix of trailing zeros may be omitted.
    #[serde(rename = "bucketCounts", skip_serializing_if = "Option::is_none")]
    pub bucket_counts: Option<Vec<String>>,
    /// The total number of samples in the distribution. Must be >= 0.
    #[serde(rename = "count", skip_serializing_if = "Option::is_none")]
    pub count: Option<String>,
    /// Example points. Must be in increasing order of `value` field.
    #[serde(rename = "exemplars", skip_serializing_if = "Option::is_none")]
    pub exemplars: Option<Vec<models::Exemplar>>,
    #[serde(rename = "explicitBuckets", skip_serializing_if = "Option::is_none")]
    pub explicit_buckets: Option<Box<models::ExplicitBuckets>>,
    #[serde(rename = "exponentialBuckets", skip_serializing_if = "Option::is_none")]
    pub exponential_buckets: Option<Box<models::ExponentialBuckets>>,
    #[serde(rename = "linearBuckets", skip_serializing_if = "Option::is_none")]
    pub linear_buckets: Option<Box<models::LinearBuckets>>,
    /// The maximum of the population of values. Ignored if `count` is zero.
    #[serde(rename = "maximum", skip_serializing_if = "Option::is_none")]
    pub maximum: Option<f64>,
    /// The arithmetic mean of the samples in the distribution. If `count` is zero then this field must be zero.
    #[serde(rename = "mean", skip_serializing_if = "Option::is_none")]
    pub mean: Option<f64>,
    /// The minimum of the population of values. Ignored if `count` is zero.
    #[serde(rename = "minimum", skip_serializing_if = "Option::is_none")]
    pub minimum: Option<f64>,
    /// The sum of squared deviations from the mean: Sum[i=1..count]((x_i - mean)^2) where each x_i is a sample values. If `count` is zero then this field must be zero, otherwise validation of the request fails.
    #[serde(
        rename = "sumOfSquaredDeviation",
        skip_serializing_if = "Option::is_none"
    )]
    pub sum_of_squared_deviation: Option<f64>,
}

impl Distribution {
    /// Distribution represents a frequency distribution of double-valued sample points. It contains the size of the population of sample points plus additional optional information: * the arithmetic mean of the samples * the minimum and maximum of the samples * the sum-squared-deviation of the samples, used to compute variance * a histogram of the values of the sample points
    pub fn new() -> Distribution {
        Distribution {
            bucket_counts: None,
            count: None,
            exemplars: None,
            explicit_buckets: None,
            exponential_buckets: None,
            linear_buckets: None,
            maximum: None,
            mean: None,
            minimum: None,
            sum_of_squared_deviation: None,
        }
    }
}
