* [pdm-devel] [PATCH proxmox-api-types 1/2] fix PVE8 node status API call
@ 2025-08-29 10:06 Dominik Csapak
2025-08-29 10:06 ` [pdm-devel] [PATCH proxmox-api-types 2/2] regenerate Dominik Csapak
2025-09-01 12:26 ` [pdm-devel] applied-series: [PATCH proxmox-api-types 1/2] fix PVE8 node status API call Wolfgang Bumiller
0 siblings, 2 replies; 3+ messages in thread
From: Dominik Csapak @ 2025-08-29 10:06 UTC (permalink / raw)
To: pdm-devel
PVE9 added a new non-optional field that does not exist in 8, so for now
overwrite that specific struct with a custom one where 'available' is
optional. This makes the deserialization work again for PVE8 too
In the future we need to think about how to handle different APIs
between version in a better way.
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
pve-api-types/generate.pl | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/pve-api-types/generate.pl b/pve-api-types/generate.pl
index b761a88..966c4d0 100644
--- a/pve-api-types/generate.pl
+++ b/pve-api-types/generate.pl
@@ -264,6 +264,35 @@ Schema2Rust::derive('NetworkInterface' => 'Clone', 'PartialEq');
api(GET => '/nodes/{node}/storage', 'list_storages', 'return-name' => 'StorageInfo');
Schema2Rust::derive('StorageInfo' => 'Clone', 'PartialEq');
+# FIXME: PVE9 introduced a new non optional property, but that does not
+# exist in PVE8, so make it optional here for older PVEs to work
+Schema2Rust::generate_struct(
+ 'NodeStatusMemory',
+ {
+ type => 'object',
+ properties => {
+ 'available' => {
+ type => 'integer',
+ description => 'The available memory in bytes.',
+ optional => 1,
+ },
+ 'free' => {
+ type => 'integer',
+ description => 'The free memory in bytes.',
+ },
+ 'total' => {
+ type => 'integer',
+ description => 'The total memory in bytes.',
+ },
+ 'used' => {
+ type => 'integer',
+ description => 'The used memory in bytes.',
+ },
+ },
+ },
+ {},
+ {},
+);
api(GET => '/nodes/{node}/status', 'node_status', 'return-name' => 'NodeStatus');
Schema2Rust::register_api_override('ClusterMetrics', '/properties/data/items', { type => "ClusterMetricsData"});
--
2.47.2
_______________________________________________
pdm-devel mailing list
pdm-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* [pdm-devel] [PATCH proxmox-api-types 2/2] regenerate
2025-08-29 10:06 [pdm-devel] [PATCH proxmox-api-types 1/2] fix PVE8 node status API call Dominik Csapak
@ 2025-08-29 10:06 ` Dominik Csapak
2025-09-01 12:26 ` [pdm-devel] applied-series: [PATCH proxmox-api-types 1/2] fix PVE8 node status API call Wolfgang Bumiller
1 sibling, 0 replies; 3+ messages in thread
From: Dominik Csapak @ 2025-08-29 10:06 UTC (permalink / raw)
To: pdm-devel
regenerate with the custom struct for NodeStatusMemory
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
pve-api-types/src/generated/types.rs | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/pve-api-types/src/generated/types.rs b/pve-api-types/src/generated/types.rs
index 71a2770..a9f4dfb 100644
--- a/pve-api-types/src/generated/types.rs
+++ b/pve-api-types/src/generated/types.rs
@@ -3670,6 +3670,7 @@ pub struct NodeStatusCurrentKernel {
#[api(
properties: {
available: {
+ optional: true,
type: Integer,
},
free: {
@@ -3688,7 +3689,8 @@ pub struct NodeStatusCurrentKernel {
pub struct NodeStatusMemory {
/// The available memory in bytes.
#[serde(deserialize_with = "proxmox_serde::perl::deserialize_i64")]
- pub available: i64,
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub available: Option<i64>,
/// The free memory in bytes.
#[serde(deserialize_with = "proxmox_serde::perl::deserialize_i64")]
--
2.47.2
_______________________________________________
pdm-devel mailing list
pdm-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* [pdm-devel] applied-series: [PATCH proxmox-api-types 1/2] fix PVE8 node status API call
2025-08-29 10:06 [pdm-devel] [PATCH proxmox-api-types 1/2] fix PVE8 node status API call Dominik Csapak
2025-08-29 10:06 ` [pdm-devel] [PATCH proxmox-api-types 2/2] regenerate Dominik Csapak
@ 2025-09-01 12:26 ` Wolfgang Bumiller
1 sibling, 0 replies; 3+ messages in thread
From: Wolfgang Bumiller @ 2025-09-01 12:26 UTC (permalink / raw)
To: Dominik Csapak; +Cc: pdm-devel
Applied this for now.
Will need to think about how to best do this in general.
One way or another it would probably be good to have the API as a json
input. Ideally we could also drop the *use* of `PVE::API2` in the
generator then, but then we also need to store the named schemas from
registered into `PVE::JSONSchema` from PVE (which does make sense,
though, given that this is part of the API...)
On Fri, Aug 29, 2025 at 12:06:51PM +0200, Dominik Csapak wrote:
> PVE9 added a new non-optional field that does not exist in 8, so for now
> overwrite that specific struct with a custom one where 'available' is
> optional. This makes the deserialization work again for PVE8 too
>
> In the future we need to think about how to handle different APIs
> between version in a better way.
>
> Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
> ---
> pve-api-types/generate.pl | 29 +++++++++++++++++++++++++++++
> 1 file changed, 29 insertions(+)
>
> diff --git a/pve-api-types/generate.pl b/pve-api-types/generate.pl
> index b761a88..966c4d0 100644
> --- a/pve-api-types/generate.pl
> +++ b/pve-api-types/generate.pl
> @@ -264,6 +264,35 @@ Schema2Rust::derive('NetworkInterface' => 'Clone', 'PartialEq');
> api(GET => '/nodes/{node}/storage', 'list_storages', 'return-name' => 'StorageInfo');
> Schema2Rust::derive('StorageInfo' => 'Clone', 'PartialEq');
>
> +# FIXME: PVE9 introduced a new non optional property, but that does not
> +# exist in PVE8, so make it optional here for older PVEs to work
> +Schema2Rust::generate_struct(
> + 'NodeStatusMemory',
> + {
> + type => 'object',
> + properties => {
> + 'available' => {
> + type => 'integer',
> + description => 'The available memory in bytes.',
> + optional => 1,
> + },
> + 'free' => {
> + type => 'integer',
> + description => 'The free memory in bytes.',
> + },
> + 'total' => {
> + type => 'integer',
> + description => 'The total memory in bytes.',
> + },
> + 'used' => {
> + type => 'integer',
> + description => 'The used memory in bytes.',
> + },
> + },
> + },
> + {},
> + {},
> +);
> api(GET => '/nodes/{node}/status', 'node_status', 'return-name' => 'NodeStatus');
>
> Schema2Rust::register_api_override('ClusterMetrics', '/properties/data/items', { type => "ClusterMetricsData"});
> --
> 2.47.2
_______________________________________________
pdm-devel mailing list
pdm-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-09-01 12:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-08-29 10:06 [pdm-devel] [PATCH proxmox-api-types 1/2] fix PVE8 node status API call Dominik Csapak
2025-08-29 10:06 ` [pdm-devel] [PATCH proxmox-api-types 2/2] regenerate Dominik Csapak
2025-09-01 12:26 ` [pdm-devel] applied-series: [PATCH proxmox-api-types 1/2] fix PVE8 node status API call Wolfgang Bumiller
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.