async_openai/types/
audit_log.rs

1use serde::{Deserialize, Serialize};
2
3/// The event type.
4#[derive(Debug, Serialize, Deserialize)]
5pub enum AuditLogEventType {
6    #[serde(rename = "api_key.created")]
7    ApiKeyCreated,
8    #[serde(rename = "api_key.updated")]
9    ApiKeyUpdated,
10    #[serde(rename = "api_key.deleted")]
11    ApiKeyDeleted,
12    #[serde(rename = "invite.sent")]
13    InviteSent,
14    #[serde(rename = "invite.accepted")]
15    InviteAccepted,
16    #[serde(rename = "invite.deleted")]
17    InviteDeleted,
18    #[serde(rename = "login.succeeded")]
19    LoginSucceeded,
20    #[serde(rename = "login.failed")]
21    LoginFailed,
22    #[serde(rename = "logout.succeeded")]
23    LogoutSucceeded,
24    #[serde(rename = "logout.failed")]
25    LogoutFailed,
26    #[serde(rename = "organization.updated")]
27    OrganizationUpdated,
28    #[serde(rename = "project.created")]
29    ProjectCreated,
30    #[serde(rename = "project.updated")]
31    ProjectUpdated,
32    #[serde(rename = "project.archived")]
33    ProjectArchived,
34    #[serde(rename = "service_account.created")]
35    ServiceAccountCreated,
36    #[serde(rename = "service_account.updated")]
37    ServiceAccountUpdated,
38    #[serde(rename = "service_account.deleted")]
39    ServiceAccountDeleted,
40    #[serde(rename = "user.added")]
41    UserAdded,
42    #[serde(rename = "user.updated")]
43    UserUpdated,
44    #[serde(rename = "user.deleted")]
45    UserDeleted,
46}
47
48/// Represents a list of audit logs.
49#[derive(Debug, Serialize, Deserialize)]
50pub struct ListAuditLogsResponse {
51    /// The object type, which is always `list`.
52    pub object: String,
53    /// A list of `AuditLog` objects.
54    pub data: Vec<AuditLog>,
55    /// The first `audit_log_id` in the retrieved `list`.
56    pub first_id: String,
57    /// The last `audit_log_id` in the retrieved `list`.
58    pub last_id: String,
59    /// The `has_more` property is used for pagination to indicate there are additional results.
60    pub has_more: bool,
61}
62
63/// The project that the action was scoped to. Absent for actions not scoped to projects.
64#[derive(Debug, Serialize, Deserialize)]
65pub struct AuditLogProject {
66    /// The project ID.
67    pub id: String,
68    /// The project title.
69    pub name: String,
70}
71
72/// The actor who performed the audit logged action.
73#[derive(Debug, Serialize, Deserialize)]
74pub struct AuditLogActor {
75    /// The type of actor. Is either `session` or `api_key`.
76    pub r#type: String,
77    /// The session in which the audit logged action was performed.
78    pub session: Option<AuditLogActorSession>,
79    /// The API Key used to perform the audit logged action.
80    pub api_key: Option<AuditLogActorApiKey>,
81}
82
83/// The session in which the audit logged action was performed.
84#[derive(Debug, Serialize, Deserialize)]
85pub struct AuditLogActorSession {
86    /// The user who performed the audit logged action.
87    pub user: AuditLogActorUser,
88    /// The IP address from which the action was performed.
89    pub ip_address: String,
90}
91
92/// The API Key used to perform the audit logged action.
93#[derive(Debug, Serialize, Deserialize)]
94pub struct AuditLogActorApiKey {
95    /// The tracking id of the API key.
96    pub id: String,
97    /// The type of API key. Can be either `user` or `service_account`.
98    pub r#type: AuditLogActorApiKeyType,
99    /// The user who performed the audit logged action, if applicable.
100    pub user: Option<AuditLogActorUser>,
101    /// The service account that performed the audit logged action, if applicable.
102    pub service_account: Option<AuditLogActorServiceAccount>,
103}
104
105#[derive(Debug, Serialize, Deserialize)]
106#[serde(rename_all = "snake_case")]
107pub enum AuditLogActorApiKeyType {
108    User,
109    ServiceAccount,
110}
111
112/// The user who performed the audit logged action.
113#[derive(Debug, Serialize, Deserialize)]
114pub struct AuditLogActorUser {
115    /// The user id.
116    pub id: String,
117    /// The user email.
118    pub email: String,
119}
120
121/// The service account that performed the audit logged action.
122#[derive(Debug, Serialize, Deserialize)]
123pub struct AuditLogActorServiceAccount {
124    /// The service account id.
125    pub id: String,
126}
127
128/// A log of a user action or configuration change within this organization.
129#[derive(Debug, Serialize, Deserialize)]
130pub struct AuditLog {
131    /// The ID of this log.
132    pub id: String,
133    /// The event type.
134    pub r#type: AuditLogEventType,
135    /// The Unix timestamp (in seconds) of the event.
136    pub effective_at: u32,
137    /// The project that the action was scoped to. Absent for actions not scoped to projects.
138    pub project: Option<AuditLogProject>,
139    /// The actor who performed the audit logged action.
140    pub actor: AuditLogActor,
141    /// The details for events with the type `api_key.created`.
142    #[serde(rename = "api_key.created")]
143    pub api_key_created: Option<AuditLogApiKeyCreated>,
144    /// The details for events with the type `api_key.updated`.
145    #[serde(rename = "api_key.updated")]
146    pub api_key_updated: Option<AuditLogApiKeyUpdated>,
147    /// The details for events with the type `api_key.deleted`.
148    #[serde(rename = "api_key.deleted")]
149    pub api_key_deleted: Option<AuditLogApiKeyDeleted>,
150    /// The details for events with the type `invite.sent`.
151    #[serde(rename = "invite.sent")]
152    pub invite_sent: Option<AuditLogInviteSent>,
153    /// The details for events with the type `invite.accepted`.
154    #[serde(rename = "invite.accepted")]
155    pub invite_accepted: Option<AuditLogInviteAccepted>,
156    /// The details for events with the type `invite.deleted`.
157    #[serde(rename = "invite.deleted")]
158    pub invite_deleted: Option<AuditLogInviteDeleted>,
159    /// The details for events with the type `login.failed`.
160    #[serde(rename = "login.failed")]
161    pub login_failed: Option<AuditLogLoginFailed>,
162    /// The details for events with the type `logout.failed`.
163    #[serde(rename = "logout.failed")]
164    pub logout_failed: Option<AuditLogLogoutFailed>,
165    /// The details for events with the type `organization.updated`.
166    #[serde(rename = "organization.updated")]
167    pub organization_updated: Option<AuditLogOrganizationUpdated>,
168    /// The details for events with the type `project.created`.
169    #[serde(rename = "project.created")]
170    pub project_created: Option<AuditLogProjectCreated>,
171    /// The details for events with the type `project.updated`.
172    #[serde(rename = "project.updated")]
173    pub project_updated: Option<AuditLogProjectUpdated>,
174    /// The details for events with the type `project.archived`.
175    #[serde(rename = "project.archived")]
176    pub project_archived: Option<AuditLogProjectArchived>,
177    /// The details for events with the type `service_account.created`.
178    #[serde(rename = "service_account.created")]
179    pub service_account_created: Option<AuditLogServiceAccountCreated>,
180    /// The details for events with the type `service_account.updated`.
181    #[serde(rename = "service_account.updated")]
182    pub service_account_updated: Option<AuditLogServiceAccountUpdated>,
183    /// The details for events with the type `service_account.deleted`.
184    #[serde(rename = "service_account.deleted")]
185    pub service_account_deleted: Option<AuditLogServiceAccountDeleted>,
186    /// The details for events with the type `user.added`.
187    #[serde(rename = "user.added")]
188    pub user_added: Option<AuditLogUserAdded>,
189    /// The details for events with the type `user.updated`.
190    #[serde(rename = "user.updated")]
191    pub user_updated: Option<AuditLogUserUpdated>,
192    /// The details for events with the type `user.deleted`.
193    #[serde(rename = "user.deleted")]
194    pub user_deleted: Option<AuditLogUserDeleted>,
195}
196
197/// The details for events with the type `api_key.created`.
198#[derive(Debug, Serialize, Deserialize)]
199pub struct AuditLogApiKeyCreated {
200    /// The tracking ID of the API key.
201    pub id: String,
202    /// The payload used to create the API key.
203    pub data: Option<AuditLogApiKeyCreatedData>,
204}
205
206/// The payload used to create the API key.
207#[derive(Debug, Serialize, Deserialize)]
208pub struct AuditLogApiKeyCreatedData {
209    /// A list of scopes allowed for the API key, e.g. `["api.model.request"]`.
210    pub scopes: Option<Vec<String>>,
211}
212
213/// The details for events with the type `api_key.updated`.
214#[derive(Debug, Serialize, Deserialize)]
215pub struct AuditLogApiKeyUpdated {
216    /// The tracking ID of the API key.
217    pub id: String,
218    /// The payload used to update the API key.
219    pub changes_requested: Option<AuditLogApiKeyUpdatedChangesRequested>,
220}
221
222/// The payload used to update the API key.
223#[derive(Debug, Serialize, Deserialize)]
224pub struct AuditLogApiKeyUpdatedChangesRequested {
225    /// A list of scopes allowed for the API key, e.g. `["api.model.request"]`.
226    pub scopes: Option<Vec<String>>,
227}
228
229/// The details for events with the type `api_key.deleted`.
230#[derive(Debug, Serialize, Deserialize)]
231pub struct AuditLogApiKeyDeleted {
232    /// The tracking ID of the API key.
233    pub id: String,
234}
235
236/// The details for events with the type `invite.sent`.
237#[derive(Debug, Serialize, Deserialize)]
238pub struct AuditLogInviteSent {
239    /// The ID of the invite.
240    pub id: String,
241    /// The payload used to create the invite.
242    pub data: Option<AuditLogInviteSentData>,
243}
244
245/// The payload used to create the invite.
246#[derive(Debug, Serialize, Deserialize)]
247pub struct AuditLogInviteSentData {
248    /// The email invited to the organization.
249    pub email: String,
250    /// The role the email was invited to be. Is either `owner` or `member`.
251    pub role: String,
252}
253
254/// The details for events with the type `invite.accepted`.
255#[derive(Debug, Serialize, Deserialize)]
256pub struct AuditLogInviteAccepted {
257    /// The ID of the invite.
258    pub id: String,
259}
260
261/// The details for events with the type `invite.deleted`.
262#[derive(Debug, Serialize, Deserialize)]
263pub struct AuditLogInviteDeleted {
264    /// The ID of the invite.
265    pub id: String,
266}
267
268/// The details for events with the type `login.failed`.
269#[derive(Debug, Serialize, Deserialize)]
270pub struct AuditLogLoginFailed {
271    /// The error code of the failure.
272    pub error_code: String,
273    /// The error message of the failure.
274    pub error_message: String,
275}
276
277/// The details for events with the type `logout.failed`.
278#[derive(Debug, Serialize, Deserialize)]
279pub struct AuditLogLogoutFailed {
280    /// The error code of the failure.
281    pub error_code: String,
282    /// The error message of the failure.
283    pub error_message: String,
284}
285
286/// The details for events with the type `organization.updated`.
287#[derive(Debug, Serialize, Deserialize)]
288pub struct AuditLogOrganizationUpdated {
289    /// The organization ID.
290    pub id: String,
291    /// The payload used to update the organization settings.
292    pub changes_requested: Option<AuditLogOrganizationUpdatedChangesRequested>,
293}
294
295/// The payload used to update the organization settings.
296#[derive(Debug, Serialize, Deserialize)]
297pub struct AuditLogOrganizationUpdatedChangesRequested {
298    /// The organization title.
299    pub title: Option<String>,
300    /// The organization description.
301    pub description: Option<String>,
302    /// The organization name.
303    pub name: Option<String>,
304    /// The organization settings.
305    pub settings: Option<AuditLogOrganizationUpdatedChangesRequestedSettings>,
306}
307
308/// The organization settings.
309#[derive(Debug, Serialize, Deserialize)]
310pub struct AuditLogOrganizationUpdatedChangesRequestedSettings {
311    /// Visibility of the threads page which shows messages created with the Assistants API and Playground. One of `ANY_ROLE`, `OWNERS`, or `NONE`.
312    pub threads_ui_visibility: Option<String>,
313    /// Visibility of the usage dashboard which shows activity and costs for your organization. One of `ANY_ROLE` or `OWNERS`.
314    pub usage_dashboard_visibility: Option<String>,
315}
316
317/// The details for events with the type `project.created`.
318#[derive(Debug, Serialize, Deserialize)]
319pub struct AuditLogProjectCreated {
320    /// The project ID.
321    pub id: String,
322    /// The payload used to create the project.
323    pub data: Option<AuditLogProjectCreatedData>,
324}
325
326/// The payload used to create the project.
327#[derive(Debug, Serialize, Deserialize)]
328pub struct AuditLogProjectCreatedData {
329    /// The project name.
330    pub name: String,
331    /// The title of the project as seen on the dashboard.
332    pub title: Option<String>,
333}
334
335/// The details for events with the type `project.updated`.
336#[derive(Debug, Serialize, Deserialize)]
337pub struct AuditLogProjectUpdated {
338    /// The project ID.
339    pub id: String,
340    /// The payload used to update the project.
341    pub changes_requested: Option<AuditLogProjectUpdatedChangesRequested>,
342}
343
344/// The payload used to update the project.
345#[derive(Debug, Serialize, Deserialize)]
346pub struct AuditLogProjectUpdatedChangesRequested {
347    /// The title of the project as seen on the dashboard.
348    pub title: Option<String>,
349}
350
351/// The details for events with the type `project.archived`.
352#[derive(Debug, Serialize, Deserialize)]
353pub struct AuditLogProjectArchived {
354    /// The project ID.
355    pub id: String,
356}
357
358/// The details for events with the type `service_account.created`.
359#[derive(Debug, Serialize, Deserialize)]
360pub struct AuditLogServiceAccountCreated {
361    /// The service account ID.
362    pub id: String,
363    /// The payload used to create the service account.
364    pub data: Option<AuditLogServiceAccountCreatedData>,
365}
366
367/// The payload used to create the service account.
368#[derive(Debug, Serialize, Deserialize)]
369pub struct AuditLogServiceAccountCreatedData {
370    /// The role of the service account. Is either `owner` or `member`.
371    pub role: String,
372}
373
374/// The details for events with the type `service_account.updated`.
375#[derive(Debug, Serialize, Deserialize)]
376pub struct AuditLogServiceAccountUpdated {
377    /// The service account ID.
378    pub id: String,
379    /// The payload used to updated the service account.
380    pub changes_requested: Option<AuditLogServiceAccountUpdatedChangesRequested>,
381}
382
383/// The payload used to updated the service account.
384#[derive(Debug, Serialize, Deserialize)]
385pub struct AuditLogServiceAccountUpdatedChangesRequested {
386    /// The role of the service account. Is either `owner` or `member`.
387    pub role: String,
388}
389
390/// The details for events with the type `service_account.deleted`.
391#[derive(Debug, Serialize, Deserialize)]
392pub struct AuditLogServiceAccountDeleted {
393    /// The service account ID.
394    pub id: String,
395}
396
397/// The details for events with the type `user.added`.
398#[derive(Debug, Serialize, Deserialize)]
399pub struct AuditLogUserAdded {
400    /// The user ID.
401    pub id: String,
402    /// The payload used to add the user to the project.
403    pub data: Option<AuditLogUserAddedData>,
404}
405
406/// The payload used to add the user to the project.
407#[derive(Debug, Serialize, Deserialize)]
408pub struct AuditLogUserAddedData {
409    /// The role of the user. Is either `owner` or `member`.
410    pub role: String,
411}
412
413/// The details for events with the type `user.updated`.
414#[derive(Debug, Serialize, Deserialize)]
415pub struct AuditLogUserUpdated {
416    /// The project ID.
417    pub id: String,
418    /// The payload used to update the user.
419    pub changes_requested: Option<AuditLogUserUpdatedChangesRequested>,
420}
421
422/// The payload used to update the user.
423#[derive(Debug, Serialize, Deserialize)]
424pub struct AuditLogUserUpdatedChangesRequested {
425    /// The role of the user. Is either `owner` or `member`.
426    pub role: String,
427}
428
429/// The details for events with the type `user.deleted`.
430#[derive(Debug, Serialize, Deserialize)]
431pub struct AuditLogUserDeleted {
432    /// The user ID.
433    pub id: String,
434}