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

/// AuditLogActorApiKey : The API Key used to perform the audit logged action.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct AuditLogActorApiKey {
    /// The tracking id of the API key.
    #[serde(rename = "id", skip_serializing_if = "Option::is_none")]
    pub id: Option<String>,
    /// The type of API key. Can be either `user` or `service_account`.
    #[serde(rename = "type", skip_serializing_if = "Option::is_none")]
    pub r#type: Option<Type>,
    #[serde(rename = "user", skip_serializing_if = "Option::is_none")]
    pub user: Option<Box<models::AuditLogActorUser>>,
    #[serde(rename = "service_account", skip_serializing_if = "Option::is_none")]
    pub service_account: Option<Box<models::AuditLogActorServiceAccount>>,
}

impl AuditLogActorApiKey {
    /// The API Key used to perform the audit logged action.
    pub fn new() -> AuditLogActorApiKey {
        AuditLogActorApiKey {
            id: None,
            r#type: None,
            user: None,
            service_account: None,
        }
    }
}
/// The type of API key. Can be either `user` or `service_account`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
    #[serde(rename = "user")]
    User,
    #[serde(rename = "service_account")]
    ServiceAccount,
}

impl Default for Type {
    fn default() -> Type {
        Self::User
    }
}

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