[pdm-devel] [PATCH proxmox-api-types 1/1] add /access/domains GET call
Dominik Csapak
d.csapak at proxmox.com
Thu Dec 19 13:09:17 CET 2024
so we can query remote realms
Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
pve-api-types/generate.pl | 7 +++-
pve-api-types/src/generated/code.rs | 12 ++++++-
pve-api-types/src/generated/types.rs | 51 ++++++++++++++++++++++++++++
3 files changed, 68 insertions(+), 2 deletions(-)
diff --git a/pve-api-types/generate.pl b/pve-api-types/generate.pl
index e72898e..4c8e164 100644
--- a/pve-api-types/generate.pl
+++ b/pve-api-types/generate.pl
@@ -280,7 +280,12 @@ Schema2Rust::register_api_extensions('ClusterJoinInfo', {
api(GET => '/cluster/config/join', 'cluster_config_join', 'return-name' => 'ClusterJoinInfo');
# api(GET => '/storage', 'list_storages', 'return-name' => 'StorageList');
-# api(GET => '/access/domains', 'list_domains', 'return-name' => 'ListRealm');
+Schema2Rust::register_api_extensions('ListRealm', {
+ '/properties/realm' => { description => sq("FIXME: Missing description in PVE.") },
+ '/properties/type' => { description => sq("FIXME: Missing description in PVE.") },
+});
+api(GET => '/access/domains', 'list_domains', 'return-name' => 'ListRealm');
+Schema2Rust::derive('ListRealm' => 'Clone', 'PartialEq');
# api(GET => '/access/groups', 'list_groups', 'return-name' => 'ListGroups');
# api(GET => '/access/groups/{groupid}', 'get_group', 'return-name' => 'Group');
# api(GET => '/access/users', 'list_users', 'return-name' => 'ListUsers');
diff --git a/pve-api-types/src/generated/code.rs b/pve-api-types/src/generated/code.rs
index 33317a3..dc17cd9 100644
--- a/pve-api-types/src/generated/code.rs
+++ b/pve-api-types/src/generated/code.rs
@@ -4,7 +4,6 @@
/// ```text
/// - /access
/// - /access/acl
-/// - /access/domains
/// - /access/domains/{realm}
/// - /access/domains/{realm}/sync
/// - /access/groups
@@ -438,6 +437,11 @@ pub trait PveClient {
Err(Error::Other("get_task_status not implemented"))
}
+ /// Authentication domain index.
+ async fn list_domains(&self) -> Result<Vec<ListRealm>, Error> {
+ Err(Error::Other("list_domains not implemented"))
+ }
+
/// LXC container index (per node).
async fn list_lxc(&self, node: &str) -> Result<Vec<LxcEntry>, Error> {
Err(Error::Other("list_lxc not implemented"))
@@ -758,6 +762,12 @@ where
Ok(self.0.get(&url).await?.expect_json()?.data)
}
+ /// Authentication domain index.
+ async fn list_domains(&self) -> Result<Vec<ListRealm>, Error> {
+ let url = format!("/api2/extjs/access/domains");
+ Ok(self.0.get(&url).await?.expect_json()?.data)
+ }
+
/// LXC container index (per node).
async fn list_lxc(&self, node: &str) -> Result<Vec<LxcEntry>, Error> {
let url = format!("/api2/extjs/nodes/{node}/lxc");
diff --git a/pve-api-types/src/generated/types.rs b/pve-api-types/src/generated/types.rs
index 06d9fe3..76c66b5 100644
--- a/pve-api-types/src/generated/types.rs
+++ b/pve-api-types/src/generated/types.rs
@@ -969,6 +969,57 @@ pub enum ListNetworksType {
serde_plain::derive_display_from_serialize!(ListNetworksType);
serde_plain::derive_fromstr_from_deserialize!(ListNetworksType);
+#[api(
+ properties: {
+ comment: {
+ optional: true,
+ type: String,
+ },
+ realm: {
+ type: String,
+ description: "FIXME: Missing description in PVE.",
+ },
+ tfa: {
+ optional: true,
+ type: ListRealmTfa,
+ },
+ type: {
+ type: String,
+ description: "FIXME: Missing description in PVE.",
+ },
+ },
+)]
+/// Object.
+#[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)]
+pub struct ListRealm {
+ /// A comment. The GUI use this text when you select a domain (Realm) on the
+ /// login window.
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub comment: Option<String>,
+
+ pub realm: String,
+
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub tfa: Option<ListRealmTfa>,
+
+ #[serde(rename = "type")]
+ pub ty: String,
+}
+
+#[api]
+/// Two-factor authentication provider.
+#[derive(Clone, Copy, Debug, Eq, PartialEq, serde::Deserialize, serde::Serialize)]
+pub enum ListRealmTfa {
+ #[serde(rename = "yubico")]
+ /// yubico.
+ Yubico,
+ #[serde(rename = "oath")]
+ /// oath.
+ Oath,
+}
+serde_plain::derive_display_from_serialize!(ListRealmTfa);
+serde_plain::derive_fromstr_from_deserialize!(ListRealmTfa);
+
const_regex! {
LIST_TASKS_STATUSFILTER_RE = r##"^(?i:ok|error|warning|unknown)$"##;
--
2.39.5
More information about the pdm-devel
mailing list