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

/// LocalShellExecAction : Execute a shell command on the server.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct LocalShellExecAction {
    /// The type of the local shell action. Always `exec`.
    #[serde(rename = "type")]
    pub r#type: Type,
    /// The command to run.
    #[serde(rename = "command")]
    pub command: Vec<String>,
    /// Optional timeout in milliseconds for the command.
    #[serde(
        rename = "timeout_ms",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub timeout_ms: Option<Option<i32>>,
    /// Optional working directory to run the command in.
    #[serde(
        rename = "working_directory",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub working_directory: Option<Option<String>>,
    /// Environment variables to set for the command.
    #[serde(rename = "env")]
    pub env: std::collections::HashMap<String, String>,
    /// Optional user to run the command as.
    #[serde(
        rename = "user",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub user: Option<Option<String>>,
}

impl LocalShellExecAction {
    /// Execute a shell command on the server.
    pub fn new(
        r#type: Type,
        command: Vec<String>,
        env: std::collections::HashMap<String, String>,
    ) -> LocalShellExecAction {
        LocalShellExecAction {
            r#type,
            command,
            timeout_ms: None,
            working_directory: None,
            env,
            user: None,
        }
    }
}
/// The type of the local shell action. Always `exec`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
    #[serde(rename = "exec")]
    Exec,
}

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

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