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

/// CreateAgentSessionParams : Parameters for creating a Managed Agents session.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct CreateAgentSessionParams {
    /// Up to 16 string key-value pairs, with keys up to 64 and values up to 512 characters. Omission or null defaults to an empty map.
    #[serde(rename = "metadata", skip_serializing_if = "Option::is_none")]
    pub metadata: Option<std::collections::HashMap<String, String>>,
    #[serde(rename = "agent", skip_serializing_if = "Option::is_none")]
    pub agent: Option<models::SessionAgentConfigParam>,
    /// The ID of a saved reusable agent. Omit `agent` to use its configuration unchanged.
    #[serde(rename = "agent_id", skip_serializing_if = "Option::is_none")]
    pub agent_id: Option<String>,
    #[serde(rename = "environment")]
    pub environment: Box<models::EnvironmentParam>,
    /// The IDs of vaults made available to the session.
    #[serde(
        rename = "vault_ids",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub vault_ids: Option<Option<Vec<String>>>,
    #[serde(
        rename = "input",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub input: Option<Option<Box<models::CreateSessionInputParam>>>,
    /// Whether to stream session events as server-sent events. Defaults to `false`.
    #[serde(rename = "stream", skip_serializing_if = "Option::is_none")]
    pub stream: Option<bool>,
}

impl CreateAgentSessionParams {
    /// Parameters for creating a Managed Agents session.
    pub fn new(environment: models::EnvironmentParam) -> CreateAgentSessionParams {
        CreateAgentSessionParams {
            metadata: None,
            agent: None,
            agent_id: None,
            environment: Box::new(environment),
            vault_ids: None,
            input: None,
            stream: None,
        }
    }
}

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