-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add initial Workflow object model
- Loading branch information
1 parent
e0d75f4
commit e9e5095
Showing
1 changed file
with
163 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>) | ||
} |