feat: add script + parameter
This commit is contained in:
parent
fb58f88f5e
commit
d4341b3b40
@ -1,3 +1,5 @@
|
|||||||
|
mod script;
|
||||||
|
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
|
1
src/script.rs
Normal file
1
src/script.rs
Normal file
@ -0,0 +1 @@
|
|||||||
|
mod parameter;
|
38
src/script/parameter.rs
Normal file
38
src/script/parameter.rs
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use validation::Validation;
|
||||||
|
|
||||||
|
mod validation;
|
||||||
|
|
||||||
|
#[derive(Deserialize, Serialize)]
|
||||||
|
pub struct Parameter {
|
||||||
|
name: Arc<str>,
|
||||||
|
data_type: DataType,
|
||||||
|
is_array: bool,
|
||||||
|
aliases: Vec<Arc<str>>,
|
||||||
|
description: Option<Arc<str>>,
|
||||||
|
help_message: Option<Arc<str>>,
|
||||||
|
parameter_sets: Vec<ParameterSet>,
|
||||||
|
validations: Vec<Validation>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize, Serialize)]
|
||||||
|
pub struct ParameterSet {
|
||||||
|
name: Arc<str>,
|
||||||
|
mandatory: bool,
|
||||||
|
position: Option<u8>,
|
||||||
|
value_from_pipeline: Option<bool>,
|
||||||
|
value_from_pipeline_by_property_name: Option<bool>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize, Serialize)]
|
||||||
|
pub enum DataType {
|
||||||
|
String,
|
||||||
|
Int32,
|
||||||
|
Int64,
|
||||||
|
Switch,
|
||||||
|
Bool,
|
||||||
|
Credential,
|
||||||
|
SecureString,
|
||||||
|
}
|
18
src/script/parameter/validation.rs
Normal file
18
src/script/parameter/validation.rs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[derive(Deserialize, Serialize)]
|
||||||
|
#[serde(tag = "type")]
|
||||||
|
pub enum Validation {
|
||||||
|
#[serde(rename = "ValidateNotNullOrEmpty")]
|
||||||
|
NotNullOrEmpty,
|
||||||
|
#[serde(rename = "ValidateRange")]
|
||||||
|
Range { min: i32, max: i32 },
|
||||||
|
#[serde(rename = "ValidateScript")]
|
||||||
|
Script { value: Arc<str> },
|
||||||
|
#[serde(rename = "ValidatePattern")]
|
||||||
|
Pattern { value: Arc<str> },
|
||||||
|
#[serde(rename = "ValidateSet")]
|
||||||
|
Set { values: Vec<Arc<str>> },
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user