[PATCH datacenter-manager v3 14/38] api-types, cli: use ReturnType::new() instead of constructing it manually

Christoph Heiss
2026-04-03T16:56:02Z

.. like everywhere else.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
---
Changes v2 -> v3:
* new patch

cli/client/src/pbs.rs | 10 ++--------
cli/client/src/pve.rs | 15 +++------------
cli/client/src/remotes.rs | 5 +----
lib/pdm-api-types/src/lib.rs | 8 ++++----
4 files changed, 10 insertions(+), 28 deletions(-)

diff --git a/cli/client/src/pbs.rs b/cli/client/src/pbs.rs
index 9972824..c59e0be 100644
--- a/cli/client/src/pbs.rs
+++ b/cli/client/src/pbs.rs
@@ -239,10 +239,7 @@ async fn list_tasks(remote: String) -> Result<(), Error> {

format_and_print_result_full(
&mut serde_json::to_value(data)?,
- &ReturnType {
- optional: false,
- schema: &TASK_LIST_SCHEMA,
- },
+ &ReturnType::new(false, &TASK_LIST_SCHEMA),
&env().format_args.output_format.to_string(),
&proxmox_router::cli::default_table_format_options(),
);
@@ -266,10 +263,7 @@ async fn task_status(remote: String, upid: String) -> Result<(), Error> {

format_and_print_result_full(
&mut serde_json::to_value(data)?,
- &ReturnType {
- optional: false,
- schema: &pdm_api_types::pbs::TaskStatus::API_SCHEMA,
- },
+ &ReturnType::new(false, &pdm_api_types::pbs::TaskStatus::API_SCHEMA),
&env().format_args.output_format.to_string(),
&Default::default(),
);
diff --git a/cli/client/src/pve.rs b/cli/client/src/pve.rs
index 19bd098..3bbc399 100644
--- a/cli/client/src/pve.rs
+++ b/cli/client/src/pve.rs
@@ -238,10 +238,7 @@ async fn cluster_resources(

format_and_print_result_full(
&mut serde_json::to_value(data)?,
- &ReturnType {
- optional: false,
- schema: &CLUSTER_LIST_SCHEMA,
- },
+ &ReturnType::new(false, &CLUSTER_LIST_SCHEMA),
&env().format_args.output_format.to_string(),
&Default::default(),
);
@@ -1077,10 +1074,7 @@ async fn list_tasks(remote: String, node: Option<String>) -> Result<(), Error> {

format_and_print_result_full(
&mut serde_json::to_value(data)?,
- &ReturnType {
- optional: false,
- schema: &TASK_LIST_SCHEMA,
- },
+ &ReturnType::new(false, &TASK_LIST_SCHEMA),
&env().format_args.output_format.to_string(),
&proxmox_router::cli::default_table_format_options(),
);
@@ -1104,10 +1098,7 @@ async fn task_status(remote: String, upid: String) -> Result<(), Error> {

format_and_print_result_full(
&mut serde_json::to_value(data)?,
- &ReturnType {
- optional: false,
- schema: &pve_api_types::TaskStatus::API_SCHEMA,
- },
+ &ReturnType::new(false, &pve_api_types::TaskStatus::API_SCHEMA),
&env().format_args.output_format.to_string(),
&Default::default(),
);
diff --git a/cli/client/src/remotes.rs b/cli/client/src/remotes.rs
index e087809..693774f 100644
--- a/cli/client/src/remotes.rs
+++ b/cli/client/src/remotes.rs
@@ -142,10 +142,7 @@ async fn remote_version(id: String) -> Result<(), Error> {
let data = client()?.remote_version(&id).await?;
format_and_print_result_full(
&mut serde_json::to_value(data)?,
- &ReturnType {
- optional: false,
- schema: &pve_api_types::VersionResponse::API_SCHEMA,
- },
+ &ReturnType::new(false, &pve_api_types::VersionResponse::API_SCHEMA),
&env().format_args.output_format.to_string(),
&Default::default(),
);
diff --git a/lib/pdm-api-types/src/lib.rs b/lib/pdm-api-types/src/lib.rs
index fec3c8f..aea1b5d 100644
--- a/lib/pdm-api-types/src/lib.rs
+++ b/lib/pdm-api-types/src/lib.rs
@@ -322,10 +322,10 @@ pub struct TaskStatistics {
pub by_remote: HashMap<String, TaskCount>,
}

-pub const NODE_TASKS_LIST_TASKS_RETURN_TYPE: ReturnType = ReturnType {
- optional: false,
- schema: &ArraySchema::new("A list of tasks.", &TaskListItem::API_SCHEMA).schema(),
-};
+pub const NODE_TASKS_LIST_TASKS_RETURN_TYPE: ReturnType = ReturnType::new(
+ false,
+ &ArraySchema::new("A list of tasks.", &TaskListItem::API_SCHEMA).schema(),
+);

#[api]
#[derive(Deserialize, Serialize, Copy, Clone, PartialEq, Eq)]
--
2.53.0