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

/// Project : Represents an individual project.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct Project {
    /// The identifier, which can be referenced in API endpoints
    #[serde(rename = "id")]
    pub id: String,
    /// The object type, which is always `organization.project`
    #[serde(rename = "object")]
    pub object: Object,
    /// The name of the project. This appears in reporting.
    #[serde(rename = "name")]
    pub name: String,
    /// The Unix timestamp (in seconds) of when the project was created.
    #[serde(rename = "created_at")]
    pub created_at: i32,
    /// The Unix timestamp (in seconds) of when the project was archived or `null`.
    #[serde(
        rename = "archived_at",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub archived_at: Option<Option<i32>>,
    /// `active` or `archived`
    #[serde(rename = "status")]
    pub status: Status,
}

impl Project {
    /// Represents an individual project.
    pub fn new(
        id: String,
        object: Object,
        name: String,
        created_at: i32,
        status: Status,
    ) -> Project {
        Project {
            id,
            object,
            name,
            created_at,
            archived_at: None,
            status,
        }
    }
}
/// The object type, which is always `organization.project`
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Object {
    #[serde(rename = "organization.project")]
    OrganizationProject,
}

impl Default for Object {
    fn default() -> Object {
        Self::OrganizationProject
    }
}
/// `active` or `archived`
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Status {
    #[serde(rename = "active")]
    Active,
    #[serde(rename = "archived")]
    Archived,
}

impl Default for Status {
    fn default() -> Status {
        Self::Active
    }
}

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