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))
 (No client certificate requested)
 by lists.proxmox.com (Postfix) with ESMTPS id 009427AA37
 for <pbs-devel@lists.proxmox.com>; Mon, 10 May 2021 09:23:19 +0200 (CEST)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
 by firstgate.proxmox.com (Proxmox) with ESMTP id DE4C61457B
 for <pbs-devel@lists.proxmox.com>; Mon, 10 May 2021 09:22:49 +0200 (CEST)
Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com
 [94.136.29.106])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits))
 (No client certificate requested)
 by firstgate.proxmox.com (Proxmox) with ESMTPS id 5C5A3144DF
 for <pbs-devel@lists.proxmox.com>; Mon, 10 May 2021 09:22:49 +0200 (CEST)
Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1])
 by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 26F67441CB
 for <pbs-devel@lists.proxmox.com>; Mon, 10 May 2021 09:22:49 +0200 (CEST)
To: pbs-devel@lists.proxmox.com
References: <20210510063914.7527-1-dietmar@proxmox.com>
From: Dietmar Maurer <dietmar@proxmox.com>
Message-ID: <6b10ac2b-4ba9-d1b9-43d7-d8579ef94a2a@proxmox.com>
Date: Mon, 10 May 2021 09:22:44 +0200
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
 Thunderbird/78.10.0
MIME-Version: 1.0
In-Reply-To: <20210510063914.7527-1-dietmar@proxmox.com>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Content-Language: en-US
X-SPAM-LEVEL: Spam detection results:  0
 AWL 0.227 Adjusted score from AWL reputation of From: address
 KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment
 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] applied: [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 07:23:20 -0000

applied

On 5/10/21 8:39 AM, Dietmar Maurer wrote:
> - 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>,