cnpg 0.1.0

Kubernetes CRD bindings for CloudNativePG
Documentation
use crate::prelude::*;

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

/// SubscriptionSpec defines the desired state of Subscription
#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema)]
#[kube(
    group = "postgresql.cnpg.io",
    version = "v1",
    kind = "Subscription",
    plural = "subscriptions"
)]
#[kube(namespaced)]
#[kube(status = "SubscriptionStatus")]
pub struct SubscriptionSpec {
    /// The name of the PostgreSQL cluster that identifies the "subscriber"
    pub cluster: SubscriptionCluster,
    /// The name of the database where the publication will be installed in
    /// the "subscriber" cluster
    pub dbname: String,
    /// The name of the external cluster with the publication ("publisher")
    #[serde(rename = "externalClusterName")]
    pub external_cluster_name: String,
    /// The name of the subscription inside PostgreSQL
    pub name: String,
    /// Subscription parameters included in the `WITH` clause of the PostgreSQL
    /// `CREATE SUBSCRIPTION` command. Most parameters cannot be changed
    /// after the subscription is created and will be ignored if modified
    /// later, except for a limited set documented at:
    /// <https://www.postgresql.org/docs/current/sql-altersubscription.html#SQL-ALTERSUBSCRIPTION-PARAMS-SET>
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub parameters: Option<BTreeMap<String, String>>,
    /// The name of the database containing the publication on the external
    /// cluster. Defaults to the one in the external cluster definition.
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        rename = "publicationDBName"
    )]
    pub publication_db_name: Option<String>,
    /// The name of the publication inside the PostgreSQL database in the
    /// "publisher"
    #[serde(rename = "publicationName")]
    pub publication_name: String,
    /// The policy for end-of-life maintenance of this subscription
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        rename = "subscriptionReclaimPolicy"
    )]
    pub subscription_reclaim_policy: Option<SubscriptionSubscriptionReclaimPolicy>,
}

/// The name of the PostgreSQL cluster that identifies the "subscriber"
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct SubscriptionCluster {
    /// Name of the referent.
    /// This field is effectively required, but due to backwards compatibility is
    /// allowed to be empty. Instances of this type with an empty value here are
    /// almost certainly wrong.
    /// More info: <https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names>
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub name: Option<String>,
}

/// SubscriptionSpec defines the desired state of Subscription
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub enum SubscriptionSubscriptionReclaimPolicy {
    #[serde(rename = "delete")]
    Delete,
    #[serde(rename = "retain")]
    Retain,
}

/// SubscriptionStatus defines the observed state of Subscription
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct SubscriptionStatus {
    /// Applied is true if the subscription was reconciled correctly
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub applied: Option<bool>,
    /// Message is the reconciliation output message
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub message: Option<String>,
    /// A sequence number representing the latest
    /// desired state that was synchronized
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        rename = "observedGeneration"
    )]
    pub observed_generation: Option<i64>,
}