api: serde-rename deleteable properties to kebab-case

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@proxmox.com>
This commit is contained in:
Lukas Wagner 2023-01-19 16:52:32 +01:00 committed by Thomas Lamprecht
parent 1f84ac052b
commit 9936c03a52
4 changed files with 7 additions and 1 deletions

View File

@ -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.

View File

@ -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.

View File

@ -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

View File

@ -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,
}