//! Auto-generated models for flux-operator-resourcesets
//! Generated from: flux-operator-resourcesets.crds.yaml
//! DO NOT EDIT - This file is auto-generated by kopium
#![allow(clippy::all)]

// WARNING: generated by kopium - manual changes will be overwritten
// kopium command: kopium --filename /tmp/tmp.gP8z0fCX0t/doc1.yaml --derive Default --derive PartialEq --docs --smart-derive-elision
// kopium version: 0.23.0

#[allow(unused_imports)]
mod prelude {
    pub use k8s_openapi::apimachinery::pkg::apis::meta::v1::Condition;
    pub use kube::CustomResource;
    pub use serde::{Deserialize, Serialize};
    pub use std::collections::BTreeMap;
}

use self::prelude::*;

/// ResourceSetSpec defines the desired state of ResourceSet
#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
#[kube(
    group = "fluxcd.controlplane.io",
    version = "v1",
    kind = "ResourceSet",
    plural = "resourcesets"
)]
#[kube(namespaced)]
#[kube(status = "ResourceSetStatus")]
#[kube(schema = "disabled")]
#[kube(derive = "Default")]
#[kube(derive = "PartialEq")]
pub struct ResourceSetSpec {
    /// CommonMetadata specifies the common labels and annotations that are
    /// applied to all resources. Any existing label or annotation will be
    /// overridden if its key matches a common one.
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        rename = "commonMetadata"
    )]
    pub common_metadata: Option<ResourceSetCommonMetadata>,
    /// DependsOn specifies the list of Kubernetes resources that must
    /// exist on the cluster before the reconciliation process starts.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "dependsOn")]
    pub depends_on: Option<Vec<ResourceSetDependsOn>>,
    /// InputStrategy defines how the inputs are combined when multiple
    /// input provider objects are used. Defaults to flattening all inputs
    /// from all providers into a single list of input sets.
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        rename = "inputStrategy"
    )]
    pub input_strategy: Option<ResourceSetInputStrategy>,
    /// Inputs contains the list of ResourceSet inputs.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub inputs: Option<Vec<BTreeMap<String, serde_json::Value>>>,
    /// InputsFrom contains the list of references to input providers.
    /// When set, the inputs are fetched from the providers and concatenated
    /// with the in-line inputs defined in the ResourceSet.
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        rename = "inputsFrom"
    )]
    pub inputs_from: Option<Vec<ResourceSetInputsFrom>>,
    /// Resources contains the list of Kubernetes resources to reconcile.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub resources: Option<Vec<serde_json::Value>>,
    /// ResourcesTemplate is a Go template that generates the list of
    /// Kubernetes resources to reconcile. The template is rendered
    /// as multi-document YAML, the resources should be separated by '---'.
    /// When both Resources and ResourcesTemplate are set, the resulting
    /// objects are merged and deduplicated, with the ones from Resources taking precedence.
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        rename = "resourcesTemplate"
    )]
    pub resources_template: Option<String>,
    /// The name of the Kubernetes service account to impersonate
    /// when reconciling the generated resources.
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        rename = "serviceAccountName"
    )]
    pub service_account_name: Option<String>,
    /// Wait instructs the controller to check the health
    /// of all the reconciled resources.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub wait: Option<bool>,
}

/// CommonMetadata specifies the common labels and annotations that are
/// applied to all resources. Any existing label or annotation will be
/// overridden if its key matches a common one.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct ResourceSetCommonMetadata {
    /// Annotations to be added to the object's metadata.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub annotations: Option<BTreeMap<String, String>>,
    /// Labels to be added to the object's metadata.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub labels: Option<BTreeMap<String, String>>,
}

