From 1c8efc00626219f1b44e088b166f7f988582d719 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Mon, 7 Mar 2022 07:41:03 +0100 Subject: [PATCH] cleanup: move BasicRealmInfo to pbs-api-types Signed-off-by: Dietmar Maurer --- pbs-api-types/src/lib.rs | 41 ++++++++++++++++++++++++++++++++++ src/api2/access/domain.rs | 46 +-------------------------------------- 2 files changed, 42 insertions(+), 45 deletions(-) diff --git a/pbs-api-types/src/lib.rs b/pbs-api-types/src/lib.rs index 754e7b22..2f51afd9 100644 --- a/pbs-api-types/src/lib.rs +++ b/pbs-api-types/src/lib.rs @@ -442,3 +442,44 @@ pub enum RRDTimeFrame { /// Decade (10 years) Decade, } + +#[api] +#[derive(Deserialize, Serialize, PartialEq, Eq)] +#[serde(rename_all = "lowercase")] +/// type of the realm +pub enum RealmType { + /// The PAM realm + Pam, + /// The PBS realm + Pbs, + /// An OpenID Connect realm + OpenId, +} + +#[api( + properties: { + realm: { + schema: REALM_ID_SCHEMA, + }, + "type": { + type: RealmType, + }, + comment: { + optional: true, + schema: SINGLE_LINE_COMMENT_SCHEMA, + }, + }, +)] +#[derive(Deserialize, Serialize)] +#[serde(rename_all = "kebab-case")] +/// Basic Information about a realm +pub struct BasicRealmInfo { + pub realm: String, + #[serde(rename = "type")] + pub ty: RealmType, + /// True if it is the default realm + #[serde(skip_serializing_if = "Option::is_none")] + pub default: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub comment: Option, +} diff --git a/src/api2/access/domain.rs b/src/api2/access/domain.rs index fda6baa5..3518e5ca 100644 --- a/src/api2/access/domain.rs +++ b/src/api2/access/domain.rs @@ -1,56 +1,12 @@ //! List Authentication domains/realms use anyhow::{Error}; - -use serde::{Deserialize, Serialize}; use serde_json::{json, Value}; use proxmox_router::{Router, RpcEnvironment, Permission}; use proxmox_schema::api; -use pbs_api_types::{REALM_ID_SCHEMA, SINGLE_LINE_COMMENT_SCHEMA}; - -#[api] -#[derive(Deserialize, Serialize, PartialEq, Eq)] -#[serde(rename_all = "lowercase")] -/// type of the realm -pub enum RealmType { - /// The PAM realm - Pam, - /// The PBS realm - Pbs, - /// An OpenID Connect realm - OpenId, -} - -#[api( - properties: { - realm: { - schema: REALM_ID_SCHEMA, - }, - "type": { - type: RealmType, - }, - comment: { - optional: true, - schema: SINGLE_LINE_COMMENT_SCHEMA, - }, - }, -)] -#[derive(Deserialize, Serialize)] -#[serde(rename_all = "kebab-case")] -/// Basic Information about a realm -pub struct BasicRealmInfo { - pub realm: String, - #[serde(rename = "type")] - pub ty: RealmType, - /// True if it is the default realm - #[serde(skip_serializing_if = "Option::is_none")] - pub default: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub comment: Option, -} - +use pbs_api_types::BasicRealmInfo; #[api( returns: {