openai-client-base 0.12.0

Auto-generated Rust client for the OpenAI API
/*
 * OpenAI API
 *
 * The OpenAI REST API. Please see https://platform.openai.com/docs/api-reference for more details.
 *
 * The version of the OpenAPI document: 2.3.0
 *
 * Generated by: https://openapi-generator.tech
 */

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

/// Upload : The Upload object can accept byte chunks in the form of Parts.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct Upload {
    /// The Upload unique identifier, which can be referenced in API endpoints.
    #[serde(rename = "id")]
    pub id: String,
    /// The Unix timestamp (in seconds) for when the Upload was created.
    #[serde(rename = "created_at")]
    pub created_at: i32,
    /// The name of the file to be uploaded.
    #[serde(rename = "filename")]
    pub filename: String,
    /// The intended number of bytes to be uploaded.
    #[serde(rename = "bytes")]
    pub bytes: i32,
    /// The intended purpose of the file. [Please refer here](/docs/api-reference/files/object#files/object-purpose) for acceptable values.
    #[serde(rename = "purpose")]
    pub purpose: String,
    /// The status of the Upload.
    #[serde(rename = "status")]
    pub status: Status,
    /// The Unix timestamp (in seconds) for when the Upload will expire.
    #[serde(rename = "expires_at")]
    pub expires_at: i32,
    /// The object type, which is always \"upload\".
    #[serde(rename = "object", skip_serializing_if = "Option::is_none")]
    pub object: Option<Object>,
    /// The ready File object after the Upload is completed.
    #[serde(rename = "file", skip_serializing_if = "Option::is_none")]
    pub file: Option<Box<models::OpenAiFile>>,
}

impl Upload {
    /// The Upload object can accept byte chunks in the form of Parts.
    pub fn new(
        id: String,
        created_at: i32,
        filename: String,
        bytes: i32,
        purpose: String,
        status: Status,
        expires_at: i32,
    ) -> Upload {
        Upload {
            id,
            created_at,
            filename,
            bytes,
            purpose,
            status,
            expires_at,
            object: None,
            file: None,
        }
    }
}
/// The status of the Upload.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Status {
    #[serde(rename = "pending")]
    Pending,
    #[serde(rename = "completed")]
    Completed,
    #[serde(rename = "cancelled")]
    Cancelled,
    #[serde(rename = "expired")]
    Expired,
}

impl Default for Status {
    fn default() -> Status {
        Self::Pending
    }
}
/// The object type, which is always \"upload\".
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Object {
    #[serde(rename = "upload")]
    Upload,
}

impl Default for Object {
    fn default() -> Object {
        Self::Upload
    }
}

impl std::fmt::Display for Upload {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match serde_json::to_string(self) {
            Ok(s) => write!(f, "{}", s),
            Err(_) => Err(std::fmt::Error),
        }
    }
}