use serde::{Deserialize, Serialize}; /*
                                      * Compute Engine API
                                      *
                                      * Creates and runs virtual machines on Google Cloud Platform.
                                      *
                                      * The version of the OpenAPI document: v1
                                      *
                                      * Generated by: https://openapi-generator.tech
                                      */

use crate::google_rest_apis::compute_v1::models;

/// BackendServiceLogConfig : The available logging options for the load balancer traffic served by this backend service.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct BackendServiceLogConfig {
    /// Denotes whether to enable logging for the load balancer traffic served by this backend service. The default value is false.
    #[serde(rename = "enable", skip_serializing_if = "Option::is_none")]
    pub enable: Option<bool>,
    /// This field can only be specified if logging is enabled for this backend service and \"logConfig.optionalMode\" was set to CUSTOM. Contains a list of optional fields you want to include in the logs. For example: serverInstance, serverGkeDetails.cluster, serverGkeDetails.pod.podNamespace
    #[serde(rename = "optionalFields", skip_serializing_if = "Option::is_none")]
    pub optional_fields: Option<Vec<String>>,
    /// This field can only be specified if logging is enabled for this backend service. Configures whether all, none or a subset of optional fields should be added to the reported logs. One of [INCLUDE_ALL_OPTIONAL, EXCLUDE_ALL_OPTIONAL, CUSTOM]. Default is EXCLUDE_ALL_OPTIONAL.
    #[serde(rename = "optionalMode", skip_serializing_if = "Option::is_none")]
    pub optional_mode: Option<OptionalMode>,
    /// This field can only be specified if logging is enabled for this backend service. The value of the field must be in [0, 1]. This configures the sampling rate of requests to the load balancer where 1.0 means all logged requests are reported and 0.0 means no logged requests are reported. The default value is 1.0.
    #[serde(rename = "sampleRate", skip_serializing_if = "Option::is_none")]
    pub sample_rate: Option<f32>,
}

impl BackendServiceLogConfig {
    /// The available logging options for the load balancer traffic served by this backend service.
    pub fn new() -> BackendServiceLogConfig {
        BackendServiceLogConfig {
            enable: None,
            optional_fields: None,
            optional_mode: None,
            sample_rate: None,
        }
    }
}
/// This field can only be specified if logging is enabled for this backend service. Configures whether all, none or a subset of optional fields should be added to the reported logs. One of [INCLUDE_ALL_OPTIONAL, EXCLUDE_ALL_OPTIONAL, CUSTOM]. Default is EXCLUDE_ALL_OPTIONAL.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum OptionalMode {
    #[serde(rename = "CUSTOM")]
    Custom,
    #[serde(rename = "EXCLUDE_ALL_OPTIONAL")]
    ExcludeAllOptional,
    #[serde(rename = "INCLUDE_ALL_OPTIONAL")]
    IncludeAllOptional,
}

impl Default for OptionalMode {
    fn default() -> OptionalMode {
        Self::Custom
    }
}
