From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id C40401FF16F for ; Tue, 22 Jul 2025 12:11:20 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id E97E635F66; Tue, 22 Jul 2025 12:12:24 +0200 (CEST) From: Christian Ebner To: pbs-devel@lists.proxmox.com Date: Tue, 22 Jul 2025 12:11:01 +0200 Message-ID: <20250722101106.526438-46-c.ebner@proxmox.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250722101106.526438-1-c.ebner@proxmox.com> References: <20250722101106.526438-1-c.ebner@proxmox.com> MIME-Version: 1.0 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1753179088206 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.046 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy 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] [PATCH proxmox-backup v11 41/46] bin: implement client subcommands for s3 configuration manipulation X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox Backup Server development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pbs-devel-bounces@lists.proxmox.com Sender: "pbs-devel" Implement and expose the proxmox-backup-manager commands to interact with the s3 client configuration. This mostly requires to insert the commands into the cli command map and bind them to the corresponding api methods. The list method is the only exception, as it requires rendering of the output given the provided output format. Signed-off-by: Christian Ebner Reviewed-by: Lukas Wagner Reviewed-by: Hannes Laimer --- changes since version 10: - no changes src/bin/proxmox_backup_manager/s3.rs | 70 +++++++++++++++++++++++++--- 1 file changed, 63 insertions(+), 7 deletions(-) diff --git a/src/bin/proxmox_backup_manager/s3.rs b/src/bin/proxmox_backup_manager/s3.rs index 9bb89ff55..82bc9413a 100644 --- a/src/bin/proxmox_backup_manager/s3.rs +++ b/src/bin/proxmox_backup_manager/s3.rs @@ -1,4 +1,4 @@ -use proxmox_router::{cli::*, RpcEnvironment}; +use proxmox_router::{cli::*, ApiHandler, RpcEnvironment}; use proxmox_s3_client::{S3_BUCKET_NAME_SCHEMA, S3_CLIENT_ID_SCHEMA}; use proxmox_schema::api; @@ -34,13 +34,69 @@ async fn check( Ok(Value::Null) } +#[api( + input: { + properties: { + "output-format": { + schema: OUTPUT_FORMAT, + optional: true, + }, + } + } +)] +/// List configured s3 clients. +fn list_s3_clients(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result { + let output_format = get_output_format(¶m); + + let info = &api2::config::s3::API_METHOD_LIST_S3_CLIENT_CONFIG; + let mut data = match info.handler { + ApiHandler::Sync(handler) => (handler)(param, info, rpcenv)?, + _ => unreachable!(), + }; + + let options = default_table_format_options() + .column(ColumnConfig::new("id")) + .column(ColumnConfig::new("endpoint")) + .column(ColumnConfig::new("port")) + .column(ColumnConfig::new("region")) + .column(ColumnConfig::new("access-key")) + .column(ColumnConfig::new("fingerprint")) + .column(ColumnConfig::new("path-style")); + + format_and_print_result_full(&mut data, &info.returns, &output_format, &options); + + Ok(Value::Null) +} + pub fn s3_commands() -> CommandLineInterface { - let cmd_def = CliCommandMap::new().insert( - "check", - CliCommand::new(&API_METHOD_CHECK) - .arg_param(&["s3-client-id", "bucket"]) - .completion_cb("s3-client-id", pbs_config::s3::complete_s3_client_id), - ); + let client_cmd_def = CliCommandMap::new() + .insert("list", CliCommand::new(&API_METHOD_LIST_S3_CLIENTS)) + .insert( + "create", + CliCommand::new(&api2::config::s3::API_METHOD_CREATE_S3_CLIENT_CONFIG) + .arg_param(&["id"]), + ) + .insert( + "update", + CliCommand::new(&api2::config::s3::API_METHOD_UPDATE_S3_CLIENT_CONFIG) + .arg_param(&["id"]) + .completion_cb("id", pbs_config::s3::complete_s3_client_id), + ) + .insert( + "remove", + CliCommand::new(&api2::config::s3::API_METHOD_DELETE_S3_CLIENT_CONFIG) + .arg_param(&["id"]) + .completion_cb("id", pbs_config::s3::complete_s3_client_id), + ); + + let cmd_def = CliCommandMap::new() + .insert( + "check", + CliCommand::new(&API_METHOD_CHECK) + .arg_param(&["s3-client-id", "bucket"]) + .completion_cb("s3-client-id", pbs_config::s3::complete_s3_client_id), + ) + .insert("client", client_cmd_def); cmd_def.into() } -- 2.47.2 _______________________________________________ pbs-devel mailing list pbs-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel