[pbs-devel] [PATCH proxmox v2 1/1] pbs-api-types: add api types for streaming content api call

Fabian Grünbichler f.gruenbichler at proxmox.com
Tue Oct 14 14:31:25 CEST 2025


On October 8, 2025 3:43 pm, Dominik Csapak wrote:
> Main point is the new struct
> * DatastoreContent, which contains either
>  - a namespace
>  - a snapshot (including namespace)
>  - a backup group (including namespace)
> 
> Since the enums variants are newtypes, we need to annotate the 'serde
> tag' and given them an 'id-property' and 'id-schema' even though we
> don't need it, since it's only relevant for saving these on disk with
> section config.
> 
> Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
> ---
> changes from v1:
> * no contenttype anymore (not necessary currently)
> * make properties public (else we can't use them in the ui)
> * rename the '*List' types to something better
> 
>  pbs-api-types/Cargo.toml       |  1 +
>  pbs-api-types/src/datastore.rs | 89 ++++++++++++++++++++++++++++++++++
>  2 files changed, 90 insertions(+)
> 
> diff --git a/pbs-api-types/Cargo.toml b/pbs-api-types/Cargo.toml
> index 358536d9..b3dee41d 100644
> --- a/pbs-api-types/Cargo.toml
> +++ b/pbs-api-types/Cargo.toml
> @@ -23,5 +23,6 @@ proxmox-lang.workspace=true
>  proxmox-s3-client = { workspace = true, features = [ "api-types" ] }
>  proxmox-schema = { workspace = true, features = [ "api-macro" ] }
>  proxmox-serde.workspace = true
> +proxmox-section-config.workspace = true
>  proxmox-time.workspace = true
>  proxmox-uuid = { workspace = true, features = [ "serde" ] }
> diff --git a/pbs-api-types/src/datastore.rs b/pbs-api-types/src/datastore.rs
> index fe73cbc4..9b4b9cfa 100644
> --- a/pbs-api-types/src/datastore.rs
> +++ b/pbs-api-types/src/datastore.rs
> @@ -1479,6 +1479,86 @@ pub struct NamespaceListItem {
>      pub comment: Option<String>,
>  }
>  
> +#[api(
> +    properties: {
> +        ns: {
> +            type: BackupNamespace,
> +        },
> +        snapshot: {
> +            type: SnapshotListItem,
> +            flatten: true,
> +        },
> +    },
> +)]
> +#[derive(Serialize, Deserialize)]
> +#[serde(rename_all = "kebab-case")]
> +/// Represents a snapshot in a datastore with namespace information
> +pub struct SnapshotWithNamespace {
> +    /// The namespace of the snapshot
> +    pub ns: BackupNamespace,
> +    #[serde(flatten)]
> +    /// The snapshot information
> +    pub snapshot: SnapshotListItem,
> +}
> +
> +#[api(
> +    properties: {
> +        ns: {
> +            type: BackupNamespace,
> +        },
> +        group: {
> +            type: GroupListItem,
> +            flatten: true,
> +        },
> +    },
> +)]
> +#[derive(Serialize, Deserialize)]
> +#[serde(rename_all = "kebab-case")]
> +/// Represents a snapshot in a datastore with namespace information
> +pub struct BackupGroupWithNamespace {
> +    /// The namespace of the snapshot
> +    pub ns: BackupNamespace,
> +    #[serde(flatten)]
> +    /// The backup group information
> +    pub group: GroupListItem,
> +}
> +
> +#[api(
> +    "id-property": "id",
> +    "id-schema": {
> +        type: String,
> +        description: "ID",
> +    },
> +)]
> +#[derive(Serialize, Deserialize)]
> +#[serde(rename_all = "kebab-case")]
> +#[serde(tag = "type")]
> +pub enum DatastoreContent {
> +    NameSpace(NamespaceListItem),

nit: Name*s*pace - that's how we capitalize it everywhere, and it would
get serialized as 'name-space' at the moment which is rather strange ;)

> +    Group(BackupGroupWithNamespace),
> +    Snapshot(SnapshotWithNamespace),
> +}
> +
> +impl From<NamespaceListItem> for DatastoreContent {
> +    fn from(value: NamespaceListItem) -> Self {
> +        DatastoreContent::NameSpace(value)
> +    }
> +}
> +
> +impl From<(BackupNamespace, GroupListItem)> for DatastoreContent {
> +    fn from(value: (BackupNamespace, GroupListItem)) -> Self {
> +        let (ns, group) = value;
> +        DatastoreContent::Group(BackupGroupWithNamespace { ns, group })
> +    }
> +}
> +
> +impl From<(BackupNamespace, SnapshotListItem)> for DatastoreContent {
> +    fn from(value: (BackupNamespace, SnapshotListItem)) -> Self {
> +        let (ns, snapshot) = value;
> +        DatastoreContent::Snapshot(SnapshotWithNamespace { ns, snapshot })
> +    }
> +}
> +
>  #[api(
>      properties: {
>          "backup": { type: BackupDir },
> @@ -1759,6 +1839,15 @@ pub const ADMIN_DATASTORE_LIST_NAMESPACE_RETURN_TYPE: ReturnType = ReturnType {
>      .schema(),
>  };
>  
> +pub const ADMIN_DATASTORE_LIST_CONTENT_RETURN_TYPE: ReturnType = ReturnType {
> +    optional: false,
> +    schema: &ArraySchema::new(
> +        "Returns the list of namespaces, backup groups and snapshots of a datastore.",
> +        &DatastoreContent::API_SCHEMA,
> +    )
> +    .schema(),
> +};
> +
>  pub const ADMIN_DATASTORE_PRUNE_RETURN_TYPE: ReturnType = ReturnType {
>      optional: false,
>      schema: &ArraySchema::new(
> -- 
> 2.47.3
> 
> 
> 
> _______________________________________________
> pbs-devel mailing list
> pbs-devel at lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
> 
> 
> 




More information about the pbs-devel mailing list