mirror of
https://git.proxmox.com/git/proxmox
synced 2025-05-23 15:49:54 +00:00
use ApiType trait
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
d0103000b8
commit
35e7f2f48e
@ -2,7 +2,7 @@ use std::sync::atomic::{AtomicUsize, Ordering};
|
|||||||
|
|
||||||
use anyhow::{bail, Error};
|
use anyhow::{bail, Error};
|
||||||
|
|
||||||
use proxmox::api::schema::{ApiStringFormat, Schema, StringSchema};
|
use proxmox::api::schema::{ApiStringFormat, ApiType, Schema, StringSchema};
|
||||||
use proxmox::const_regex;
|
use proxmox::const_regex;
|
||||||
use proxmox::sys::linux::procfs;
|
use proxmox::sys::linux::procfs;
|
||||||
|
|
||||||
@ -54,13 +54,15 @@ const_regex! {
|
|||||||
pub const PROXMOX_UPID_FORMAT: ApiStringFormat =
|
pub const PROXMOX_UPID_FORMAT: ApiStringFormat =
|
||||||
ApiStringFormat::Pattern(&PROXMOX_UPID_REGEX);
|
ApiStringFormat::Pattern(&PROXMOX_UPID_REGEX);
|
||||||
|
|
||||||
impl UPID {
|
impl ApiType for UPID {
|
||||||
pub const API_SCHEMA: Schema = StringSchema::new("Unique Process/Task Identifier")
|
const API_SCHEMA: Schema = StringSchema::new("Unique Process/Task Identifier")
|
||||||
.min_length("UPID:N:12345678:12345678:12345678:::".len())
|
.min_length("UPID:N:12345678:12345678:12345678:::".len())
|
||||||
.max_length(128) // arbitrary
|
.max_length(128) // arbitrary
|
||||||
.format(&PROXMOX_UPID_FORMAT)
|
.format(&PROXMOX_UPID_FORMAT)
|
||||||
.schema();
|
.schema();
|
||||||
|
}
|
||||||
|
|
||||||
|
impl UPID {
|
||||||
/// Create a new UPID
|
/// Create a new UPID
|
||||||
pub fn new(
|
pub fn new(
|
||||||
worker_type: &str,
|
worker_type: &str,
|
||||||
|
@ -30,7 +30,7 @@ use lazy_static::lazy_static;
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use proxmox::api::api;
|
use proxmox::api::api;
|
||||||
use proxmox::api::schema::{ApiStringFormat, Schema, StringSchema, Updatable};
|
use proxmox::api::schema::{ApiStringFormat, ApiType, Schema, StringSchema, Updatable};
|
||||||
use proxmox::const_regex;
|
use proxmox::const_regex;
|
||||||
|
|
||||||
// we only allow a limited set of characters
|
// we only allow a limited set of characters
|
||||||
@ -409,13 +409,15 @@ impl Updatable for Userid {
|
|||||||
const UPDATER_IS_OPTION: bool = true;
|
const UPDATER_IS_OPTION: bool = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Userid {
|
impl ApiType for Userid {
|
||||||
pub const API_SCHEMA: Schema = StringSchema::new("User ID")
|
const API_SCHEMA: Schema = StringSchema::new("User ID")
|
||||||
.format(&PROXMOX_USER_ID_FORMAT)
|
.format(&PROXMOX_USER_ID_FORMAT)
|
||||||
.min_length(3)
|
.min_length(3)
|
||||||
.max_length(64)
|
.max_length(64)
|
||||||
.schema();
|
.schema();
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Userid {
|
||||||
const fn new(data: String, name_len: usize) -> Self {
|
const fn new(data: String, name_len: usize) -> Self {
|
||||||
Self { data, name_len }
|
Self { data, name_len }
|
||||||
}
|
}
|
||||||
@ -538,13 +540,22 @@ pub struct Authid {
|
|||||||
tokenname: Option<Tokenname>
|
tokenname: Option<Tokenname>
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Authid {
|
|
||||||
pub const API_SCHEMA: Schema = StringSchema::new("Authentication ID")
|
impl Updatable for Authid {
|
||||||
|
type Updater = Option<Authid>;
|
||||||
|
|
||||||
|
const UPDATER_IS_OPTION: bool = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ApiType for Authid {
|
||||||
|
const API_SCHEMA: Schema = StringSchema::new("Authentication ID")
|
||||||
.format(&PROXMOX_AUTH_ID_FORMAT)
|
.format(&PROXMOX_AUTH_ID_FORMAT)
|
||||||
.min_length(3)
|
.min_length(3)
|
||||||
.max_length(64)
|
.max_length(64)
|
||||||
.schema();
|
.schema();
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Authid {
|
||||||
const fn new(user: Userid, tokenname: Option<Tokenname>) -> Self {
|
const fn new(user: Userid, tokenname: Option<Tokenname>) -> Self {
|
||||||
Self { user, tokenname }
|
Self { user, tokenname }
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user