openai-client-base 0.13.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, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct AdminApiKeyCreateResponse {
    /// The object type, which is always `organization.admin_api_key`
    #[serde(rename = "object")]
    pub object: Object,
    /// The identifier, which can be referenced in API endpoints
    #[serde(rename = "id")]
    pub id: String,
    #[serde(rename = "name", skip_serializing_if = "Option::is_none")]
    pub name: Option<String>,
    /// The redacted value of the API key
    #[serde(rename = "redacted_value")]
    pub redacted_value: String,
    /// The Unix timestamp (in seconds) of when the API key was created
    #[serde(rename = "created_at")]
    pub created_at: i32,
    /// The Unix timestamp (in seconds) of when the API key was last used
    #[serde(rename = "last_used_at", skip_serializing_if = "Option::is_none")]
    pub last_used_at: Option<i32>,
    #[serde(rename = "owner")]
    pub owner: Box<models::AdminApiKeyOwner>,
    /// The value of the API key. Only shown on create.
    #[serde(rename = "value")]
    pub value: String,
}

impl AdminApiKeyCreateResponse {
    pub fn new(
        object: Object,
        id: String,
        redacted_value: String,
        created_at: i32,
        owner: models::AdminApiKeyOwner,
        value: String,
    ) -> AdminApiKeyCreateResponse {
        AdminApiKeyCreateResponse {
            object,
            id,
            name: None,
            redacted_value,
            created_at,
            last_used_at: None,
            owner: Box::new(owner),
            value,
        }
    }
}
/// The object type, which is always `organization.admin_api_key`
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Object {
    #[serde(rename = "organization.admin_api_key")]
    OrganizationAdminApiKey,
}

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

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