/// Dependency defines a ResourceSet dependency on a Kubernetes resource.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct ResourceSetDependsOn {
    /// APIVersion of the resource to depend on.
    #[serde(rename = "apiVersion")]
    pub api_version: String,
    /// Kind of the resource to depend on.
    pub kind: String,
    /// Name of the resource to depend on.
    pub name: String,
    /// Namespace of the resource to depend on.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub namespace: Option<String>,
    /// Ready checks if the resource Ready status condition is true.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub ready: Option<bool>,
    /// ReadyExpr checks if the resource satisfies the given CEL expression.
    /// The expression replaces the default readiness check and
    /// is only evaluated if Ready is set to 'true'.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "readyExpr")]
    pub ready_expr: Option<String>,
}

/// InputStrategy defines how the inputs are combined when multiple
/// input provider objects are used. Defaults to flattening all inputs
/// from all providers into a single list of input sets.
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
pub struct ResourceSetInputStrategy {
    /// IncludeEmptyProviders controls how input providers that export no
    /// inputs are treated. Only applies when Name is Permute. When true, if
    /// any provider has zero inputs the resulting permutation set is empty
    /// (mathematically correct Cartesian product behavior). When false or
    /// unset (default), providers with zero inputs are silently skipped and
    /// the remaining providers still permute among themselves.
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        rename = "includeEmptyProviders"
    )]
    pub include_empty_providers: Option<bool>,
    /// Name defines how the inputs are combined when multiple
    /// input provider objects are used. Supported values are:
    /// - Flatten: all inputs sets from all input provider objects are
    ///   flattened into a single list of input sets.
    /// - Permute: all inputs sets from all input provider objects are
    ///   combined using a Cartesian product, resulting in a list of input sets
    ///   that contains every possible combination of input values.
    ///   For example, if provider A has inputs [{x: 1}, {x: 2}] and provider B has
    ///   inputs [{y: "a"}, {y: "b"}], the resulting input sets will be:
    ///   [{x: 1, y: "a"}, {x: 1, y: "b"}, {x: 2, y: "a"}, {x: 2, y: "b"}].
    ///   This strategy can lead to a large number of input sets and should be
    ///   used with caution. Users should use filtering features from
    ///   ResourceSetInputProvider to limit the amount of exported inputs.
    pub name: ResourceSetInputStrategyName,
}

/// InputStrategy defines how the inputs are combined when multiple
/// input provider objects are used. Defaults to flattening all inputs
/// from all providers into a single list of input sets.
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
pub enum ResourceSetInputStrategyName {
    Flatten,
    Permute,
}

/// InputProviderReference defines a reference to an input provider resource
/// in the same namespace as the ResourceSet.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct ResourceSetInputsFrom {
    /// APIVersion of the input provider resource.
    /// When not set, the APIVersion of the ResourceSet is used.
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        rename = "apiVersion"
    )]
    pub api_version: Option<ResourceSetInputsFromApiVersion>,
    /// Kind of the input provider resource.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub kind: Option<ResourceSetInputsFromKind>,
    /// Name of the input provider resource. Cannot be set
    /// when the Selector field is set.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub name: Option<String>,
    /// Selector is a label selector to filter the input provider resources
    /// as an alternative to the Name field.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub selector: Option<ResourceSetInputsFromSelector>,
}

/// InputProviderReference defines a reference to an input provider resource
/// in the same namespace as the ResourceSet.
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
pub enum ResourceSetInputsFromApiVersion {
    #[serde(rename = "fluxcd.controlplane.io/v1")]
    FluxcdControlplaneIoV1,
}

/// InputProviderReference defines a reference to an input provider resource
/// in the same namespace as the ResourceSet.
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
pub enum ResourceSetInputsFromKind {
    ResourceSetInputProvider,
}

/// Selector is a label selector to filter the input provider resources
/// as an alternative to the Name field.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct ResourceSetInputsFromSelector {
    /// matchExpressions is a list of label selector requirements. The requirements are ANDed.
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        rename = "matchExpressions"
    )]
    pub match_expressions: Option<Vec<ResourceSetInputsFromSelectorMatchExpressions>>,
    /// matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels
    /// map is equivalent to an element of matchExpressions, whose key field is "key", the
    /// operator is "In", and the values array contains only "value". The requirements are ANDed.
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        rename = "matchLabels"
    )]
    pub match_labels: Option<BTreeMap<String, String>>,
}

