]> git.proxmox.com Git - proxmox-backup.git/commitdiff
src/api2/types.rs: define REMOTE_ID_SCHEMA here
authorDietmar Maurer <dietmar@proxmox.com>
Mon, 13 Jan 2020 10:47:07 +0000 (11:47 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Mon, 13 Jan 2020 10:47:07 +0000 (11:47 +0100)
src/api2/config/remotes.rs
src/api2/types.rs
src/bin/proxmox-backup-manager.rs
src/config/remotes.rs

index 38e448ab7e97a36172c38a0f321f1aa692842217..d0f185f5a7ee0a9d43e82001539b4ff725d65b82 100644 (file)
@@ -3,6 +3,7 @@ use serde_json::Value;
 
 use proxmox::api::{api, ApiMethod, Router, RpcEnvironment};
 
+use crate::api2::types::*;
 use crate::config::remotes;
 
 #[api(
@@ -34,7 +35,7 @@ pub fn list_remotes(
     input: {
         properties: {
             name: {
-                schema: remotes::REMOTE_ID_SCHEMA,
+                schema: REMOTE_ID_SCHEMA,
             },
             comment: {
                 optional: true,
@@ -77,7 +78,7 @@ pub fn create_remote(name: String, param: Value) -> Result<(), Error> {
     input: {
         properties: {
             name: {
-                schema: remotes::REMOTE_ID_SCHEMA,
+                schema: REMOTE_ID_SCHEMA,
             },
         },
     },
index e89e951f68ad6a90850ecb02786b22a6f51b380d..3a3365e77315476cc0db86eafd02f073c1709754 100644 (file)
@@ -117,6 +117,12 @@ pub const DATASTORE_SCHEMA: Schema = StringSchema::new("Datastore name.")
     .max_length(32)
     .schema();
 
+pub const REMOTE_ID_SCHEMA: Schema = StringSchema::new("Remote ID.")
+    .format(&PROXMOX_SAFE_ID_FORMAT)
+    .min_length(3)
+    .max_length(32)
+    .schema();
+
 
 
 // Complex type definitions
index 6eeb30d5c37856e0ea02c289e2920b4a51a3b47d..d68d2df74ec084c1fe8e190e12906c4d69b267c2 100644 (file)
@@ -382,7 +382,7 @@ fn cert_mgmt_cli() -> CommandLineInterface {
                 schema: DATASTORE_SCHEMA,
             },
             remote: {
-                schema: crate::config::remotes::REMOTE_ID_SCHEMA,
+                schema: REMOTE_ID_SCHEMA,
             },
             "remote-store": {
                 schema: DATASTORE_SCHEMA,
index b1180993f1790314ea09fc80153167421419fb70..30ff257a67e4769dca0ccc522577732ebb6b9fa4 100644 (file)
@@ -7,6 +7,7 @@ use proxmox::api::{api, schema::*};
 
 use proxmox::tools::{fs::replace_file, fs::CreateOptions};
 
+use crate::api2::types::*;
 use crate::section_config::{SectionConfig, SectionConfigData, SectionConfigPlugin};
 
 lazy_static! {
@@ -15,10 +16,6 @@ lazy_static! {
 
 // fixme: define better schemas
 
-pub const REMOTE_ID_SCHEMA: Schema = StringSchema::new("Remote ID.")
-    .min_length(3)
-    .schema();
-
 pub const COMMENT_SCHEMA: Schema = StringSchema::new("Comment").schema();
 pub const REMOTE_HOST_SCHEMA: Schema = StringSchema::new("Host IP address or DNS name.").schema();
 pub const REMOTE_USERID_SCHEMA: Schema = StringSchema::new("User ID").schema();