openai-client-base 0.16.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};

/// McpCallItemResource : A call to a tool on an MCP server.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct McpCallItemResource {
    /// The item type. Always `mcp_call`.
    #[serde(rename = "type")]
    pub r#type: Type,
    /// The ID of the MCP call item.
    #[serde(rename = "id")]
    pub id: String,
    /// The ID of the turn that contains this item.
    #[serde(rename = "turn_id")]
    pub turn_id: String,
    /// The label of the MCP server.
    #[serde(rename = "server_label")]
    pub server_label: String,
    /// The name of the MCP tool.
    #[serde(rename = "name")]
    pub name: String,
    #[serde(rename = "arguments", deserialize_with = "Option::deserialize")]
    pub arguments: Option<serde_json::Value>,
    #[serde(rename = "status")]
    pub status: models::FunctionCallStatusResource,
    /// The output returned by the MCP tool, if any.
    #[serde(rename = "output", deserialize_with = "Option::deserialize")]
    pub output: Option<Box<serde_json::Value>>,
    /// The error returned by the MCP tool, if any.
    #[serde(rename = "error", deserialize_with = "Option::deserialize")]
    pub error: Option<Box<serde_json::Value>>,
}

impl McpCallItemResource {
    /// A call to a tool on an MCP server.
    pub fn new(
        r#type: Type,
        id: String,
        turn_id: String,
        server_label: String,
        name: String,
        arguments: Option<serde_json::Value>,
        status: models::FunctionCallStatusResource,
        output: Option<serde_json::Value>,
        error: Option<serde_json::Value>,
    ) -> McpCallItemResource {
        McpCallItemResource {
            r#type,
            id,
            turn_id,
            server_label,
            name,
            arguments,
            status,
            output: output.map(Box::new),
            error: error.map(Box::new),
        }
    }
}
/// The item type. Always `mcp_call`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
    #[serde(rename = "mcp_call")]
    McpCall,
}

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

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