use ApiType trait

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller
2021-08-25 09:37:54 +02:00
parent a8a20e9210
commit a37c8d2431
12 changed files with 33 additions and 15 deletions

View File

@ -6,7 +6,7 @@ use ::serde::{Deserialize, Serialize};
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;

View File

@ -1,7 +1,7 @@
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,

View File

@ -35,8 +35,8 @@ pub enum MediaLocation {
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()?;

View File

@ -4,6 +4,7 @@ use serde_json::{json, Value};
use proxmox::{
api::{
schema::{
ApiType,
Schema,
ObjectSchemaType,
ApiStringFormat,

View File

@ -16,6 +16,7 @@ use proxmox::api::{
default_table_format_options,
},
router::ReturnType,
schema::ApiType,
};
use pbs_client::tools::key_source::get_encryption_key_password;

View File

@ -10,6 +10,7 @@ use proxmox::api::cli::{
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};

View File

@ -5,7 +5,7 @@ use serde::{Serialize, Deserialize};
use proxmox::api::{
api,
schema::{Schema, StringSchema, Updater},
schema::{ApiType, Schema, StringSchema, Updater},
section_config::{
SectionConfig,
SectionConfigData,

View File

@ -4,7 +4,7 @@ use anyhow::{bail, Error};
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;

View File

@ -4,7 +4,7 @@ use serde_json::json;
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;

View File

@ -152,6 +152,8 @@ fn object_to_writer(output: &mut dyn Write, object: &Object) -> Result<(), Error
#[test]
fn test() {
use proxmox::api::schema::ApiType;
// let's just reuse some schema we actually have available:
use crate::config::node::NodeConfig;