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

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct ServiceAccountApiKeyBody {
    /// The object type, which is always `organization.project.service_account.api_key`
    #[serde(rename = "object")]
    pub object: Object,
    /// The unredacted API key value.
    #[serde(rename = "value")]
    pub value: String,
    /// The name of the API key.
    #[serde(rename = "name")]
    pub name: String,
    /// The Unix timestamp (in seconds) when the API key was created.
    #[serde(rename = "created_at")]
    pub created_at: i32,
    /// The Unix timestamp (in seconds) when the API key expires, or null if it does not expire.
    #[serde(
        rename = "expires_at",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub expires_at: Option<Option<i32>>,
    /// The identifier of the API key.
    #[serde(rename = "id")]
    pub id: String,
}

impl ServiceAccountApiKeyBody {
    pub fn new(
        object: Object,
        value: String,
        name: String,
        created_at: i32,
        id: String,
    ) -> ServiceAccountApiKeyBody {
        ServiceAccountApiKeyBody {
            object,
            value,
            name,
            created_at,
            expires_at: None,
            id,
        }
    }
}
/// The object type, which is always `organization.project.service_account.api_key`
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Object {
    #[serde(rename = "organization.project.service_account.api_key")]
    OrganizationProjectServiceAccountApiKey,
}

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

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