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::sys::linux::procfs;
pub const PROXMOX_UPID_FORMAT: ApiStringFormat =
ApiStringFormat::Pattern(&PROXMOX_UPID_REGEX);
-impl UPID {
- pub const API_SCHEMA: Schema = StringSchema::new("Unique Process/Task Identifier")
+impl ApiType for UPID {
+ const API_SCHEMA: Schema = StringSchema::new("Unique Process/Task Identifier")
.min_length("UPID:N:12345678:12345678:12345678:::".len())
.max_length(128) // arbitrary
.format(&PROXMOX_UPID_FORMAT)
.schema();
+}
+impl UPID {
/// Create a new UPID
pub fn new(
worker_type: &str,
use serde::{Deserialize, Serialize};
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;
// we only allow a limited set of characters
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 }
}
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)
.min_length(3)
.max_length(64)
.schema();
+}
+impl Authid {
const fn new(user: Userid, tokenname: Option<Tokenname>) -> Self {
Self { user, tokenname }
}
use proxmox::api::{api, Router, RpcEnvironment, Permission};
use proxmox::api::section_config::SectionConfigData;
-use proxmox::api::schema::parse_property_string;
+use proxmox::api::schema::{ApiType, parse_property_string};
use pbs_datastore::task::TaskState;
use crate::api2::config::sync::delete_sync_job;
use serde::{Deserialize, Serialize};
use serde_json::Value;
-use proxmox::api::{api, schema::{Schema, StringSchema, ApiStringFormat}};
+use proxmox::api::{api, schema::{ApiType, Schema, StringSchema, ApiStringFormat}};
use crate::api2::types::{
DNS_ALIAS_FORMAT, DNS_NAME_FORMAT, PROXMOX_SAFE_ID_FORMAT,
proxmox::forward_deserialize_to_from_str!(MediaLocation);
proxmox::forward_serialize_to_display!(MediaLocation);
-impl MediaLocation {
- pub const API_SCHEMA: Schema = StringSchema::new(
+impl proxmox::api::schema::ApiType for MediaLocation {
+ const API_SCHEMA: Schema = StringSchema::new(
"Media location (e.g. 'offline', 'online-<changer_name>', 'vault-<vault_name>')")
.format(&ApiStringFormat::VerifyFn(|text| {
let location: MediaLocation = text.parse()?;
use proxmox::{
api::{
schema::{
+ ApiType,
Schema,
ObjectSchemaType,
ApiStringFormat,
default_table_format_options,
},
router::ReturnType,
+ schema::ApiType,
};
use pbs_client::tools::key_source::get_encryption_key_password;
OUTPUT_FORMAT,
};
use proxmox::api::router::ReturnType;
+use proxmox::api::schema::ApiType;
use proxmox::sys::linux::tty;
use proxmox::tools::fs::{file_get_contents, replace_file, CreateOptions};
use proxmox::api::{
api,
- schema::{Schema, StringSchema, Updater},
+ schema::{ApiType, Schema, StringSchema, Updater},
section_config::{
SectionConfig,
SectionConfigData,
use serde::{Deserialize, Serialize};
use proxmox::api::api;
-use proxmox::api::schema::{ApiStringFormat, Updater};
+use proxmox::api::schema::{ApiStringFormat, ApiType, Updater};
use proxmox_http::ProxyConfig;
use handlebars::{Handlebars, Helper, Context, RenderError, RenderContext, Output, HelperResult, TemplateError};
use proxmox::tools::email::sendmail;
-use proxmox::api::schema::parse_property_string;
+use proxmox::api::schema::{ApiType, parse_property_string};
use proxmox::try_block;
use pbs_tools::format::HumanByte;
#[test]
fn test() {
+ use proxmox::api::schema::ApiType;
+
// let's just reuse some schema we actually have available:
use crate::config::node::NodeConfig;