/*
 * Orvanta API
 *
 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
 *
 * The version of the OpenAPI document: 1.2.0
 * Contact: contact@orvanta.cloud
 * Generated by: https://openapi-generator.tech
 */

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

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct QueuedJob {
    #[serde(rename = "workspace_id", skip_serializing_if = "Option::is_none")]
    pub workspace_id: Option<String>,
    #[serde(rename = "id")]
    pub id: uuid::Uuid,
    #[serde(rename = "parent_job", skip_serializing_if = "Option::is_none")]
    pub parent_job: Option<uuid::Uuid>,
    #[serde(rename = "created_by", skip_serializing_if = "Option::is_none")]
    pub created_by: Option<String>,
    #[serde(rename = "created_at", skip_serializing_if = "Option::is_none")]
    pub created_at: Option<String>,
    #[serde(rename = "started_at", skip_serializing_if = "Option::is_none")]
    pub started_at: Option<String>,
    #[serde(rename = "scheduled_for", skip_serializing_if = "Option::is_none")]
    pub scheduled_for: Option<String>,
    #[serde(rename = "running")]
    pub running: bool,
    #[serde(rename = "script_path", skip_serializing_if = "Option::is_none")]
    pub script_path: Option<String>,
    #[serde(rename = "script_hash", skip_serializing_if = "Option::is_none")]
    pub script_hash: Option<String>,
    /// The arguments to pass to the script or flow
    #[serde(rename = "args", skip_serializing_if = "Option::is_none")]
    pub args: Option<std::collections::HashMap<String, serde_json::Value>>,
    #[serde(rename = "logs", skip_serializing_if = "Option::is_none")]
    pub logs: Option<String>,
    #[serde(rename = "raw_code", skip_serializing_if = "Option::is_none")]
    pub raw_code: Option<String>,
    #[serde(rename = "canceled")]
    pub canceled: bool,
    #[serde(rename = "canceled_by", skip_serializing_if = "Option::is_none")]
    pub canceled_by: Option<String>,
    #[serde(rename = "canceled_reason", skip_serializing_if = "Option::is_none")]
    pub canceled_reason: Option<String>,
    #[serde(rename = "last_ping", skip_serializing_if = "Option::is_none")]
    pub last_ping: Option<String>,
    #[serde(rename = "job_kind")]
    pub job_kind: JobKind,
    #[serde(rename = "schedule_path", skip_serializing_if = "Option::is_none")]
    pub schedule_path: Option<String>,
    /// The user (u/userfoo) or group (g/groupfoo) whom the execution of this script will be permissioned_as and by extension its DT_TOKEN. 
    #[serde(rename = "permissioned_as")]
    pub permissioned_as: String,
    #[serde(rename = "flow_status", skip_serializing_if = "Option::is_none")]
    pub flow_status: Option<Box<models::FlowStatus>>,
    #[serde(rename = "workflow_as_code_status", skip_serializing_if = "Option::is_none")]
    pub workflow_as_code_status: Option<Box<models::WorkflowStatus>>,
    #[serde(rename = "raw_flow", skip_serializing_if = "Option::is_none")]
    pub raw_flow: Option<Box<models::FlowValue>>,
    #[serde(rename = "is_flow_step")]
    pub is_flow_step: bool,
    #[serde(rename = "language", skip_serializing_if = "Option::is_none")]
    pub language: Option<models::ScriptLang>,
    #[serde(rename = "email")]
    pub email: String,
    #[serde(rename = "visible_to_owner")]
    pub visible_to_owner: bool,
    #[serde(rename = "mem_peak", skip_serializing_if = "Option::is_none")]
    pub mem_peak: Option<i32>,
    #[serde(rename = "tag")]
    pub tag: String,
    #[serde(rename = "priority", skip_serializing_if = "Option::is_none")]
    pub priority: Option<i32>,
    #[serde(rename = "self_wait_time_ms", skip_serializing_if = "Option::is_none")]
    pub self_wait_time_ms: Option<f64>,
    #[serde(rename = "aggregate_wait_time_ms", skip_serializing_if = "Option::is_none")]
    pub aggregate_wait_time_ms: Option<f64>,
    #[serde(rename = "suspend", skip_serializing_if = "Option::is_none")]
    pub suspend: Option<f64>,
    #[serde(rename = "preprocessed", skip_serializing_if = "Option::is_none")]
    pub preprocessed: Option<bool>,
    #[serde(rename = "worker", skip_serializing_if = "Option::is_none")]
    pub worker: Option<String>,
}

impl QueuedJob {
    pub fn new(id: uuid::Uuid, running: bool, canceled: bool, job_kind: JobKind, permissioned_as: String, is_flow_step: bool, email: String, visible_to_owner: bool, tag: String) -> QueuedJob {
        QueuedJob {
            workspace_id: None,
            id,
            parent_job: None,
            created_by: None,
            created_at: None,
            started_at: None,
            scheduled_for: None,
            running,
            script_path: None,
            script_hash: None,
            args: None,
            logs: None,
            raw_code: None,
            canceled,
            canceled_by: None,
            canceled_reason: None,
            last_ping: None,
            job_kind,
            schedule_path: None,
            permissioned_as,
            flow_status: None,
            workflow_as_code_status: None,
            raw_flow: None,
            is_flow_step,
            language: None,
            email,
            visible_to_owner,
            mem_peak: None,
            tag,
            priority: None,
            self_wait_time_ms: None,
            aggregate_wait_time_ms: None,
            suspend: None,
            preprocessed: None,
            worker: None,
        }
    }
}
/// 
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum JobKind {
    #[serde(rename = "script")]
    Script,
    #[serde(rename = "preview")]
    Preview,
    #[serde(rename = "dependencies")]
    Dependencies,
    #[serde(rename = "flowdependencies")]
    Flowdependencies,
    #[serde(rename = "appdependencies")]
    Appdependencies,
    #[serde(rename = "flow")]
    Flow,
    #[serde(rename = "flowpreview")]
    Flowpreview,
    #[serde(rename = "script_hub")]
    ScriptHub,
    #[serde(rename = "identity")]
    Identity,
    #[serde(rename = "deploymentcallback")]
    Deploymentcallback,
    #[serde(rename = "singlestepflow")]
    Singlestepflow,
    #[serde(rename = "flowscript")]
    Flowscript,
    #[serde(rename = "flownode")]
    Flownode,
    #[serde(rename = "appscript")]
    Appscript,
    #[serde(rename = "aiagent")]
    Aiagent,
    #[serde(rename = "unassigned_script")]
    UnassignedScript,
    #[serde(rename = "unassigned_flow")]
    UnassignedFlow,
    #[serde(rename = "unassigned_singlestepflow")]
    UnassignedSinglestepflow,
}

impl Default for JobKind {
    fn default() -> JobKind {
        Self::Script
    }
}

