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;

/// HealthCheck : Represents a health check resource. Google Compute Engine has two health check resources: * [Regional](/compute/docs/reference/rest/v1/regionHealthChecks) * [Global](/compute/docs/reference/rest/v1/healthChecks) These health check resources can be used for load balancing and for autohealing VMs in a managed instance group (MIG). **Load balancing** Health check requirements vary depending on the type of load balancer. For details about the type of health check supported for each load balancer and corresponding backend type, see Health checks overview: Load balancer guide. **Autohealing in MIGs** The health checks that you use for autohealing VMs in a MIG can be either regional or global. For more information, see Set up an application health check and autohealing. For more information, see Health checks overview.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct HealthCheck {
    /// How often (in seconds) to send a health check. The default value is 5 seconds.
    #[serde(rename = "checkIntervalSec", skip_serializing_if = "Option::is_none")]
    pub check_interval_sec: Option<i32>,
    /// [Output Only] Creation timestamp in 3339 text format.
    #[serde(rename = "creationTimestamp", skip_serializing_if = "Option::is_none")]
    pub creation_timestamp: Option<String>,
    /// An optional description of this resource. Provide this property when you create the resource.
    #[serde(rename = "description", skip_serializing_if = "Option::is_none")]
    pub description: Option<String>,
    #[serde(rename = "grpcHealthCheck", skip_serializing_if = "Option::is_none")]
    pub grpc_health_check: Option<Box<models::GrpcHealthCheck>>,
    /// A so-far unhealthy instance will be marked healthy after this many consecutive successes. The default value is 2.
    #[serde(rename = "healthyThreshold", skip_serializing_if = "Option::is_none")]
    pub healthy_threshold: Option<i32>,
    #[serde(rename = "http2HealthCheck", skip_serializing_if = "Option::is_none")]
    pub http2_health_check: Option<Box<models::Http2HealthCheck>>,
    #[serde(rename = "httpHealthCheck", skip_serializing_if = "Option::is_none")]
    pub http_health_check: Option<Box<models::HttpHealthCheck>>,
    #[serde(rename = "httpsHealthCheck", skip_serializing_if = "Option::is_none")]
    pub https_health_check: Option<Box<models::HttpsHealthCheck>>,
    /// [Output Only] The unique identifier for the resource. This identifier is defined by the server.
    #[serde(rename = "id", skip_serializing_if = "Option::is_none")]
    pub id: Option<String>,
    /// Type of the resource.
    #[serde(rename = "kind", skip_serializing_if = "Option::is_none")]
    pub kind: Option<String>,
    #[serde(rename = "logConfig", skip_serializing_if = "Option::is_none")]
    pub log_config: Option<Box<models::HealthCheckLogConfig>>,
    /// Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. For example, a name that is 1-63 characters long, matches the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`, and otherwise complies with RFC1035. This regular expression describes a name where the first character is a lowercase letter, and all following characters are a dash, lowercase letter, or digit, except the last character, which isn't a dash.
    #[serde(rename = "name", skip_serializing_if = "Option::is_none")]
    pub name: Option<String>,
    /// [Output Only] Region where the health check resides. Not applicable to global health checks.
    #[serde(rename = "region", skip_serializing_if = "Option::is_none")]
    pub region: Option<String>,
    /// [Output Only] Server-defined URL for the resource.
    #[serde(rename = "selfLink", skip_serializing_if = "Option::is_none")]
    pub self_link: Option<String>,
    #[serde(rename = "sslHealthCheck", skip_serializing_if = "Option::is_none")]
    pub ssl_health_check: Option<Box<models::SslHealthCheck>>,
    #[serde(rename = "tcpHealthCheck", skip_serializing_if = "Option::is_none")]
    pub tcp_health_check: Option<Box<models::TcpHealthCheck>>,
    /// How long (in seconds) to wait before claiming failure. The default value is 5 seconds. It is invalid for timeoutSec to have greater value than checkIntervalSec.
    #[serde(rename = "timeoutSec", skip_serializing_if = "Option::is_none")]
    pub timeout_sec: Option<i32>,
    /// Specifies the type of the healthCheck, either TCP, SSL, HTTP, HTTPS, HTTP2 or GRPC. Exactly one of the protocol-specific health check fields must be specified, which must match type field.
    #[serde(rename = "type", skip_serializing_if = "Option::is_none")]
    pub r#type: Option<Type>,
    /// A so-far healthy instance will be marked unhealthy after this many consecutive failures. The default value is 2.
    #[serde(rename = "unhealthyThreshold", skip_serializing_if = "Option::is_none")]
    pub unhealthy_threshold: Option<i32>,
}

impl HealthCheck {
    /// Represents a health check resource. Google Compute Engine has two health check resources: * [Regional](/compute/docs/reference/rest/v1/regionHealthChecks) * [Global](/compute/docs/reference/rest/v1/healthChecks) These health check resources can be used for load balancing and for autohealing VMs in a managed instance group (MIG). **Load balancing** Health check requirements vary depending on the type of load balancer. For details about the type of health check supported for each load balancer and corresponding backend type, see Health checks overview: Load balancer guide. **Autohealing in MIGs** The health checks that you use for autohealing VMs in a MIG can be either regional or global. For more information, see Set up an application health check and autohealing. For more information, see Health checks overview.
    pub fn new() -> HealthCheck {
        HealthCheck {
            check_interval_sec: None,
            creation_timestamp: None,
            description: None,
            grpc_health_check: None,
            healthy_threshold: None,
            http2_health_check: None,
            http_health_check: None,
            https_health_check: None,
            id: None,
            kind: None,
            log_config: None,
            name: None,
            region: None,
            self_link: None,
            ssl_health_check: None,
            tcp_health_check: None,
            timeout_sec: None,
            r#type: None,
            unhealthy_threshold: None,
        }
    }
}
/// Specifies the type of the healthCheck, either TCP, SSL, HTTP, HTTPS, HTTP2 or GRPC. Exactly one of the protocol-specific health check fields must be specified, which must match type field.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
    #[serde(rename = "GRPC")]
    Grpc,
    #[serde(rename = "HTTP")]
    Http,
    #[serde(rename = "HTTP2")]
    Http2,
    #[serde(rename = "HTTPS")]
    Https,
    #[serde(rename = "INVALID")]
    Invalid,
    #[serde(rename = "SSL")]
    Ssl,
    #[serde(rename = "TCP")]
    Tcp,
}

impl Default for Type {
    fn default() -> Type {
        Self::Grpc
    }
}
