Add a new FirewallAliasEntry struct that represents a firewall alias definition (items from GET /cluster/firewall/aliases).
Signed-off-by: Dietmar Maurer <[email protected]> --- proxmox-firewall-api-types/src/alias.rs | 39 +++++++++++++++++++++++++ proxmox-firewall-api-types/src/lib.rs | 2 +- 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/proxmox-firewall-api-types/src/alias.rs b/proxmox-firewall-api-types/src/alias.rs index 7722148c..9f87b43f 100644 --- a/proxmox-firewall-api-types/src/alias.rs +++ b/proxmox-firewall-api-types/src/alias.rs @@ -2,6 +2,11 @@ use std::fmt; use std::str::FromStr; use anyhow::{bail, Error}; +use serde::{Deserialize, Serialize}; + +use proxmox_config_digest::ConfigDigest; +use proxmox_network_types::ip_address::Cidr; +use proxmox_schema::{api, api_types::COMMENT_SCHEMA}; #[cfg(feature = "enum-fallback")] use proxmox_fixed_string::FixedString; @@ -97,6 +102,40 @@ impl FromStr for FirewallAliasReference { } } +#[api( + properties: { + name: { + type: String, + format: &proxmox_schema::ApiStringFormat::VerifyFn(verify_alias_name), + }, + cidr: { + type: String, + }, + comment: { + optional: true, + schema: COMMENT_SCHEMA, + }, + }, +)] +/// Firewall alias definition entry, assigns a CIDR to a name. +/// +/// The name can be used in firewall rules to refer to the CIDR. +#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] +pub struct FirewallAliasEntry { + /// The name of the alias entry. + pub name: String, + + /// Network/IP specification in CIDR format. + pub cidr: Cidr, + + /// Digest to detect concurrent modifications. + pub digest: ConfigDigest, + + /// Descriptive comment. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub comment: Option<String>, +} + #[cfg(test)] mod tests { use super::*; diff --git a/proxmox-firewall-api-types/src/lib.rs b/proxmox-firewall-api-types/src/lib.rs index 0eebd727..044fc761 100644 --- a/proxmox-firewall-api-types/src/lib.rs +++ b/proxmox-firewall-api-types/src/lib.rs @@ -2,7 +2,7 @@ mod address; pub use address::{FirewallAddressEntry, FirewallAddressList, FirewallAddressMatch}; mod alias; -pub use alias::{FirewallAliasReference, FirewallAliasScope}; +pub use alias::{FirewallAliasEntry, FirewallAliasReference, FirewallAliasScope}; mod conntrack; pub use conntrack::FirewallConntrackHelper; -- 2.47.3
