/*
 * 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};

/// UpdateLoadBalancerService : An update to a service for a Load Balancer.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct UpdateLoadBalancerService {
    /// Port the Load Balancer will balance to.
    #[serde(rename = "destination_port", skip_serializing_if = "Option::is_none")]
    pub destination_port: Option<i32>,
    #[serde(rename = "health_check", skip_serializing_if = "Option::is_none")]
    pub health_check: Option<Box<models::UpdateLoadBalancerServiceHealthCheck>>,
    #[serde(rename = "http", skip_serializing_if = "Option::is_none")]
    pub http: Option<Box<models::Http>>,
    /// Port the Load Balancer listens on.
    #[serde(rename = "listen_port")]
    pub listen_port: i32,
    /// Protocol of the Load Balancer.
    #[serde(rename = "protocol", skip_serializing_if = "Option::is_none")]
    pub protocol: Option<Protocol>,
    /// Is Proxyprotocol enabled or not.
    #[serde(rename = "proxyprotocol", skip_serializing_if = "Option::is_none")]
    pub proxyprotocol: Option<bool>,
}

impl UpdateLoadBalancerService {
    /// An update to a service for a Load Balancer.
    pub fn new(listen_port: i32) -> UpdateLoadBalancerService {
        UpdateLoadBalancerService {
            destination_port: None,
            health_check: None,
            http: None,
            listen_port,
            protocol: None,
            proxyprotocol: None,
        }
    }
}
/// Protocol of the Load Balancer.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Protocol {
    #[serde(rename = "http")]
    Http,
    #[serde(rename = "https")]
    Https,
    #[serde(rename = "tcp")]
    Tcp,
}

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