async_openai/types/admin/
users.rs

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