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