From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dietmar@proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256)
 (No client certificate requested)
 by lists.proxmox.com (Postfix) with ESMTPS id 37F777A9A0
 for <pbs-devel@lists.proxmox.com>; Mon, 10 May 2021 08:39:28 +0200 (CEST)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
 by firstgate.proxmox.com (Proxmox) with ESMTP id 2CA02135B0
 for <pbs-devel@lists.proxmox.com>; Mon, 10 May 2021 08:39:28 +0200 (CEST)
Received: from elsa.proxmox.com (unknown [94.136.29.99])
 by firstgate.proxmox.com (Proxmox) with ESMTP id 419DC1358B
 for <pbs-devel@lists.proxmox.com>; Mon, 10 May 2021 08:39:27 +0200 (CEST)
Received: by elsa.proxmox.com (Postfix, from userid 0)
 id 20CADAEB340; Mon, 10 May 2021 08:39:21 +0200 (CEST)
From: Dietmar Maurer <dietmar@proxmox.com>
To: pbs-devel@lists.proxmox.com
Date: Mon, 10 May 2021 08:39:13 +0200
Message-Id: <20210510063914.7527-1-dietmar@proxmox.com>
X-Mailer: git-send-email 2.20.1
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-SPAM-LEVEL: Spam detection results:  0
 AWL -0.414 Adjusted score from AWL reputation of From: address
 KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment
 RDNS_NONE 1.274 Delivered to internal network by a host with no rDNS
 SPF_HELO_NONE           0.001 SPF: HELO does not publish an SPF Record
 SPF_PASS               -0.001 SPF: sender matches SPF record
Subject: [pbs-devel] [PATCH proxmox-backup 1/2] cleanup
 src/api2/node/config.rs
X-BeenThere: pbs-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox Backup Server development discussion
 <pbs-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pbs-devel>, 
 <mailto:pbs-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pbs-devel/>
List-Post: <mailto:pbs-devel@lists.proxmox.com>
List-Help: <mailto:pbs-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel>, 
 <mailto:pbs-devel-request@lists.proxmox.com?subject=subscribe>
X-List-Received-Date: Mon, 10 May 2021 06:39:28 -0000

- add return type
- fix permissions
- fix descriptions
---
 src/api2/node/config.rs | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/src/api2/node/config.rs b/src/api2/node/config.rs
index fd997062..92c0100e 100644
--- a/src/api2/node/config.rs
+++ b/src/api2/node/config.rs
@@ -1,12 +1,11 @@
 use anyhow::Error;
-use serde_json::Value;
 
 use proxmox::api::schema::Updatable;
 use proxmox::api::{api, Permission, Router, RpcEnvironment};
 
 use crate::api2::types::NODE_SCHEMA;
-use crate::config::acl::PRIV_SYS_MODIFY;
-use crate::config::node::NodeConfigUpdater;
+use crate::config::acl::{PRIV_SYS_AUDIT, PRIV_SYS_MODIFY};
+use crate::config::node::{NodeConfig, NodeConfigUpdater};
 
 pub const ROUTER: Router = Router::new()
     .get(&API_METHOD_GET_NODE_CONFIG)
@@ -19,14 +18,17 @@ pub const ROUTER: Router = Router::new()
         },
     },
     access: {
-        permission: &Permission::Privilege(&["system"], PRIV_SYS_MODIFY, false),
+        permission: &Permission::Privilege(&["system"], PRIV_SYS_AUDIT, false),
+    },
+    returns: {
+        type: NodeConfig,
     },
 )]
-/// Create a new changer device.
-pub fn get_node_config(mut rpcenv: &mut dyn RpcEnvironment) -> Result<Value, Error> {
+/// Get the node configuration
+pub fn get_node_config(mut rpcenv: &mut dyn RpcEnvironment) -> Result<NodeConfig, Error> {
     let (config, digest) = crate::config::node::config()?;
     rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into();
-    Ok(serde_json::to_value(config)?)
+    Ok(config)
 }
 
 #[api(
@@ -52,7 +54,7 @@ pub fn get_node_config(mut rpcenv: &mut dyn RpcEnvironment) -> Result<Value, Err
     },
     protected: true,
 )]
-/// Create a new changer device.
+/// Update the node configuration
 pub fn update_node_config(
     updater: NodeConfigUpdater,
     delete: Option<String>,
-- 
2.20.1