[pdm-devel] [PATCH proxmox-api-types 04/12] sdn: generate vnet endpoints
Stefan Hanreich
s.hanreich at proxmox.com
Fri Feb 28 16:17:41 CET 2025
Signed-off-by: Stefan Hanreich <s.hanreich at proxmox.com>
---
pve-api-types/src/generated/code.rs | 34 +++-
pve-api-types/src/generated/types.rs | 245 +++++++++++++++++++++++++++
2 files changed, 278 insertions(+), 1 deletion(-)
diff --git a/pve-api-types/src/generated/code.rs b/pve-api-types/src/generated/code.rs
index c1f0e74..f5a993c 100644
--- a/pve-api-types/src/generated/code.rs
+++ b/pve-api-types/src/generated/code.rs
@@ -118,7 +118,6 @@
/// - /cluster/sdn/ipams/{ipam}/status
/// - /cluster/sdn/lock
/// - /cluster/sdn/rollback
-/// - /cluster/sdn/vnets
/// - /cluster/sdn/vnets/{vnet}
/// - /cluster/sdn/vnets/{vnet}/firewall
/// - /cluster/sdn/vnets/{vnet}/firewall/options
@@ -411,6 +410,11 @@ pub trait PveClient {
Err(Error::Other("create_token not implemented"))
}
+ /// Create a new sdn vnet object.
+ async fn create_vnet(&self, params: CreateVnet) -> Result<(), Error> {
+ Err(Error::Other("create_vnet not implemented"))
+ }
+
/// Create a new sdn zone object.
async fn create_zone(&self, params: CreateZone) -> Result<(), Error> {
Err(Error::Other("create_zone not implemented"))
@@ -489,6 +493,15 @@ pub trait PveClient {
Err(Error::Other("list_storages not implemented"))
}
+ /// SDN vnets index.
+ async fn list_vnets(
+ &self,
+ pending: Option<bool>,
+ running: Option<bool>,
+ ) -> Result<Vec<SdnVnet>, Error> {
+ Err(Error::Other("list_vnets not implemented"))
+ }
+
/// SDN zones index.
async fn list_zones(
&self,
@@ -726,6 +739,12 @@ where
Ok(self.0.post(url, ¶ms).await?.expect_json()?.data)
}
+ /// Create a new sdn vnet object.
+ async fn create_vnet(&self, params: CreateVnet) -> Result<(), Error> {
+ let url = "/api2/extjs/cluster/sdn/vnets";
+ self.0.post(url, ¶ms).await?.nodata()
+ }
+
/// Create a new sdn zone object.
async fn create_zone(&self, params: CreateZone) -> Result<(), Error> {
let url = "/api2/extjs/cluster/sdn/zones";
@@ -852,6 +871,19 @@ where
Ok(self.0.get(url).await?.expect_json()?.data)
}
+ /// SDN vnets index.
+ async fn list_vnets(
+ &self,
+ pending: Option<bool>,
+ running: Option<bool>,
+ ) -> Result<Vec<SdnVnet>, Error> {
+ let (mut query, mut sep) = (String::new(), '?');
+ add_query_bool(&mut query, &mut sep, "pending", pending);
+ add_query_bool(&mut query, &mut sep, "running", running);
+ let url = &format!("/api2/extjs/cluster/sdn/vnets{query}");
+ Ok(self.0.get(url).await?.expect_json()?.data)
+ }
+
/// SDN zones index.
async fn list_zones(
&self,
diff --git a/pve-api-types/src/generated/types.rs b/pve-api-types/src/generated/types.rs
index 408d8ca..871707a 100644
--- a/pve-api-types/src/generated/types.rs
+++ b/pve-api-types/src/generated/types.rs
@@ -932,6 +932,91 @@ pub struct CreateTokenResponseInfo {
const_regex! {
+CREATE_VNET_VNET_RE = r##"^[a-z][a-z0-9]*[a-z0-9]$"##;
+
+}
+
+#[api(
+ properties: {
+ alias: {
+ max_length: 256,
+ optional: true,
+ type: String,
+ },
+ "isolate-ports": {
+ default: false,
+ optional: true,
+ },
+ "lock-secret": {
+ optional: true,
+ type: String,
+ },
+ tag: {
+ maximum: 16777215,
+ minimum: 1,
+ optional: true,
+ type: Integer,
+ },
+ type: {
+ optional: true,
+ type: SdnVnetType,
+ },
+ vlanaware: {
+ default: false,
+ optional: true,
+ },
+ vnet: {
+ format: &ApiStringFormat::Pattern(&CREATE_VNET_VNET_RE),
+ type: String,
+ },
+ zone: {
+ type: String,
+ },
+ },
+)]
+/// Object.
+#[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)]
+pub struct CreateVnet {
+ /// Alias name of the VNet.
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub alias: Option<String>,
+
+ /// If true, sets the isolated property for all interfaces on the bridge of
+ /// this VNet.
+ #[serde(deserialize_with = "proxmox_login::parse::deserialize_bool")]
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ #[serde(rename = "isolate-ports")]
+ pub isolate_ports: Option<bool>,
+
+ /// the secret for unlocking the global SDN configuration
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ #[serde(rename = "lock-secret")]
+ pub lock_secret: Option<String>,
+
+ /// VLAN Tag (for VLAN or QinQ zones) or VXLAN VNI (for VXLAN or EVPN
+ /// zones).
+ #[serde(deserialize_with = "proxmox_login::parse::deserialize_u32")]
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub tag: Option<u32>,
+
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ #[serde(rename = "type")]
+ pub ty: Option<SdnVnetType>,
+
+ /// Allow VLANs to pass through this vnet.
+ #[serde(deserialize_with = "proxmox_login::parse::deserialize_bool")]
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub vlanaware: Option<bool>,
+
+ /// The SDN vnet object identifier.
+ pub vnet: String,
+
+ /// Name of the zone this VNet belongs to.
+ pub zone: String,
+}
+
+const_regex! {
+
CREATE_ZONE_EXITNODES_RE = r##"^(?i:[a-z0-9](?i:[a-z0-9\-]*[a-z0-9])?)$"##;
CREATE_ZONE_EXITNODES_PRIMARY_RE = r##"^(?i:[a-z0-9](?i:[a-z0-9\-]*[a-z0-9])?)$"##;
CREATE_ZONE_MAC_RE = r##"^(?i)[a-f0-9][02468ace](?::[a-f0-9]{2}){5}$"##;
@@ -9127,6 +9212,166 @@ pub enum SdnObjectState {
serde_plain::derive_display_from_serialize!(SdnObjectState);
serde_plain::derive_fromstr_from_deserialize!(SdnObjectState);
+#[api(
+ properties: {
+ alias: {
+ max_length: 256,
+ optional: true,
+ type: String,
+ },
+ digest: {
+ optional: true,
+ type: String,
+ },
+ "isolate-ports": {
+ default: false,
+ optional: true,
+ },
+ pending: {
+ optional: true,
+ type: SdnVnetPending,
+ },
+ state: {
+ optional: true,
+ type: SdnObjectState,
+ },
+ tag: {
+ maximum: 16777215,
+ minimum: 1,
+ optional: true,
+ type: Integer,
+ },
+ type: {
+ type: SdnVnetType,
+ },
+ vlanaware: {
+ default: false,
+ optional: true,
+ },
+ vnet: {
+ type: String,
+ },
+ zone: {
+ optional: true,
+ type: String,
+ },
+ },
+)]
+/// Object.
+#[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)]
+pub struct SdnVnet {
+ /// Alias name of the VNet.
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub alias: Option<String>,
+
+ /// Digest of the VNet section.
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub digest: Option<String>,
+
+ /// If true, sets the isolated property for all interfaces on the bridge of
+ /// this VNet.
+ #[serde(deserialize_with = "proxmox_login::parse::deserialize_bool")]
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ #[serde(rename = "isolate-ports")]
+ pub isolate_ports: Option<bool>,
+
+ /// Changes that have not yet been applied to the running configuration.
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub pending: Option<SdnVnetPending>,
+
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub state: Option<SdnObjectState>,
+
+ /// VLAN Tag (for VLAN or QinQ zones) or VXLAN VNI (for VXLAN or EVPN
+ /// zones).
+ #[serde(deserialize_with = "proxmox_login::parse::deserialize_u32")]
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub tag: Option<u32>,
+
+ #[serde(rename = "type")]
+ pub ty: SdnVnetType,
+
+ /// Allow VLANs to pass through this VNet.
+ #[serde(deserialize_with = "proxmox_login::parse::deserialize_bool")]
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub vlanaware: Option<bool>,
+
+ /// Name of the VNet.
+ pub vnet: String,
+
+ /// Name of the zone this VNet belongs to.
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub zone: Option<String>,
+}
+
+#[api(
+ properties: {
+ alias: {
+ max_length: 256,
+ optional: true,
+ type: String,
+ },
+ "isolate-ports": {
+ default: false,
+ optional: true,
+ },
+ tag: {
+ maximum: 16777215,
+ minimum: 1,
+ optional: true,
+ type: Integer,
+ },
+ vlanaware: {
+ default: false,
+ optional: true,
+ },
+ zone: {
+ optional: true,
+ type: String,
+ },
+ },
+)]
+/// Changes that have not yet been applied to the running configuration.
+#[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)]
+pub struct SdnVnetPending {
+ /// Alias name of the VNet.
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub alias: Option<String>,
+
+ /// If true, sets the isolated property for all interfaces on the bridge of
+ /// this VNet.
+ #[serde(deserialize_with = "proxmox_login::parse::deserialize_bool")]
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ #[serde(rename = "isolate-ports")]
+ pub isolate_ports: Option<bool>,
+
+ /// VLAN Tag (for VLAN or QinQ zones) or VXLAN VNI (for VXLAN or EVPN
+ /// zones).
+ #[serde(deserialize_with = "proxmox_login::parse::deserialize_u32")]
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub tag: Option<u32>,
+
+ /// Allow VLANs to pass through this VNet.
+ #[serde(deserialize_with = "proxmox_login::parse::deserialize_bool")]
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub vlanaware: Option<bool>,
+
+ /// Name of the zone this VNet belongs to.
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub zone: Option<String>,
+}
+
+#[api]
+/// Type of the VNet.
+#[derive(Clone, Copy, Debug, Eq, PartialEq, serde::Deserialize, serde::Serialize)]
+pub enum SdnVnetType {
+ #[serde(rename = "vnet")]
+ /// vnet.
+ Vnet,
+}
+serde_plain::derive_display_from_serialize!(SdnVnetType);
+serde_plain::derive_fromstr_from_deserialize!(SdnVnetType);
+
const_regex! {
SDN_ZONE_EXITNODES_RE = r##"^(?i:[a-z0-9](?i:[a-z0-9\-]*[a-z0-9])?)$"##;
--
2.39.5
More information about the pdm-devel
mailing list