// Code generated by oagen. DO NOT EDIT.

#[allow(unused_imports)]
use super::*;
#[allow(unused_imports)]
use crate::enums::*;
use serde::{Deserialize, Serialize};
/// A partition result: a document segmented into chunks along the requested `key`.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Partition {
    /// Unique identifier of the partition
    pub id: String,
    /// Information about the partitioned file
    pub file: FileRef,
    /// Model used for the partition operation
    pub model: String,
    /// Partition key used for the run
    pub key: String,
    /// Free-form instructions supplied with the partition request
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub instructions: Option<String>,
    /// Number of consensus votes used
    ///
    /// Defaults to `1`.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub n_consensus: Option<i64>,
    /// Whether pages were allowed to appear in more than one partition chunk
    ///
    /// Defaults to `true`.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub allow_overlap: Option<bool>,
    /// The list of partition chunks with their assigned pages. Empty [] until status == 'completed'.
    ///
    /// Defaults to `[]`.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub output: Option<Vec<PartitionChunk>>,
    /// 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<PartitionStatus>,
    /// 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 partition runs
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub consensus: Option<PartitionConsensus>,
    /// Usage information for the partition operation
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub usage: Option<RetabUsage>,
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub created_at: Option<String>,
}
impl Partition {
    /// Construct a new `Partition` with the required fields set.
    #[allow(deprecated)]
    pub fn new(
        id: impl Into<String>,
        file: FileRef,
        model: impl Into<String>,
        key: impl Into<String>,
    ) -> Self {
        Self {
            id: id.into(),
            file,
            model: model.into(),
            key: key.into(),
            instructions: Default::default(),
            n_consensus: Default::default(),
            allow_overlap: Default::default(),
            output: Default::default(),
            status: Default::default(),
            error: Default::default(),
            consensus: Default::default(),
            usage: Default::default(),
            created_at: Default::default(),
        }
    }
}
