[pdm-devel] [PATCH proxmox 03/13] network-types: implement api type for Fqdn
Christoph Heiss
c.heiss at proxmox.com
Thu Dec 4 13:51:12 CET 2025
Pretty straight-forward, as we already got a fitting regex defined for a
FQDN.
Signed-off-by: Christoph Heiss <c.heiss at proxmox.com>
---
proxmox-network-types/src/fqdn.rs | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/proxmox-network-types/src/fqdn.rs b/proxmox-network-types/src/fqdn.rs
index 9582639d..3c1bd475 100644
--- a/proxmox-network-types/src/fqdn.rs
+++ b/proxmox-network-types/src/fqdn.rs
@@ -2,6 +2,9 @@
use std::{fmt, str::FromStr};
+#[cfg(feature = "api-types")]
+use proxmox_schema::UpdaterType;
+
use serde::Deserialize;
/// Possible errors that might occur when parsing FQDNs.
@@ -55,6 +58,7 @@ impl fmt::Display for FqdnParseError {
/// [RFC4343]: <https://www.ietf.org/rfc/rfc4343.txt>
/// [hostname(7)]: <https://manpages.debian.org/stable/manpages/hostname.7.en.html>
#[derive(Clone, Debug, Eq)]
+#[cfg_attr(feature = "api-types", derive(UpdaterType))]
pub struct Fqdn {
parts: Vec<String>,
}
@@ -132,6 +136,16 @@ impl Fqdn {
}
}
+#[cfg(feature = "api-types")]
+impl proxmox_schema::ApiType for Fqdn {
+ const API_SCHEMA: proxmox_schema::Schema =
+ proxmox_schema::StringSchema::new("Fully-qualified domain name")
+ .format(&proxmox_schema::ApiStringFormat::Pattern(
+ &proxmox_schema::api_types::DNS_NAME_REGEX,
+ ))
+ .schema();
+}
+
impl FromStr for Fqdn {
type Err = FqdnParseError;
--
2.51.2
More information about the pdm-devel
mailing list