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};

/// VideoResource : Structured information describing a generated video job.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct VideoResource {
    /// Unique identifier for the video job.
    #[serde(rename = "id")]
    pub id: String,
    /// The object type, which is always `video`.
    #[serde(rename = "object")]
    pub object: Object,
    #[serde(rename = "model")]
    pub model: Box<models::VideoModel>,
    #[serde(rename = "status")]
    pub status: models::VideoStatus,
    /// Approximate completion percentage for the generation task.
    #[serde(rename = "progress")]
    pub progress: i32,
    /// Unix timestamp (seconds) for when the job was created.
    #[serde(rename = "created_at")]
    pub created_at: i32,
    /// Unix timestamp (seconds) for when the job completed, if finished.
    #[serde(rename = "completed_at", deserialize_with = "Option::deserialize")]
    pub completed_at: Option<i32>,
    /// Unix timestamp (seconds) for when the downloadable assets expire, if set.
    #[serde(rename = "expires_at", deserialize_with = "Option::deserialize")]
    pub expires_at: Option<i32>,
    /// The prompt that was used to generate the video.
    #[serde(rename = "prompt", deserialize_with = "Option::deserialize")]
    pub prompt: Option<String>,
    #[serde(rename = "size")]
    pub size: models::VideoSize,
    /// Duration of the generated clip in seconds. For extensions, this is the stitched total duration.
    #[serde(rename = "seconds")]
    pub seconds: String,
    /// Identifier of the source video if this video is a remix.
    #[serde(
        rename = "remixed_from_video_id",
        deserialize_with = "Option::deserialize"
    )]
    pub remixed_from_video_id: Option<String>,
    #[serde(rename = "error", deserialize_with = "Option::deserialize")]
    pub error: Option<Box<models::Error2>>,
}

impl VideoResource {
    /// Structured information describing a generated video job.
    pub fn new(
        id: String,
        object: Object,
        model: models::VideoModel,
        status: models::VideoStatus,
        progress: i32,
        created_at: i32,
        completed_at: Option<i32>,
        expires_at: Option<i32>,
        prompt: Option<String>,
        size: models::VideoSize,
        seconds: String,
        remixed_from_video_id: Option<String>,
        error: Option<models::Error2>,
    ) -> VideoResource {
        VideoResource {
            id,
            object,
            model: Box::new(model),
            status,
            progress,
            created_at,
            completed_at,
            expires_at,
            prompt,
            size,
            seconds,
            remixed_from_video_id,
            error: error.map(Box::new),
        }
    }
}
/// The object type, which is always `video`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Object {
    #[serde(rename = "video")]
    Video,
}

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

impl std::fmt::Display for VideoResource {
    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),
        }
    }
}