/*
 * Tapis Workflows API
 *
 * Create and manage pipelines
 *
 * The version of the OpenAPI document: 1.6.0
 * Contact: cicsupport@tacc.utexas.edu
 * Generated by: https://openapi-generator.tech
 */

use crate::models;
use serde::{Deserialize, Serialize};

use serde_with::serde_as;

#[serde_as]
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct ReqFunctionTask {
    #[serde(rename = "id")]
    pub id: String,
    #[serde(rename = "type")]
    pub r#type: models::EnumTaskType,
    #[serde(rename = "depends_on", skip_serializing_if = "Option::is_none")]
    pub depends_on: Option<Vec<models::TaskDependency>>,
    #[serde(rename = "description", skip_serializing_if = "Option::is_none")]
    pub description: Option<String>,
    #[serde(rename = "execution_profile", skip_serializing_if = "Option::is_none")]
    pub execution_profile: Option<Box<models::TaskExecutionProfile>>,
    #[serde(rename = "input", skip_serializing_if = "Option::is_none")]
    pub input: Option<std::collections::HashMap<String, models::SpecWithValue>>,
    #[serde(rename = "output", skip_serializing_if = "Option::is_none")]
    pub output: Option<std::collections::HashMap<String, models::OutputValue>>,
    #[serde(rename = "conditions", skip_serializing_if = "Option::is_none")]
    pub conditions: Option<Vec<std::collections::HashMap<String, serde_json::Value>>>,
    #[serde(rename = "git_repositories", skip_serializing_if = "Option::is_none")]
    pub git_repositories: Option<Vec<models::GitCloneDetails>>,
    #[serde(rename = "runtime")]
    pub runtime: models::EnumRuntimeEnvironment,
    #[serde(rename = "installer")]
    pub installer: models::EnumInstaller,
    #[serde(rename = "command", skip_serializing_if = "Option::is_none")]
    pub command: Option<String>,
    #[serde(rename = "entrypoint", skip_serializing_if = "Option::is_none")]
    pub entrypoint: Option<String>,
    #[serde_as(as = "Option<serde_with::base64::Base64>")]
    #[serde(rename = "code", skip_serializing_if = "Option::is_none")]
    pub code: Option<Vec<u8>>,
    #[serde(rename = "packages", skip_serializing_if = "Option::is_none")]
    pub packages: Option<Vec<String>>,
}

impl ReqFunctionTask {
    pub fn new(
        id: String,
        r#type: models::EnumTaskType,
        runtime: models::EnumRuntimeEnvironment,
        installer: models::EnumInstaller,
    ) -> ReqFunctionTask {
        ReqFunctionTask {
            id,
            r#type,
            depends_on: None,
            description: None,
            execution_profile: None,
            input: None,
            output: None,
            conditions: None,
            git_repositories: None,
            runtime,
            installer,
            command: None,
            entrypoint: None,
            code: None,
            packages: None,
        }
    }
}
