// Code generated by oagen. DO NOT EDIT.

#[allow(unused_imports)]
use super::*;
#[allow(unused_imports)]
use crate::enums::*;
use serde::{Deserialize, Serialize};
/// An edit produced by a workflow run, tagged with its artifact `operation` and creation time.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct EditWorkflowArtifact {
    /// Unique identifier of the edit.
    pub id: String,
    /// Information about the source file (input document or template PDF).
    pub file: FileRef,
    /// Model used for the edit operation.
    pub model: String,
    /// Free-form instructions supplied with the edit request.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub instructions: Option<String>,
    /// Configuration used for the edit operation.
    pub config: EditConfig,
    /// Template id used when the edit was created from a template; null for direct-document edits.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub template_id: Option<String>,
    /// The edit result: filled form fields and the rendered PDF. An empty sentinel until status == 'completed'; gate reads on status.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub output: Option<EditResult>,
    /// 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<EditWorkflowArtifactStatus>,
    /// 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>,
    /// Durable file reference for the filled document, when materialized.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub filled_document_ref: Option<FileRef>,
    /// Usage information for the edit operation.
    #[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 `edit`.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub operation: Option<String>,
}
impl EditWorkflowArtifact {
    /// Construct a new `EditWorkflowArtifact` with the required fields set.
    #[allow(deprecated)]
    pub fn new(
        id: impl Into<String>,
        file: FileRef,
        model: impl Into<String>,
        config: EditConfig,
    ) -> Self {
        Self {
            id: id.into(),
            file,
            model: model.into(),
            instructions: Default::default(),
            config,
            template_id: Default::default(),
            output: Default::default(),
            status: Default::default(),
            error: Default::default(),
            filled_document_ref: Default::default(),
            usage: Default::default(),
            created_at: Default::default(),
            operation: Default::default(),
        }
    }
}
