From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id D09B61FF16B for ; Tue, 15 Jul 2025 15:02:54 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 3CD243CEA2; Tue, 15 Jul 2025 15:03:53 +0200 (CEST) From: Christian Ebner To: pbs-devel@lists.proxmox.com Date: Tue, 15 Jul 2025 14:53:27 +0200 Message-ID: <20250715125332.954494-50-c.ebner@proxmox.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250715125332.954494-1-c.ebner@proxmox.com> References: <20250715125332.954494-1-c.ebner@proxmox.com> MIME-Version: 1.0 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 RCVD_IN_MSPIKE_H2 0.001 Average reputation (+2) SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [s3.rs] Subject: [pbs-devel] [PATCH proxmox-backup v8 40/45] 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 --- changes since version 7: - new in this version 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