novel_openai/spec/admin/api_keys/api_keys_.rs
1use derive_builder::Builder;
2use serde::{Deserialize, Serialize};
3
4use crate::error::OpenAIError;
5
6/// Represents an individual Admin API key in an org.
7#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
8pub struct AdminApiKey {
9 /// The object type, which is always `organization.admin_api_key`.
10 pub object: String,
11 /// The identifier, which can be referenced in API endpoints.
12 pub id: String,
13 /// The name of the API key.
14 pub name: String,
15 /// The redacted value of the API key.
16 pub redacted_value: String,
17 /// The value of the API key. Only shown on create.
18 #[serde(skip_serializing_if = "Option::is_none")]
19 pub value: Option<String>,
20 /// The Unix timestamp (in seconds) of when the API key was created.
21 pub created_at: u64,
22 /// The Unix timestamp (in seconds) of when the API key was last used.
23 pub last_used_at: Option<u64>,
24 /// The owner of the API key.
25 pub owner: AdminApiKeyOwner,
26}
27
28/// Represents the owner of an admin API key.
29#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
30pub struct AdminApiKeyOwner {
31 pub kind: String,
32
33 pub object: String,
34 /// The identifier, which can be referenced in API endpoints.
35 pub id: String,
36 /// The name of the owner.
37 pub name: String,
38 /// The Unix timestamp (in seconds) of when the owner was created.
39 pub created_at: u64,
40
41 pub role: String,
42}
43
44/// Represents the response object for listing admin API keys.
45#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
46pub struct ApiKeyList {
47 /// The object type, which is always `list`.
48 pub object: String,
49 /// The list of admin API keys.
50 pub data: Vec<AdminApiKey>,
51 /// Indicates if there are more admin API keys available.
52 pub has_more: bool,
53 /// The ID of the first admin API key in the list.
54 pub first_id: Option<String>,
55 /// The ID of the last admin API key in the list.
56 pub last_id: Option<String>,
57}
58
59/// Represents the request object for creating an admin API key.
60#[derive(Debug, Serialize, Deserialize, Builder, Clone, PartialEq)]
61#[builder(name = "CreateAdminApiKeyRequestArgs")]
62#[builder(pattern = "mutable")]
63#[builder(setter(into, strip_option))]
64#[builder(derive(Debug))]
65#[builder(build_fn(error = "OpenAIError"))]
66pub struct CreateAdminApiKeyRequest {
67 /// The name of the API key being created.
68 pub name: String,
69}
70
71/// Represents the response object for deleting an admin API key.
72#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
73pub struct AdminApiKeyDeleteResponse {
74 /// The object type, which is always `organization.admin_api_key.deleted`.
75 pub object: String,
76 /// The ID of the deleted API key.
77 pub id: String,
78 /// Indicates if the API key was successfully deleted.
79 pub deleted: bool,
80}