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

/// WebhookFineTuningJobCancelled : Sent when a fine-tuning job has been cancelled.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct WebhookFineTuningJobCancelled {
    /// The Unix timestamp (in seconds) of when the fine-tuning job was cancelled.
    #[serde(rename = "created_at")]
    pub created_at: i32,
    /// The unique ID of the event.
    #[serde(rename = "id")]
    pub id: String,
    #[serde(rename = "data")]
    pub data: Box<models::WebhookFineTuningJobCancelledData>,
    /// The object of the event. Always `event`.
    #[serde(rename = "object", skip_serializing_if = "Option::is_none")]
    pub object: Option<Object>,
    /// The type of the event. Always `fine_tuning.job.cancelled`.
    #[serde(rename = "type")]
    pub r#type: Type,
}

impl WebhookFineTuningJobCancelled {
    /// Sent when a fine-tuning job has been cancelled.
    pub fn new(
        created_at: i32,
        id: String,
        data: models::WebhookFineTuningJobCancelledData,
        r#type: Type,
    ) -> WebhookFineTuningJobCancelled {
        WebhookFineTuningJobCancelled {
            created_at,
            id,
            data: Box::new(data),
            object: None,
            r#type,
        }
    }
}
/// The object of the event. Always `event`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Object {
    #[serde(rename = "event")]
    Event,
}

impl Default for Object {
    fn default() -> Object {
        Self::Event
    }
}
/// The type of the event. Always `fine_tuning.job.cancelled`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
    #[serde(rename = "fine_tuning.job.cancelled")]
    FineTuningJobCancelled,
}

impl Default for Type {
    fn default() -> Type {
        Self::FineTuningJobCancelled
    }
}

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