Skip to content

Commit

Permalink
feat: add initial Workflow object model
Browse files Browse the repository at this point in the history
  • Loading branch information
onnovalkering committed Mar 18, 2020
1 parent e0d75f4 commit e9e5095
Showing 1 changed file with 163 additions and 1 deletion.
164 changes: 163 additions & 1 deletion src/v11_wf.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,172 @@
use serde::{Deserialize, Serialize};
use serde_with::skip_serializing_none;
use serde_yaml::Value as YValue;

type Map<T> = std::collections::HashMap<String, T>;

#[skip_serializing_none]
#[serde(rename_all = "camelCase")]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Workflow {
cwl_version: String,
class: String,

cwl_version: String,

doc: Option<WorkflowDoc>,

hints: Option<YValue>,

id: Option<String>,

inputs: WorkflowInputs,

label: Option<String>,

outputs: WorkflowOutputs,

steps: WorkflowSteps,

requirements: Option<YValue>,
}

#[serde(untagged, rename_all = "camelCase")]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub enum WorkflowDoc {
Doc(String),
Array(Vec<String>),
}

#[serde(untagged, rename_all = "camelCase")]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub enum WorkflowInputs {
Array(Vec<WorkflowInputParameter>),
Map(Map<WorkflowInputParameter>),
Types(Map<String>)
}

#[skip_serializing_none]
#[serde(rename_all = "camelCase")]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct WorkflowInputParameter {
#[serde(rename = "type")]
param_type: YValue,

label: Option<String>,

secondary_files: WorkflowSecondaryFiles,

streamable: Option<bool>,

default: Option<YValue>,

doc: Option<WorkflowDoc>,

id: Option<String>,

input_binding: Option<WorkflowInputBinding>,

format: Option<WorkflowParameterFormat>,

load_contents: Option<bool>,

load_listing: Option<String>,
}

#[serde(untagged, rename_all = "camelCase")]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub enum WorkflowOutputs {
Array(Vec<WorkflowOutputParameter>),
Map(Map<WorkflowOutputParameter>),
Types(Map<YValue>)
}

#[skip_serializing_none]
#[serde(rename_all = "camelCase")]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct WorkflowOutputParameter {
#[serde(rename = "type")]
param_type: YValue,

label: Option<String>,

secondary_files: WorkflowSecondaryFiles,

streamable: Option<bool>,

default: Option<YValue>,

doc: Option<WorkflowDoc>,

id: Option<String>,

format: Option<WorkflowParameterFormat>,

output_source: Option<WorkflowOutputSource>,

link_merge: Option<String>,
}

#[serde(untagged, rename_all = "camelCase")]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub enum WorkflowSteps {
Array(Vec<WorkflowStep>),
Map(Map<WorkflowStep>),
}

#[skip_serializing_none]
#[serde(rename_all = "camelCase")]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct WorkflowStep {

}

#[serde(untagged, rename_all = "camelCase")]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub enum WorkflowSecondaryFiles {
SecondaryFile(SecondaryFileSchema),
Array(Vec<SecondaryFileSchema>),
}

#[skip_serializing_none]
#[serde(rename_all = "camelCase")]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct SecondaryFileSchema {
pub pattern: SecondaryFileSchemaPattern,
pub required: Option<SecondaryFileSchemaRequired>
}

#[serde(untagged, rename_all = "camelCase")]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub enum SecondaryFileSchemaPattern {
Pattern(String),
Expression(YValue)
}

#[serde(untagged, rename_all = "camelCase")]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub enum SecondaryFileSchemaRequired {
Required(bool),
Expression(YValue)
}

#[serde(untagged, rename_all = "camelCase")]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub enum WorkflowParameterFormat {
Format(String),
Array(Vec<String>),
Expression(YValue),
}

#[skip_serializing_none]
#[serde(rename_all = "camelCase")]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct WorkflowInputBinding {
pub load_contents: Option<bool>
}

#[serde(untagged, rename_all = "camelCase")]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub enum WorkflowOutputSource {
OutputSource(String),
Array(Vec<String>)
}

0 comments on commit e9e5095

Please sign in to comment.