]> git.proxmox.com Git - proxmox-backup.git/commitdiff
src/api2/config/datastore.rs_ add delete property to update method
authorDietmar Maurer <dietmar@proxmox.com>
Wed, 29 Apr 2020 07:09:59 +0000 (09:09 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Wed, 29 Apr 2020 07:09:59 +0000 (09:09 +0200)
src/api2/config/datastore.rs

index 94bd77ef266834c6f26125a3f5e386f98dc3be74..0bd86c2d801e5a1ad70ea91754c04fccc0a6601e 100644 (file)
@@ -2,6 +2,7 @@ use std::path::PathBuf;
 
 use anyhow::{bail, Error};
 use serde_json::Value;
+use ::serde::{Deserialize, Serialize};
 
 use proxmox::api::{api, ApiMethod, Router, RpcEnvironment, Permission};
 
@@ -119,6 +120,15 @@ pub fn read_datastore(name: String) -> Result<Value, Error> {
     Ok(data)
 }
 
+#[api()]
+#[derive(Serialize, Deserialize)]
+#[allow(non_camel_case_types)]
+/// Deletable property name
+pub enum DeletableProperty {
+    /// Delete the comment property.
+    comment,
+}
+
 #[api(
     protected: true,
     input: {
@@ -130,6 +140,14 @@ pub fn read_datastore(name: String) -> Result<Value, Error> {
                 optional: true,
                 schema: SINGLE_LINE_COMMENT_SCHEMA,
             },
+            delete: {
+                description: "List of properties to delete.",
+                type: Array,
+                optional: true,
+                items: {
+                    type: DeletableProperty,
+                }
+            },
             digest: {
                 optional: true,
                 schema: PROXMOX_CONFIG_DIGEST_SCHEMA,
@@ -144,6 +162,7 @@ pub fn read_datastore(name: String) -> Result<Value, Error> {
 pub fn update_datastore(
     name: String,
     comment: Option<String>,
+    delete: Option<Vec<DeletableProperty>>,
     digest: Option<String>,
 ) -> Result<(), Error> {
 
@@ -159,6 +178,14 @@ pub fn update_datastore(
 
     let mut data: datastore::DataStoreConfig = config.lookup("datastore", &name)?;
 
+     if let Some(delete) = delete {
+        for delete_prop in delete {
+            match delete_prop {
+                DeletableProperty::comment => { data.comment = None; },
+            }
+        }
+    }
+
     if let Some(comment) = comment {
         let comment = comment.trim().to_string();
         if comment.is_empty() {