Skip to main content

outfox_openai/spec/admin/users/
users_.rs

1use derive_builder::Builder;
2use serde::{Deserialize, Serialize};
3
4use crate::error::OpenAIError;
5use crate::spec::admin::roles::{OrganizationRole, Role};
6
7/// Represents an individual `user` within an organization.
8#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
9pub struct User {
10    /// The object type, which is always `organization.user`
11    pub object: String,
12    /// The identifier, which can be referenced in API endpoints
13    pub id: String,
14    /// The name of the user
15    pub name: String,
16    /// The email address of the user
17    pub email: String,
18    /// `owner` or `reader`
19    pub role: OrganizationRole,
20    /// The Unix timestamp (in seconds) of when the users was added.
21    pub added_at: u64,
22}
23
24/// A list of `User` objects.
25#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
26pub struct UserListResponse {
27    pub object: String,
28    pub data: Vec<User>,
29    pub first_id: Option<String>,
30    pub last_id: Option<String>,
31    pub has_more: bool,
32}
33
34#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Builder)]
35#[builder(name = "UserRoleUpdateRequestArgs")]
36#[builder(pattern = "mutable")]
37#[builder(setter(into, strip_option))]
38#[builder(derive(Debug))]
39#[builder(build_fn(error = "OpenAIError"))]
40pub struct UserRoleUpdateRequest {
41    /// `owner` or `reader`
42    pub role: OrganizationRole,
43}
44
45/// Confirmation of the deleted user
46#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
47pub struct UserDeleteResponse {
48    pub object: String,
49    pub id: String,
50    pub deleted: bool,
51}
52
53/// Role assignment linking a user to a role.
54#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
55pub struct UserRoleAssignment {
56    /// The object type, which is always `user.role`.
57    pub object: String,
58    /// The user.
59    pub user: User,
60    /// The role.
61    pub role: Role,
62}
63
64/// Paginated list of role assignments for a user.
65#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
66pub struct UserRoleAssignmentListResource {
67    /// The object type, which is always `list`.
68    pub object: String,
69    /// Role assignments returned in the current page.
70    pub data: Vec<UserRoleAssignment>,
71    /// Whether additional assignments are available when paginating.
72    pub has_more: bool,
73    /// Cursor to fetch the next page of results, or `null` when there are no more assignments.
74    pub next: Option<String>,
75}
76
77/// Request payload for assigning a role to a user.
78#[derive(Debug, Serialize, Deserialize, Builder, Clone, PartialEq)]
79#[builder(name = "AssignUserRoleRequestArgs")]
80#[builder(pattern = "mutable")]
81#[builder(setter(into, strip_option))]
82#[builder(derive(Debug))]
83#[builder(build_fn(error = "OpenAIError"))]
84pub struct PublicAssignOrganizationUserRoleBody {
85    /// Identifier of the role to assign.
86    pub role_id: String,
87}