// Code generated by oagen. DO NOT EDIT.

#[allow(unused_imports)]
use super::*;
#[allow(unused_imports)]
use crate::enums::*;
use serde::{Deserialize, Serialize};
/// An extraction produced by a workflow run, tagged with its artifact `operation` and creation time.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ExtractionWorkflowArtifact {
    /// Unique identifier of the extraction
    pub id: String,
    /// Information about the extracted file
    pub file: FileRef,
    /// Model used for the extraction
    pub model: String,
    /// JSON schema used for the extraction
    pub json_schema: std::collections::HashMap<String, serde_json::Value>,
    /// Number of consensus votes used
    ///
    /// Defaults to `1`.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub n_consensus: Option<i64>,
    /// Free-form instructions supplied with the extraction request.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub instructions: Option<String>,
    /// The extracted structured data
    pub output: std::collections::HashMap<String, serde_json::Value>,
    /// Lifecycle status. The synchronous path returns 'completed'. Background runs progress pending -> queued -> in_progress -> completed | failed | cancelled.
    ///
    /// Defaults to `pending`.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub status: Option<ExtractionWorkflowArtifactStatus>,
    /// Error details when a background run fails; null otherwise. Always present so consumers can read it without an existence check.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub error: Option<PrimitiveError>,
    /// Consensus metadata for multi-vote extraction runs
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub consensus: Option<ExtractionConsensus>,
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub metadata: Option<std::collections::HashMap<String, String>>,
    /// Usage information for the extraction
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub usage: Option<RetabUsage>,
    /// Timestamp when this artifact was created.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub created_at: Option<String>,
    /// The operation that produced this artifact
    ///
    /// Defaults to `extraction`.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub operation: Option<String>,
}
impl ExtractionWorkflowArtifact {
    /// Construct a new `ExtractionWorkflowArtifact` with the required fields set.
    #[allow(deprecated)]
    pub fn new(
        id: impl Into<String>,
        file: FileRef,
        model: impl Into<String>,
        json_schema: std::collections::HashMap<String, serde_json::Value>,
        output: std::collections::HashMap<String, serde_json::Value>,
    ) -> Self {
        Self {
            id: id.into(),
            file,
            model: model.into(),
            json_schema,
            n_consensus: Default::default(),
            instructions: Default::default(),
            output,
            status: Default::default(),
            error: Default::default(),
            consensus: Default::default(),
            metadata: Default::default(),
            usage: Default::default(),
            created_at: Default::default(),
            operation: Default::default(),
        }
    }
}
