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

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct ContainerResource {
    /// Unique identifier for the container.
    #[serde(rename = "id")]
    pub id: String,
    /// The type of this object.
    #[serde(rename = "object")]
    pub object: String,
    /// Name of the container.
    #[serde(rename = "name")]
    pub name: String,
    /// Unix timestamp (in seconds) when the container was created.
    #[serde(rename = "created_at")]
    pub created_at: i32,
    /// Status of the container (e.g., active, deleted).
    #[serde(rename = "status")]
    pub status: String,
    /// Unix timestamp (in seconds) when the container was last active.
    #[serde(rename = "last_active_at", skip_serializing_if = "Option::is_none")]
    pub last_active_at: Option<i32>,
    #[serde(rename = "expires_after", skip_serializing_if = "Option::is_none")]
    pub expires_after: Option<Box<models::ContainerResourceExpiresAfter>>,
    /// The memory limit configured for the container.
    #[serde(rename = "memory_limit", skip_serializing_if = "Option::is_none")]
    pub memory_limit: Option<MemoryLimit>,
    #[serde(rename = "network_policy", skip_serializing_if = "Option::is_none")]
    pub network_policy: Option<Box<models::ContainerResourceNetworkPolicy>>,
}

impl ContainerResource {
    pub fn new(
        id: String,
        object: String,
        name: String,
        created_at: i32,
        status: String,
    ) -> ContainerResource {
        ContainerResource {
            id,
            object,
            name,
            created_at,
            status,
            last_active_at: None,
            expires_after: None,
            memory_limit: None,
            network_policy: None,
        }
    }
}
/// The memory limit configured for the container.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum MemoryLimit {
    #[serde(rename = "1g")]
    Variant1g,
    #[serde(rename = "4g")]
    Variant4g,
    #[serde(rename = "16g")]
    Variant16g,
    #[serde(rename = "64g")]
    Variant64g,
}

impl Default for MemoryLimit {
    fn default() -> MemoryLimit {
        Self::Variant1g
    }
}

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