[pbs-devel] [PATCH proxmox-backup] api: serde-rename deleteable properties to kebab-case
Lukas Wagner
l.wagner at proxmox.com
Thu Jan 19 16:52:32 CET 2023
In former commit, the enum members were renamed to be CamelCase, in
accordance with the usual Rust style guide. However, this broke the
GUI in some places due to failing JSON property deserialization.
To fix this, some serde(rename = "kebab-case") directives were added.
Some properties were also serde-renamed to snake_case, otherwise
it would have been necessary to also modify proxmox-widget-toolkit
as well as PVE source code. This can follow in a later commit if so
desired.
Fixes: a2055c38 fix non-camel-case enums
Signed-off-by: Lukas Wagner <l.wagner at proxmox.com>
---
src/api2/config/media_pool.rs | 1 +
src/api2/config/remote.rs | 1 +
src/api2/node/dns.rs | 1 +
src/api2/node/network.rs | 5 ++++-
4 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/src/api2/config/media_pool.rs b/src/api2/config/media_pool.rs
index 79e2e9c5..4a4cec56 100644
--- a/src/api2/config/media_pool.rs
+++ b/src/api2/config/media_pool.rs
@@ -103,6 +103,7 @@ pub fn get_config(name: String) -> Result<MediaPoolConfig, Error> {
#[api()]
#[derive(Serialize, Deserialize)]
+#[serde(rename_all = "kebab-case")]
/// Deletable property name
pub enum DeletableProperty {
/// Delete media set allocation policy.
diff --git a/src/api2/config/remote.rs b/src/api2/config/remote.rs
index fb97b3e1..2f02d121 100644
--- a/src/api2/config/remote.rs
+++ b/src/api2/config/remote.rs
@@ -133,6 +133,7 @@ pub fn read_remote(
#[api()]
#[derive(Serialize, Deserialize)]
+#[serde(rename_all = "kebab-case")]
/// Deletable property name
pub enum DeletableProperty {
/// Delete the comment property.
diff --git a/src/api2/node/dns.rs b/src/api2/node/dns.rs
index 6804a102..4f6822d8 100644
--- a/src/api2/node/dns.rs
+++ b/src/api2/node/dns.rs
@@ -22,6 +22,7 @@ static RESOLV_CONF_FN: &str = "/etc/resolv.conf";
#[api()]
#[derive(Serialize, Deserialize)]
+#[serde(rename_all = "kebab-case")]
/// Deletable property name
pub enum DeletableProperty {
/// Delete first nameserver entry
diff --git a/src/api2/node/network.rs b/src/api2/node/network.rs
index fef0a6cb..ade6fe40 100644
--- a/src/api2/node/network.rs
+++ b/src/api2/node/network.rs
@@ -400,6 +400,7 @@ pub fn create_interface(
#[api()]
#[derive(Serialize, Deserialize)]
+#[serde(rename_all = "kebab-case")]
/// Deletable property name
pub enum DeletableProperty {
/// Delete the IPv4 address property.
@@ -423,15 +424,17 @@ pub enum DeletableProperty {
/// Delete autostart flag
Autostart,
/// Delete bridge ports (set to 'none')
+ #[serde(rename = "bridge_ports")]
BridgePorts,
/// Delete bridge-vlan-aware flag
+ #[serde(rename = "bridge_vlan_aware")]
BridgeVlanAware,
/// Delete bond-slaves (set to 'none')
Slaves,
/// Delete bond-primary
- #[serde(rename = "bond-primary")]
BondPrimary,
/// Delete bond transmit hash policy
+ #[serde(rename = "bond_xmit_hash_policy")]
BondXmitHashPolicy,
}
--
2.30.2
More information about the pbs-devel
mailing list