use anyhow::{bail, Error};
use serde_json::{json, Value};
-use proxmox::{
- api::{
- schema::{
- Schema,
- ObjectSchemaType,
- SchemaPropertyEntry,
- ApiStringFormat,
- },
- router::{
- ApiAccess,
- },
- format::{
- dump_enum_properties,
- dump_section_config,
- get_property_string_type_text,
- },
- ApiMethod,
- ApiHandler,
- Router,
- SubRoute,
- Permission,
- },
-};
-
-use proxmox_backup::{
- api2,
- config::{
- self,
- acl::PRIVILEGES,
- },
-};
+use proxmox_router::{ApiAccess, ApiHandler, ApiMethod, Permission, Router, SubRoute};
+use proxmox_schema::format::{dump_enum_properties, get_property_string_type_text};
+use proxmox_schema::{ApiStringFormat, ApiType, ObjectSchemaType, Schema};
+use proxmox_section_config::dump_section_config;
+
+use pbs_api_types::PRIVILEGES;
+
+use proxmox_backup::api2;
fn get_args() -> (String, Vec<String>) {
let (_prefix, args) = get_args();
- if args.len() < 1 {
+ if args.is_empty() {
bail!("missing arguments");
}
for arg in args.iter() {
let text = match arg.as_ref() {
"apidata.js" => generate_api_tree(),
- "datastore.cfg" => dump_section_config(&config::datastore::CONFIG),
- "tape.cfg" => dump_section_config(&config::drive::CONFIG),
- "tape-job.cfg" => dump_section_config(&config::tape_job::CONFIG),
- "user.cfg" => dump_section_config(&config::user::CONFIG),
- "remote.cfg" => dump_section_config(&config::remote::CONFIG),
- "sync.cfg" => dump_section_config(&config::sync::CONFIG),
- "verification.cfg" => dump_section_config(&config::verify::CONFIG),
- "media-pool.cfg" => dump_section_config(&config::media_pool::CONFIG),
- "config::acl::Role" => dump_enum_properties(&config::acl::Role::API_SCHEMA)?,
+ "datastore.cfg" => dump_section_config(&pbs_config::datastore::CONFIG),
+ "tape.cfg" => dump_section_config(&pbs_config::drive::CONFIG),
+ "tape-job.cfg" => dump_section_config(&pbs_config::tape_job::CONFIG),
+ "user.cfg" => dump_section_config(&pbs_config::user::CONFIG),
+ "remote.cfg" => dump_section_config(&pbs_config::remote::CONFIG),
+ "sync.cfg" => dump_section_config(&pbs_config::sync::CONFIG),
+ "verification.cfg" => dump_section_config(&pbs_config::verify::CONFIG),
+ "media-pool.cfg" => dump_section_config(&pbs_config::media_pool::CONFIG),
+ "config::acl::Role" => dump_enum_properties(&pbs_api_types::Role::API_SCHEMA)?,
_ => bail!("docgen: got unknown type"),
};
println!("{}", text);
data["text"] = "Restore API (HTTP/2)".into();
tree.push(data);
- format!("var pbsapi = {};", serde_json::to_string_pretty(&tree).unwrap())
+ format!("var apiSchema = {};", serde_json::to_string_pretty(&tree).unwrap())
}
pub fn dump_schema(schema: &Schema) -> Value {
data
}
-pub fn dump_property_schema<I>(
- param: &dyn ObjectSchemaType<PropertyIter = I>,
-) -> Value
- where I: Iterator<Item = &'static SchemaPropertyEntry>,
-{
+pub fn dump_property_schema(param: &dyn ObjectSchemaType) -> Value {
let mut properties = json!({});
for (prop, optional, schema) in param.properties() {
data["parameters"] = dump_property_schema(&api_method.parameters);
- let mut returns = dump_schema(&api_method.returns.schema);
+ let mut returns = dump_schema(api_method.returns.schema);
if api_method.returns.optional {
returns["optional"] = 1.into();
}