/*
 * Hetzner Cloud API
 *
 * Copied from the official API documentation for the Public Hetzner Cloud.
 *
 * The version of the OpenAPI document: 4b3f595
 *
 * Generated by: https://openapi-generator.tech
 */

use crate::models;
use serde::{Deserialize, Serialize};

/// UpdateLoadBalancerServiceHealthCheck : Service health check.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct UpdateLoadBalancerServiceHealthCheck {
    #[serde(rename = "http", skip_serializing_if = "Option::is_none")]
    pub http: Option<Box<models::UpdateLoadBalancerServiceHealthCheckHttp>>,
    /// Time interval in seconds health checks are performed.
    #[serde(rename = "interval", skip_serializing_if = "Option::is_none")]
    pub interval: Option<i32>,
    /// Port the health check will be performed on.
    #[serde(rename = "port", skip_serializing_if = "Option::is_none")]
    pub port: Option<i32>,
    /// Type of the health check.
    #[serde(rename = "protocol", skip_serializing_if = "Option::is_none")]
    pub protocol: Option<Protocol>,
    /// Unsuccessful retries needed until a target is considered unhealthy; an unhealthy target needs the same number of successful retries to become healthy again.
    #[serde(rename = "retries", skip_serializing_if = "Option::is_none")]
    pub retries: Option<i32>,
    /// Time in seconds after an attempt is considered a timeout.
    #[serde(rename = "timeout", skip_serializing_if = "Option::is_none")]
    pub timeout: Option<i32>,
}

impl UpdateLoadBalancerServiceHealthCheck {
    /// Service health check.
    pub fn new() -> UpdateLoadBalancerServiceHealthCheck {
        UpdateLoadBalancerServiceHealthCheck {
            http: None,
            interval: None,
            port: None,
            protocol: None,
            retries: None,
            timeout: None,
        }
    }
}
/// Type of the health check.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Protocol {
    #[serde(rename = "http")]
    Http,
    #[serde(rename = "tcp")]
    Tcp,
}

impl Default for Protocol {
    fn default() -> Protocol {
        Self::Http
    }
}
