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_publications.yaml --schema=derived -d --hide-prelude
// kopium version: 0.22.5

/// PublicationSpec defines the desired state of Publication
#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema)]
#[kube(
    group = "postgresql.cnpg.io",
    version = "v1",
    kind = "Publication",
    plural = "publications"
)]
#[kube(namespaced)]
#[kube(status = "PublicationStatus")]
pub struct PublicationSpec {
    /// The name of the PostgreSQL cluster that identifies the "publisher"
    pub cluster: PublicationCluster,
    /// The name of the database where the publication will be installed in
    /// the "publisher" cluster
    pub dbname: String,
    /// The name of the publication inside PostgreSQL
    pub name: String,
    /// Publication parameters part of the `WITH` clause as expected by
    /// PostgreSQL `CREATE PUBLICATION` command
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub parameters: Option<BTreeMap<String, String>>,
    /// The policy for end-of-life maintenance of this publication
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        rename = "publicationReclaimPolicy"
    )]
    pub publication_reclaim_policy: Option<PublicationPublicationReclaimPolicy>,
    /// Target of the publication as expected by PostgreSQL `CREATE PUBLICATION` command
    pub target: PublicationTarget,
}

/// The name of the PostgreSQL cluster that identifies the "publisher"
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct PublicationCluster {
    /// 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>,
}

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

/// Target of the publication as expected by PostgreSQL `CREATE PUBLICATION` command
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct PublicationTarget {
    /// Marks the publication as one that replicates changes for all tables
    /// in the database, including tables created in the future.
    /// Corresponding to `FOR ALL TABLES` in PostgreSQL.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "allTables")]
    pub all_tables: Option<bool>,
    /// Just the following schema objects
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub objects: Option<Vec<PublicationTargetObjects>>,
}

/// PublicationTargetObject is an object to publish
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct PublicationTargetObjects {
    /// Specifies a list of tables to add to the publication. Corresponding
    /// to `FOR TABLE` in PostgreSQL.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub table: Option<PublicationTargetObjectsTable>,
    /// Marks the publication as one that replicates changes for all tables
    /// in the specified list of schemas, including tables created in the
    /// future. Corresponding to `FOR TABLES IN SCHEMA` in PostgreSQL.
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        rename = "tablesInSchema"
    )]
    pub tables_in_schema: Option<String>,
}

/// Specifies a list of tables to add to the publication. Corresponding
/// to `FOR TABLE` in PostgreSQL.
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct PublicationTargetObjectsTable {
    /// The columns to publish
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub columns: Option<Vec<String>>,
    /// The table name
    pub name: String,
    /// Whether to limit to the table only or include all its descendants
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub only: Option<bool>,
    /// The schema name
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub schema: Option<String>,
}

/// PublicationStatus defines the observed state of Publication
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
pub struct PublicationStatus {
    /// Applied is true if the publication 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>,
}