hatchet-sdk 0.2.8

This is an unofficial Rust SDK for Hatchet, a distributed, fault-tolerant task queue.
Documentation
/*
 * Hatchet API
 *
 * The Hatchet API
 *
 * The version of the OpenAPI document: 1.0.0
 *
 * Generated by: https://openapi-generator.tech
 */

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

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct V1TaskGet200Response {
    #[serde(rename = "metadata")]
    pub metadata: Box<models::V1TaskGet200ResponseMetadata>,
    /// The action ID of the task.
    #[serde(rename = "actionId", skip_serializing_if = "Option::is_none")]
    pub action_id: Option<String>,
    /// The number of retries of the task.
    #[serde(rename = "retryCount", skip_serializing_if = "Option::is_none")]
    pub retry_count: Option<i32>,
    /// The attempt number of the task.
    #[serde(rename = "attempt", skip_serializing_if = "Option::is_none")]
    pub attempt: Option<i32>,
    /// Additional metadata for the task run.
    #[serde(rename = "additionalMetadata", skip_serializing_if = "Option::is_none")]
    pub additional_metadata: Option<serde_json::Value>,
    /// The list of children tasks
    #[serde(rename = "children", skip_serializing_if = "Option::is_none")]
    pub children: Option<Vec<models::V1TaskGet200ResponseChildrenInner>>,
    /// The timestamp the task was created.
    #[serde(rename = "createdAt")]
    pub created_at: String,
    /// The display name of the task run.
    #[serde(rename = "displayName")]
    pub display_name: String,
    /// The duration of the task run, in milliseconds.
    #[serde(rename = "duration", skip_serializing_if = "Option::is_none")]
    pub duration: Option<i32>,
    /// The error message of the task run (for the latest run)
    #[serde(rename = "errorMessage", skip_serializing_if = "Option::is_none")]
    pub error_message: Option<String>,
    /// The timestamp the task run finished.
    #[serde(rename = "finishedAt", skip_serializing_if = "Option::is_none")]
    pub finished_at: Option<String>,
    /// The input of the task run.
    #[serde(rename = "input")]
    pub input: serde_json::Value,
    /// The number of spawned children tasks
    #[serde(rename = "numSpawnedChildren")]
    pub num_spawned_children: i32,
    /// The output of the task run (for the latest run)
    #[serde(rename = "output")]
    pub output: serde_json::Value,
    #[serde(rename = "status")]
    pub status: Status,
    /// The timestamp the task run started.
    #[serde(rename = "startedAt", skip_serializing_if = "Option::is_none")]
    pub started_at: Option<String>,
    /// The step ID of the task.
    #[serde(rename = "stepId", skip_serializing_if = "Option::is_none")]
    pub step_id: Option<uuid::Uuid>,
    /// The external ID of the task.
    #[serde(rename = "taskExternalId")]
    pub task_external_id: uuid::Uuid,
    /// The ID of the task.
    #[serde(rename = "taskId")]
    pub task_id: i32,
    /// The timestamp the task was inserted.
    #[serde(rename = "taskInsertedAt")]
    pub task_inserted_at: String,
    /// The ID of the tenant.
    #[serde(rename = "tenantId")]
    pub tenant_id: uuid::Uuid,
    /// The type of the workflow (whether it's a DAG or a task)
    #[serde(rename = "type")]
    pub r#type: Type,
    #[serde(rename = "workflowId")]
    pub workflow_id: uuid::Uuid,
    #[serde(rename = "workflowName", skip_serializing_if = "Option::is_none")]
    pub workflow_name: Option<String>,
    /// The external ID of the workflow run
    #[serde(rename = "workflowRunExternalId")]
    pub workflow_run_external_id: uuid::Uuid,
    /// The version ID of the workflow
    #[serde(rename = "workflowVersionId", skip_serializing_if = "Option::is_none")]
    pub workflow_version_id: Option<uuid::Uuid>,
    #[serde(rename = "workflowConfig", skip_serializing_if = "Option::is_none")]
    pub workflow_config: Option<serde_json::Value>,
    /// The external ID of the parent task.
    #[serde(
        rename = "parentTaskExternalId",
        skip_serializing_if = "Option::is_none"
    )]
    pub parent_task_external_id: Option<uuid::Uuid>,
}

impl V1TaskGet200Response {
    pub fn new(
        metadata: models::V1TaskGet200ResponseMetadata,
        created_at: String,
        display_name: String,
        input: serde_json::Value,
        num_spawned_children: i32,
        output: serde_json::Value,
        status: Status,
        task_external_id: uuid::Uuid,
        task_id: i32,
        task_inserted_at: String,
        tenant_id: uuid::Uuid,
        r#type: Type,
        workflow_id: uuid::Uuid,
        workflow_run_external_id: uuid::Uuid,
    ) -> V1TaskGet200Response {
        V1TaskGet200Response {
            metadata: Box::new(metadata),
            action_id: None,
            retry_count: None,
            attempt: None,
            additional_metadata: None,
            children: None,
            created_at,
            display_name,
            duration: None,
            error_message: None,
            finished_at: None,
            input,
            num_spawned_children,
            output,
            status,
            started_at: None,
            step_id: None,
            task_external_id,
            task_id,
            task_inserted_at,
            tenant_id,
            r#type,
            workflow_id,
            workflow_name: None,
            workflow_run_external_id,
            workflow_version_id: None,
            workflow_config: None,
            parent_task_external_id: None,
        }
    }
}
///
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Status {
    #[serde(rename = "QUEUED")]
    Queued,
    #[serde(rename = "RUNNING")]
    Running,
    #[serde(rename = "COMPLETED")]
    Completed,
    #[serde(rename = "CANCELLED")]
    Cancelled,
    #[serde(rename = "FAILED")]
    Failed,
}

impl Default for Status {
    fn default() -> Status {
        Self::Queued
    }
}
/// The type of the workflow (whether it's a DAG or a task)
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
    #[serde(rename = "DAG")]
    Dag,
    #[serde(rename = "TASK")]
    Task,
}

impl Default for Type {
    fn default() -> Type {
        Self::Dag
    }
}