1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
* 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};
/// AdminApiKey : Represents an individual Admin API key in an org.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct AdminApiKey {
/// The object type, which is always `organization.admin_api_key`
#[serde(rename = "object")]
pub object: String,
/// The identifier, which can be referenced in API endpoints
#[serde(rename = "id")]
pub id: String,
/// The name of the API key
#[serde(rename = "name")]
pub name: String,
/// The redacted value of the API key
#[serde(rename = "redacted_value")]
pub redacted_value: String,
/// The value of the API key. Only shown on create.
#[serde(rename = "value", skip_serializing_if = "Option::is_none")]
pub value: Option<String>,
/// The Unix timestamp (in seconds) of when the API key was created
#[serde(rename = "created_at")]
pub created_at: i64,
/// The Unix timestamp (in seconds) of when the API key was last used
#[serde(rename = "last_used_at", deserialize_with = "Option::deserialize")]
pub last_used_at: Option<i64>,
#[serde(rename = "owner")]
pub owner: Box<models::AdminApiKeyOwner>,
}
impl AdminApiKey {
/// Represents an individual Admin API key in an org.
pub fn new(
object: String,
id: String,
name: String,
redacted_value: String,
created_at: i64,
last_used_at: Option<i64>,
owner: models::AdminApiKeyOwner,
) -> AdminApiKey {
AdminApiKey {
object,
id,
name,
redacted_value,
value: None,
created_at,
last_used_at,
owner: Box::new(owner),
}
}
}
impl std::fmt::Display for AdminApiKey {
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),
}
}
}