use lazy_static::lazy_static;
use serde::{Deserialize, Serialize};
-use proxmox::api::api;
-use proxmox::api::schema::{ApiStringFormat, Schema, StringSchema, Updatable};
-use proxmox::const_regex;
+use proxmox_schema::{
+ api, const_regex, ApiStringFormat, ApiType, Schema, StringSchema, UpdaterType,
+};
// we only allow a limited set of characters
// colon is not allowed, because we store usernames in
}
/// A complete user id consisting of a user name and a realm
-#[derive(Clone, Debug, PartialEq, Eq, Hash)]
+#[derive(Clone, Debug, PartialEq, Eq, Hash, UpdaterType)]
pub struct Userid {
data: String,
name_len: usize,
}
-impl Updatable for Userid {
- type Updater = Option<Userid>;
-
- const UPDATER_IS_OPTION: bool = true;
-}
-
-impl Userid {
- pub const API_SCHEMA: Schema = StringSchema::new("User ID")
+impl ApiType for Userid {
+ const API_SCHEMA: Schema = StringSchema::new("User ID")
.format(&PROXMOX_USER_ID_FORMAT)
.min_length(3)
.max_length(64)
.schema();
+}
+impl Userid {
const fn new(data: String, name_len: usize) -> Self {
Self { data, name_len }
}
}
/// A complete authentication id consisting of a user id and an optional token name.
-#[derive(Clone, Debug, Eq, PartialEq, Hash)]
+#[derive(Clone, Debug, Eq, PartialEq, Hash, UpdaterType)]
pub struct Authid {
user: Userid,
tokenname: Option<Tokenname>
}
-impl Authid {
- pub const API_SCHEMA: Schema = StringSchema::new("Authentication ID")
+impl ApiType for Authid {
+ const API_SCHEMA: Schema = StringSchema::new("Authentication ID")
.format(&PROXMOX_AUTH_ID_FORMAT)
.min_length(3)
.max_length(64)
.schema();
+}
+impl Authid {
const fn new(user: Userid, tokenname: Option<Tokenname>) -> Self {
Self { user, tokenname }
}