From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <pdm-devel-bounces@lists.proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68])
	by lore.proxmox.com (Postfix) with ESMTPS id C2B6F1FF164
	for <inbox@lore.proxmox.com>; Fri, 28 Feb 2025 16:19:09 +0100 (CET)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
	by firstgate.proxmox.com (Proxmox) with ESMTP id 0C467121A5;
	Fri, 28 Feb 2025 16:19:08 +0100 (CET)
From: Stefan Hanreich <s.hanreich@proxmox.com>
To: pdm-devel@lists.proxmox.com
Date: Fri, 28 Feb 2025 16:17:41 +0100
Message-Id: <20250228151803.158984-5-s.hanreich@proxmox.com>
X-Mailer: git-send-email 2.39.5
In-Reply-To: <20250228151803.158984-1-s.hanreich@proxmox.com>
References: <20250228151803.158984-1-s.hanreich@proxmox.com>
MIME-Version: 1.0
X-SPAM-LEVEL: Spam detection results:  0
 AWL -0.381 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DMARC_MISSING             0.1 Missing DMARC policy
 KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment
 KAM_LAZY_DOMAIN_SECURITY 1 Sending domain does not have any anti-forgery
 methods POISEN_SPAM_PILL          0.1 Meta: its spam
 POISEN_SPAM_PILL_1        0.1 random spam to be learned in bayes
 POISEN_SPAM_PILL_3        0.1 random spam to be learned in bayes
 RDNS_NONE 0.793 Delivered to internal network by a host with no rDNS
 SPF_HELO_NONE           0.001 SPF: HELO does not publish an SPF Record
 SPF_NONE                0.001 SPF: sender does not publish an SPF Record
Subject: [pdm-devel] [PATCH proxmox-api-types 04/12] sdn: generate vnet
 endpoints
X-BeenThere: pdm-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox Datacenter Manager development discussion
 <pdm-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pdm-devel>, 
 <mailto:pdm-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pdm-devel/>
List-Post: <mailto:pdm-devel@lists.proxmox.com>
List-Help: <mailto:pdm-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel>, 
 <mailto:pdm-devel-request@lists.proxmox.com?subject=subscribe>
Reply-To: Proxmox Datacenter Manager development discussion
 <pdm-devel@lists.proxmox.com>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: pdm-devel-bounces@lists.proxmox.com
Sender: "pdm-devel" <pdm-devel-bounces@lists.proxmox.com>

Signed-off-by: Stefan Hanreich <s.hanreich@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, &params).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, &params).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


_______________________________________________
pdm-devel mailing list
pdm-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel