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

/// EnvironmentTemplateResource : Reusable configuration that provisions a fresh OpenAI-hosted environment for each session.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct EnvironmentTemplateResource {
    /// The ID of the reusable environment template.
    #[serde(rename = "id")]
    pub id: String,
    /// An optional human-readable display name for the template.
    #[serde(rename = "name", deserialize_with = "Option::deserialize")]
    pub name: Option<String>,
    /// The object type. Always `agent.environment.template`.
    #[serde(rename = "object")]
    pub object: Object,
    /// The Unix timestamp, in seconds, when the template was created.
    #[serde(rename = "created_at")]
    pub created_at: i64,
    /// The Unix timestamp, in seconds, when the template was last updated.
    #[serde(rename = "updated_at")]
    pub updated_at: i64,
    #[serde(rename = "packages")]
    pub packages: models::EnvironmentPackagesResource,
    #[serde(rename = "network")]
    pub network: models::NetworkPolicyResource,
    #[serde(rename = "desktop")]
    pub desktop: models::DesktopResource,
    /// Directories that expose capabilities to the agent.
    #[serde(rename = "capability_directories")]
    pub capability_directories: Vec<String>,
    /// Safe skill metadata, preserving unresolved version selectors.
    #[serde(rename = "skills")]
    pub skills: Vec<models::HostedTemplateSkillResource>,
    /// Safe plugin metadata, excluding inline archive contents.
    #[serde(rename = "plugins")]
    pub plugins: Vec<models::HostedPluginResourceInline>,
    /// Safe file metadata, excluding contents and session-scoped file IDs.
    #[serde(rename = "files")]
    pub files: Vec<models::HostedTemplateFileResource>,
}

impl EnvironmentTemplateResource {
    /// Reusable configuration that provisions a fresh OpenAI-hosted environment for each session.
    pub fn new(
        id: String,
        name: Option<String>,
        object: Object,
        created_at: i64,
        updated_at: i64,
        packages: models::EnvironmentPackagesResource,
        network: models::NetworkPolicyResource,
        desktop: models::DesktopResource,
        capability_directories: Vec<String>,
        skills: Vec<models::HostedTemplateSkillResource>,
        plugins: Vec<models::HostedPluginResourceInline>,
        files: Vec<models::HostedTemplateFileResource>,
    ) -> EnvironmentTemplateResource {
        EnvironmentTemplateResource {
            id,
            name,
            object,
            created_at,
            updated_at,
            packages,
            network,
            desktop,
            capability_directories,
            skills,
            plugins,
            files,
        }
    }
}
/// The object type. Always `agent.environment.template`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Object {
    #[serde(rename = "agent.environment.template")]
    AgentEnvironmentTemplate,
}

impl Default for Object {
    fn default() -> Object {
        Self::AgentEnvironmentTemplate
    }
}

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