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

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

/// ExportableCompletedJob : Completed job with full data for export/import operations
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct ExportableCompletedJob {
    #[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")]
    pub created_by: String,
    #[serde(rename = "created_at")]
    pub created_at: String,
    #[serde(rename = "started_at", skip_serializing_if = "Option::is_none")]
    pub started_at: Option<String>,
    #[serde(rename = "completed_at", skip_serializing_if = "Option::is_none")]
    pub completed_at: Option<String>,
    #[serde(rename = "duration_ms", skip_serializing_if = "Option::is_none")]
    pub duration_ms: Option<i32>,
    #[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>,
    /// Full job arguments without size restrictions
    #[serde(rename = "args", skip_serializing_if = "Option::is_none")]
    pub args: Option<serde_json::Value>,
    /// Full job result without size restrictions
    #[serde(rename = "result", skip_serializing_if = "Option::is_none")]
    pub result: Option<serde_json::Value>,
    /// Complete job logs from v2_job table
    #[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 = "raw_lock", skip_serializing_if = "Option::is_none")]
    pub raw_lock: Option<String>,
    #[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 = "job_kind")]
    pub job_kind: JobKind,
    /// Trigger path for the job (replaces schedule_path)
    #[serde(rename = "trigger", skip_serializing_if = "Option::is_none")]
    pub trigger: Option<String>,
    #[serde(rename = "trigger_kind", skip_serializing_if = "Option::is_none")]
    pub trigger_kind: Option<TriggerKind>,
    #[serde(rename = "permissioned_as")]
    pub permissioned_as: String,
    #[serde(rename = "permissioned_as_email", skip_serializing_if = "Option::is_none")]
    pub permissioned_as_email: Option<String>,
    /// Flow status from v2_job_status table
    #[serde(rename = "flow_status", skip_serializing_if = "Option::is_none")]
    pub flow_status: Option<serde_json::Value>,
    #[serde(rename = "workflow_as_code_status", skip_serializing_if = "Option::is_none")]
    pub workflow_as_code_status: Option<serde_json::Value>,
    #[serde(rename = "raw_flow", skip_serializing_if = "Option::is_none")]
    pub raw_flow: Option<serde_json::Value>,
    #[serde(rename = "is_flow_step", skip_serializing_if = "Option::is_none")]
    pub is_flow_step: Option<bool>,
    #[serde(rename = "language", skip_serializing_if = "Option::is_none")]
    pub language: Option<models::ScriptLang>,
    #[serde(rename = "is_skipped", skip_serializing_if = "Option::is_none")]
    pub is_skipped: Option<bool>,
    #[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", skip_serializing_if = "Option::is_none")]
    pub tag: Option<String>,
    #[serde(rename = "priority", skip_serializing_if = "Option::is_none")]
    pub priority: Option<i32>,
    #[serde(rename = "labels", skip_serializing_if = "Option::is_none")]
    pub labels: Option<Vec<String>>,
    #[serde(rename = "same_worker", skip_serializing_if = "Option::is_none")]
    pub same_worker: Option<bool>,
    #[serde(rename = "flow_step_id", skip_serializing_if = "Option::is_none")]
    pub flow_step_id: Option<String>,
    #[serde(rename = "flow_innermost_root_job", skip_serializing_if = "Option::is_none")]
    pub flow_innermost_root_job: Option<uuid::Uuid>,
    #[serde(rename = "concurrent_limit", skip_serializing_if = "Option::is_none")]
    pub concurrent_limit: Option<i32>,
    #[serde(rename = "concurrency_time_window_s", skip_serializing_if = "Option::is_none")]
    pub concurrency_time_window_s: Option<i32>,
    #[serde(rename = "timeout", skip_serializing_if = "Option::is_none")]
    pub timeout: Option<i32>,
    #[serde(rename = "cache_ttl", skip_serializing_if = "Option::is_none")]
    pub cache_ttl: Option<i32>,
    #[serde(rename = "self_wait_time_ms", skip_serializing_if = "Option::is_none")]
    pub self_wait_time_ms: Option<i32>,
    #[serde(rename = "aggregate_wait_time_ms", skip_serializing_if = "Option::is_none")]
    pub aggregate_wait_time_ms: Option<i32>,
    #[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>,
    /// Actual job status from database
    #[serde(rename = "status", skip_serializing_if = "Option::is_none")]
    pub status: Option<String>,
}

impl ExportableCompletedJob {
    /// Completed job with full data for export/import operations
    pub fn new(id: uuid::Uuid, created_by: String, created_at: String, job_kind: JobKind, permissioned_as: String, email: String, visible_to_owner: bool) -> ExportableCompletedJob {
        ExportableCompletedJob {
            id,
            parent_job: None,
            created_by,
            created_at,
            started_at: None,
            completed_at: None,
            duration_ms: None,
            script_path: None,
            script_hash: None,
            args: None,
            result: None,
            logs: None,
            raw_code: None,
            raw_lock: None,
            canceled_by: None,
            canceled_reason: None,
            job_kind,
            trigger: None,
            trigger_kind: None,
            permissioned_as,
            permissioned_as_email: None,
            flow_status: None,
            workflow_as_code_status: None,
            raw_flow: None,
            is_flow_step: None,
            language: None,
            is_skipped: None,
            email,
            visible_to_owner,
            mem_peak: None,
            tag: None,
            priority: None,
            labels: None,
            same_worker: None,
            flow_step_id: None,
            flow_innermost_root_job: None,
            concurrent_limit: None,
            concurrency_time_window_s: None,
            timeout: None,
            cache_ttl: None,
            self_wait_time_ms: None,
            aggregate_wait_time_ms: None,
            preprocessed: None,
            worker: None,
            status: 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 = "flow")]
    Flow,
    #[serde(rename = "flowdependencies")]
    Flowdependencies,
    #[serde(rename = "appdependencies")]
    Appdependencies,
    #[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
    }
}
/// 
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum TriggerKind {
    #[serde(rename = "webhook")]
    Webhook,
    #[serde(rename = "http")]
    Http,
    #[serde(rename = "websocket")]
    Websocket,
    #[serde(rename = "kafka")]
    Kafka,
    #[serde(rename = "email")]
    Email,
    #[serde(rename = "nats")]
    Nats,
    #[serde(rename = "schedule")]
    Schedule,
    #[serde(rename = "app")]
    App,
    #[serde(rename = "ui")]
    Ui,
    #[serde(rename = "postgres")]
    Postgres,
    #[serde(rename = "sqs")]
    Sqs,
    #[serde(rename = "gcp")]
    Gcp,
}

impl Default for TriggerKind {
    fn default() -> TriggerKind {
        Self::Webhook
    }
}

