use crate::prelude::*;

// WARNING: generated by kopium - manual changes will be overwritten
// kopium command: kopium -f /home/mmoreiradj/git/crd-rs/crds/cilium/v2alpha1/ciliumgatewayclassconfigs.yaml --schema=derived -d --hide-prelude
// kopium version: 0.22.5

/// Spec is a human-readable of a GatewayClass configuration.
#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema)]
#[kube(
    group = "cilium.io",
    version = "v2alpha1",
    kind = "CiliumGatewayClassConfig",
    plural = "ciliumgatewayclassconfigs"
)]
#[kube(namespaced)]
#[kube(status = "CiliumGatewayClassConfigStatus")]
pub struct CiliumGatewayClassConfigSpec {
    /// Description helps describe a GatewayClass configuration with more details.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub description: Option<String>,
    /// Service specifies the configuration for the generated Service.
    /// Note that not all fields from upstream Service.Spec are supported
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub service: Option<CiliumGatewayClassConfigService>,
}

/// Service specifies the configuration for the generated Service.
/// Note that not all fields from upstream Service.Spec are supported
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct CiliumGatewayClassConfigService {
    /// Sets the Service.Spec.AllocateLoadBalancerNodePorts in generated Service objects to the given value.
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        rename = "allocateLoadBalancerNodePorts"
    )]
    pub allocate_load_balancer_node_ports: Option<bool>,
    /// Sets the Service.Spec.ExternalTrafficPolicy in generated Service objects to the given value.
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        rename = "externalTrafficPolicy"
    )]
    pub external_traffic_policy: Option<String>,
    /// Sets the Service.Spec.IPFamilies in generated Service objects to the given value.
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        rename = "ipFamilies"
    )]
    pub ip_families: Option<Vec<String>>,
    /// Sets the Service.Spec.IPFamilyPolicy in generated Service objects to the given value.
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        rename = "ipFamilyPolicy"
    )]
    pub ip_family_policy: Option<String>,
    /// Sets the Service.Spec.LoadBalancerClass in generated Service objects to the given value.
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        rename = "loadBalancerClass"
    )]
    pub load_balancer_class: Option<String>,
    /// Sets the Service.Spec.LoadBalancerSourceRanges in generated Service objects to the given value.
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        rename = "loadBalancerSourceRanges"
    )]
    pub load_balancer_source_ranges: Option<Vec<String>>,
    /// LoadBalancerSourceRangesPolicy defines the policy for the LoadBalancerSourceRanges if the incoming traffic
    /// is allowed or denied.
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        rename = "loadBalancerSourceRangesPolicy"
    )]
    pub load_balancer_source_ranges_policy:
        Option<CiliumGatewayClassConfigServiceLoadBalancerSourceRangesPolicy>,
    /// Sets the Service.Spec.TrafficDistribution in generated Service objects to the given value.
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        rename = "trafficDistribution"
    )]
    pub traffic_distribution: Option<String>,
    /// Sets the Service.Spec.Type in generated Service objects to the given value.
    /// Only LoadBalancer and NodePort are supported.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "type")]
    pub r#type: Option<CiliumGatewayClassConfigServiceType>,
}

/// Service specifies the configuration for the generated Service.
/// Note that not all fields from upstream Service.Spec are supported
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub enum CiliumGatewayClassConfigServiceLoadBalancerSourceRangesPolicy {
    Allow,
    Deny,
}

/// Service specifies the configuration for the generated Service.
/// Note that not all fields from upstream Service.Spec are supported
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub enum CiliumGatewayClassConfigServiceType {
    LoadBalancer,
    NodePort,
}

/// Status is the status of the policy.
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct CiliumGatewayClassConfigStatus {
    /// Current service state
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub conditions: Option<Vec<Condition>>,
}
