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 78AB51FF15C for ; Fri, 28 Nov 2025 16:38:42 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 0BFE51E2BD; Fri, 28 Nov 2025 16:39:02 +0100 (CET) From: Shannon Sterz To: pdm-devel@lists.proxmox.com Date: Fri, 28 Nov 2025 16:38:53 +0100 Message-ID: <20251128153855.543210-3-s.sterz@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251128153855.543210-1-s.sterz@proxmox.com> References: <20251128153855.543210-1-s.sterz@proxmox.com> MIME-Version: 1.0 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1764344297063 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.086 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: [pdm-devel] [PATCH datacenter-manager 2/4] tree-wide: make `returns` defintion match the return type of api methods X-BeenThere: pdm-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Datacenter Manager development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox Datacenter Manager development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pdm-devel-bounces@lists.proxmox.com Sender: "pdm-devel" this takes usually one of the following forms: - an array of the type is defined in the `returns` section, but the type itself not a list of it is returned in the method. - the `returns` section has a hand-crafted definition that is incomplete, even though the type itself could be used directly. - the type in the `returns` section does not match the actual return type at all (e.g. the method returns a unit -> no `returns` section should be specified) Signed-off-by: Shannon Sterz --- server/src/api/config/access/ad.rs | 1 - server/src/api/config/access/ldap.rs | 1 - server/src/api/config/access/openid.rs | 1 - server/src/api/pbs/tasks.rs | 8 ++++++-- server/src/api/pve/firewall.rs | 24 ++++-------------------- server/src/api/pve/lxc.rs | 4 ++-- server/src/api/pve/storage.rs | 2 +- server/src/api/pve/tasks.rs | 8 +++++++- server/src/api/remotes.rs | 4 +--- server/src/api/resources.rs | 8 +------- server/src/api/sdn/vnets.rs | 2 +- server/src/api/sdn/zones.rs | 2 +- 12 files changed, 24 insertions(+), 41 deletions(-) diff --git a/server/src/api/config/access/ad.rs b/server/src/api/config/access/ad.rs index 8167082..b5a3d5a 100644 --- a/server/src/api/config/access/ad.rs +++ b/server/src/api/config/access/ad.rs @@ -184,7 +184,6 @@ pub enum DeletableProperty { }, }, }, - returns: { type: AdRealmConfig }, access: { permission: &Permission::Privilege(&["access", "domains"], PRIV_REALM_ALLOCATE, false), }, diff --git a/server/src/api/config/access/ldap.rs b/server/src/api/config/access/ldap.rs index c5e7732..374284f 100644 --- a/server/src/api/config/access/ldap.rs +++ b/server/src/api/config/access/ldap.rs @@ -216,7 +216,6 @@ pub enum DeletableProperty { }, }, }, - returns: { type: LdapRealmConfig }, access: { permission: &Permission::Privilege(&["access", "domains"], PRIV_REALM_ALLOCATE, false), }, diff --git a/server/src/api/config/access/openid.rs b/server/src/api/config/access/openid.rs index 1832448..5e1764a 100644 --- a/server/src/api/config/access/openid.rs +++ b/server/src/api/config/access/openid.rs @@ -184,7 +184,6 @@ pub enum DeletableProperty { }, }, }, - returns: { type: OpenIdRealmConfig }, access: { permission: &Permission::Privilege(&["access", "domains"], PRIV_REALM_ALLOCATE, false), }, diff --git a/server/src/api/pbs/tasks.rs b/server/src/api/pbs/tasks.rs index a178d81..7e86442 100644 --- a/server/src/api/pbs/tasks.rs +++ b/server/src/api/pbs/tasks.rs @@ -39,7 +39,11 @@ const UPID_API_SUBDIRS: SubdirMap = &sorted!([ // FIXME: fine-grained task filtering? permission: &Permission::Privilege(&["resource", "{remote}"], PRIV_RESOURCE_AUDIT, false), }, - returns: { type: pve_api_types::TaskStatus }, + returns: { + type: Array, + description:"A list of tasks.", + items: { type: pbs_api_types::TaskListItem }, + }, )] /// Get the list of tasks either for a specific node, or query all at once. async fn list_tasks(remote: String) -> Result, Error> { @@ -89,7 +93,7 @@ async fn stop_task(remote: String, upid: RemoteUpid) -> Result<(), Error> { // FIXME: fine-grained task filtering? permission: &Permission::Privilege(&["resource", "{remote}"], PRIV_RESOURCE_AUDIT, false), }, - returns: { type: pve_api_types::TaskStatus }, + returns: { type: pdm_api_types::pbs::TaskStatus }, )] /// Get the status of a task from a Proxmox VE instance. pub async fn get_task_status( diff --git a/server/src/api/pve/firewall.rs b/server/src/api/pve/firewall.rs index 383b2d8..af11d58 100644 --- a/server/src/api/pve/firewall.rs +++ b/server/src/api/pve/firewall.rs @@ -337,11 +337,7 @@ pub async fn pve_firewall_status( remote: { schema: REMOTE_ID_SCHEMA }, }, }, - returns: { - type: Array, - description: "Get firewall options.", - items: { type: pve_api_types::ClusterFirewallOptions }, - }, + returns: { type: pve_api_types::ClusterFirewallOptions }, access: { permission: &Permission::Privilege(&["resource", "{remote}"], PRIV_RESOURCE_AUDIT, false), }, @@ -456,11 +452,7 @@ pub async fn cluster_firewall_status( }, }, }, - returns: { - type: Array, - description: "Get firewall options.", - items: { type: pve_api_types::NodeFirewallOptions }, - }, + returns: { type: pve_api_types::NodeFirewallOptions }, access: { permission: &Permission::Privilege(&["resource", "{remote}"], PRIV_RESOURCE_AUDIT, false), }, @@ -565,11 +557,7 @@ pub async fn cluster_firewall_rules( vmid: { schema: VMID_SCHEMA }, }, }, - returns: { - type: Array, - description: "Get firewall options.", - items: { type: pve_api_types::GuestFirewallOptions }, - }, + returns: { type: pve_api_types::GuestFirewallOptions }, access: { permission: &Permission::Privilege(&["resource", "{remote}", "guest", "{vmid}"], PRIV_RESOURCE_AUDIT, false), }, @@ -687,11 +675,7 @@ pub async fn node_firewall_rules( vmid: { schema: VMID_SCHEMA }, }, }, - returns: { - type: Array, - description: "Get firewall options.", - items: { type: pve_api_types::GuestFirewallOptions }, - }, + returns: { type: pve_api_types::GuestFirewallOptions }, access: { permission: &Permission::Privilege(&["resource", "{remote}", "guest", "{vmid}"], PRIV_RESOURCE_AUDIT, false), }, diff --git a/server/src/api/pve/lxc.rs b/server/src/api/pve/lxc.rs index 96c0957..dc95783 100644 --- a/server/src/api/pve/lxc.rs +++ b/server/src/api/pve/lxc.rs @@ -61,7 +61,7 @@ const LXC_VM_SUBDIRS: SubdirMap = &sorted!([ returns: { type: Array, description: "Get a list of containers.", - items: { type: pve_api_types::VmEntry }, + items: { type: pve_api_types::LxcEntry }, }, access: { permission: &Permission::Privilege(&["resource", "{remote}"], PRIV_RESOURCE_AUDIT, false), @@ -194,7 +194,7 @@ pub async fn lxc_get_pending( vmid: { schema: VMID_SCHEMA }, }, }, - returns: { type: pve_api_types::QemuStatus }, + returns: { type: pve_api_types::LxcStatus }, access: { permission: &Permission::Privilege(&["resource", "{remote}", "guest", "{vmid}"], PRIV_RESOURCE_AUDIT, false), }, diff --git a/server/src/api/pve/storage.rs b/server/src/api/pve/storage.rs index a5338f4..6979711 100644 --- a/server/src/api/pve/storage.rs +++ b/server/src/api/pve/storage.rs @@ -27,7 +27,7 @@ const STORAGE_SUBDIR: SubdirMap = &sorted!([ storage: { schema: PVE_STORAGE_ID_SCHEMA, }, }, }, - returns: { type: pve_api_types::QemuStatus }, + returns: { type: pve_api_types::StorageStatus }, access: { permission: &Permission::Privilege(&["resource", "{remote}", "storage", "{storage}"], PRIV_RESOURCE_AUDIT, false), }, diff --git a/server/src/api/pve/tasks.rs b/server/src/api/pve/tasks.rs index 5edce14..378f100 100644 --- a/server/src/api/pve/tasks.rs +++ b/server/src/api/pve/tasks.rs @@ -43,7 +43,13 @@ const UPID_API_SUBDIRS: SubdirMap = &sorted!([ // FIXME: fine-grained task filtering? permission: &Permission::Privilege(&["resource", "{remote}"], PRIV_RESOURCE_AUDIT, false), }, - returns: { type: pve_api_types::TaskStatus }, + returns: { + type: Array, + description: "A list of tasks.", + items: { + type: pve_api_types::ListTasksResponse + } + }, )] /// Get the list of tasks either for a specific node, or query all at once. async fn list_tasks( diff --git a/server/src/api/remotes.rs b/server/src/api/remotes.rs index bc0c871..76b005d 100644 --- a/server/src/api/remotes.rs +++ b/server/src/api/remotes.rs @@ -67,9 +67,7 @@ pub fn get_remote<'a>( description: "The list of configured remotes.", type: Array, items: { - description: "Remote entry", - type: Object, - properties: {}, + type: Remote, }, }, )] diff --git a/server/src/api/resources.rs b/server/src/api/resources.rs index 7eeb0ce..55056e1 100644 --- a/server/src/api/resources.rs +++ b/server/src/api/resources.rs @@ -458,13 +458,7 @@ pub(crate) async fn get_resources_impl( }, } }, - returns: { - description: "Array of resources, grouped by remote", - type: Array, - items: { - type: RemoteResources, - } - }, + returns: { type: RemoteResources }, )] /// Return the amount of configured/seen resources by type pub async fn get_status( diff --git a/server/src/api/sdn/vnets.rs b/server/src/api/sdn/vnets.rs index ebd2874..5e14c6a 100644 --- a/server/src/api/sdn/vnets.rs +++ b/server/src/api/sdn/vnets.rs @@ -149,7 +149,7 @@ async fn list_vnets( }, }, }, - returns: { type: String, description: "Worker UPID" }, + returns: { schema: pdm_api_types::UPID_SCHEMA }, )] /// Create a VNet across multiple remotes async fn create_vnet( diff --git a/server/src/api/sdn/zones.rs b/server/src/api/sdn/zones.rs index 2ae3d67..c455279 100644 --- a/server/src/api/sdn/zones.rs +++ b/server/src/api/sdn/zones.rs @@ -158,7 +158,7 @@ pub async fn list_zones( }, }, }, - returns: { type: String, description: "Worker UPID" }, + returns: { schema: pdm_api_types::UPID_SCHEMA }, )] /// Create a zone across multiple remotes async fn create_zone( -- 2.47.3 _______________________________________________ pdm-devel mailing list pdm-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel