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

/// ApplyPatchToolCall : A tool call that applies file diffs by creating, deleting, or updating files.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct ApplyPatchToolCall {
    /// The type of the item. Always `apply_patch_call`.
    #[serde(rename = "type")]
    pub r#type: Type,
    /// The unique ID of the apply patch tool call. Populated when this item is returned via API.
    #[serde(rename = "id")]
    pub id: String,
    /// The unique ID of the apply patch tool call generated by the model.
    #[serde(rename = "call_id")]
    pub call_id: String,
    #[serde(rename = "status")]
    pub status: models::ApplyPatchCallStatus,
    #[serde(rename = "operation")]
    pub operation: Box<models::ApplyPatchOperation>,
    /// The ID of the entity that created this tool call.
    #[serde(rename = "created_by", skip_serializing_if = "Option::is_none")]
    pub created_by: Option<String>,
}

impl ApplyPatchToolCall {
    /// A tool call that applies file diffs by creating, deleting, or updating files.
    pub fn new(
        r#type: Type,
        id: String,
        call_id: String,
        status: models::ApplyPatchCallStatus,
        operation: models::ApplyPatchOperation,
    ) -> ApplyPatchToolCall {
        ApplyPatchToolCall {
            r#type,
            id,
            call_id,
            status,
            operation: Box::new(operation),
            created_by: None,
        }
    }
}
/// The type of the item. Always `apply_patch_call`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
    #[serde(rename = "apply_patch_call")]
    ApplyPatchCall,
}

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

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