/// A label selector requirement is a selector that contains values, a key, and an operator that
/// relates the key and values.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct ResourceSetInputsFromSelectorMatchExpressions {
    /// key is the label key that the selector applies to.
    pub key: String,
    /// operator represents a key's relationship to a set of values.
    /// Valid operators are In, NotIn, Exists and DoesNotExist.
    pub operator: String,
    /// values is an array of string values. If the operator is In or NotIn,
    /// the values array must be non-empty. If the operator is Exists or DoesNotExist,
    /// the values array must be empty. This array is replaced during a strategic
    /// merge patch.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub values: Option<Vec<String>>,
}

/// ResourceSetStatus defines the observed state of ResourceSet.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct ResourceSetStatus {
    /// Conditions contains the readiness conditions of the object.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub conditions: Option<Vec<Condition>>,
    /// ExternalChecksumRefs lists the ConfigMap and Secret references
    /// discovered in checksumFrom annotations on the last reconciliation
    /// that point to objects not rendered by this ResourceSet. Each entry
    /// has the form "Kind/namespace/name". It is used to trigger a
    /// reconciliation when one of the referenced objects changes.
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        rename = "externalChecksumRefs"
    )]
    pub external_checksum_refs: Option<Vec<String>>,
    /// History contains the reconciliation history of the ResourceSet
    /// as a list of snapshots ordered by the last reconciled time.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub history: Option<Vec<ResourceSetStatusHistory>>,
    /// Inventory contains a list of Kubernetes resource object references
    /// last applied on the cluster.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub inventory: Option<ResourceSetStatusInventory>,
    /// LastAppliedRevision is the digest of the
    /// generated resources that were last reconcile.
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        rename = "lastAppliedRevision"
    )]
    pub last_applied_revision: Option<String>,
    /// LastHandledReconcileAt holds the value of the most recent
    /// reconcile request value, so a change of the annotation value
    /// can be detected.
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        rename = "lastHandledReconcileAt"
    )]
    pub last_handled_reconcile_at: Option<String>,
}

/// Snapshot represents a point-in-time record of a group of resources reconciliation,
/// including timing information, status, and a unique digest identifier.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct ResourceSetStatusHistory {
    /// Digest is the checksum in the format `<algo>:<hex>` of the resources in this snapshot.
    pub digest: String,
    /// FirstReconciled is the time when this revision was first reconciled to the cluster.
    #[serde(rename = "firstReconciled")]
    pub first_reconciled: String,
    /// LastReconciled is the time when this revision was last reconciled to the cluster.
    #[serde(rename = "lastReconciled")]
    pub last_reconciled: String,
    /// LastReconciledDuration is time it took to reconcile the resources in this revision.
    #[serde(rename = "lastReconciledDuration")]
    pub last_reconciled_duration: String,
    /// LastReconciledStatus is the status of the last reconciliation.
    #[serde(rename = "lastReconciledStatus")]
    pub last_reconciled_status: String,
    /// Metadata contains additional information about the snapshot.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub metadata: Option<BTreeMap<String, String>>,
    /// TotalReconciliations is the total number of reconciliations that have occurred for this snapshot.
    #[serde(rename = "totalReconciliations")]
    pub total_reconciliations: i64,
}

/// Inventory contains a list of Kubernetes resource object references
/// last applied on the cluster.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct ResourceSetStatusInventory {
    /// Entries of Kubernetes resource object references.
    pub entries: Vec<ResourceSetStatusInventoryEntries>,
}

/// ResourceRef contains the information necessary to locate a resource within a cluster.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct ResourceSetStatusInventoryEntries {
    /// ID is the string representation of the Kubernetes resource object's metadata,
    /// in the format '<namespace>_<name>_<group>_<kind>'.
    pub id: String,
    /// Version is the API version of the Kubernetes resource object's kind.
    pub v: String,
}
