[pbs-devel] [PATCH proxmox-backup v11 41/46] bin: implement client subcommands for s3 configuration manipulation

Christian Ebner c.ebner at proxmox.com
Tue Jul 22 12:11:01 CEST 2025


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 <c.ebner at proxmox.com>
Reviewed-by: Lukas Wagner <l.wagner at proxmox.com>
Reviewed-by: Hannes Laimer <h.laimer at proxmox.com>
---
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<Value, Error> {
+    let output_format = get_output_format(&param);
+
+    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





More information about the pbs-devel mailing list