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

/// CommandExecutionItemResource : A command execution produced by the agent.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct CommandExecutionItemResource {
    /// The item type. Always `command_execution`.
    #[serde(rename = "type")]
    pub r#type: Type,
    /// The ID of the command execution 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 command that was executed.
    #[serde(rename = "command")]
    pub command: String,
    /// The working directory used to execute the command.
    #[serde(rename = "cwd", deserialize_with = "Option::deserialize")]
    pub cwd: Option<String>,
    #[serde(rename = "status")]
    pub status: models::FunctionCallStatusResource,
    /// The command output, if available.
    #[serde(rename = "output", deserialize_with = "Option::deserialize")]
    pub output: Option<String>,
    /// The process exit code, if the command completed.
    #[serde(rename = "exit_code", deserialize_with = "Option::deserialize")]
    pub exit_code: Option<i64>,
    /// The command duration in milliseconds.
    #[serde(rename = "duration_ms", deserialize_with = "Option::deserialize")]
    pub duration_ms: Option<i64>,
}

impl CommandExecutionItemResource {
    /// A command execution produced by the agent.
    pub fn new(
        r#type: Type,
        id: String,
        turn_id: String,
        command: String,
        cwd: Option<String>,
        status: models::FunctionCallStatusResource,
        output: Option<String>,
        exit_code: Option<i64>,
        duration_ms: Option<i64>,
    ) -> CommandExecutionItemResource {
        CommandExecutionItemResource {
            r#type,
            id,
            turn_id,
            command,
            cwd,
            status,
            output,
            exit_code,
            duration_ms,
        }
    }
}
/// The item type. Always `command_execution`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
    #[serde(rename = "command_execution")]
    CommandExecution,
}

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

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