async_openai/types/admin/
groups.rs

1use crate::types::admin::roles::Role;
2use crate::types::admin::users::User;
3use crate::types::OpenAIError;
4use derive_builder::Builder;
5use serde::{Deserialize, Serialize};
6
7/// Sort order for listing groups.
8#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
9#[serde(rename_all = "lowercase")]
10pub enum ListGroupsOrder {
11    /// Ascending order
12    Asc,
13    /// Descending order
14    Desc,
15}
16
17/// Query parameters for listing groups.
18#[derive(Debug, Serialize, Default, Clone, Builder, PartialEq)]
19#[builder(name = "ListGroupsQueryArgs")]
20#[builder(pattern = "mutable")]
21#[builder(setter(into, strip_option), default)]
22#[builder(derive(Debug))]
23#[builder(build_fn(error = "OpenAIError"))]
24pub struct ListGroupsQuery {
25    /// A limit on the number of groups to be returned. Limit can range between 0 and 1000, and the default is 100.
26    #[serde(skip_serializing_if = "Option::is_none")]
27    pub limit: Option<u32>,
28    /// A cursor for use in pagination. `after` is a group ID that defines your place in the list.
29    #[serde(skip_serializing_if = "Option::is_none")]
30    pub after: Option<String>,
31    /// Specifies the sort order of the returned groups.
32    #[serde(skip_serializing_if = "Option::is_none")]
33    pub order: Option<ListGroupsOrder>,
34}
35
36/// Summary information about a group returned in role assignment responses.
37#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
38pub struct Group {
39    /// The object type, which is always `group`.
40    pub object: String,
41    /// Identifier for the group.
42    pub id: String,
43    /// Display name of the group.
44    pub name: String,
45    /// Unix timestamp (in seconds) when the group was created.
46    pub created_at: u64,
47    /// Whether the group is managed through SCIM.
48    pub scim_managed: bool,
49}
50
51/// Details about an organization group.
52#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
53pub struct GroupResponse {
54    /// Identifier for the group.
55    pub id: String,
56    /// Display name of the group.
57    pub name: String,
58    /// Unix timestamp (in seconds) when the group was created.
59    pub created_at: u64,
60    /// Whether the group is managed through SCIM and controlled by your identity provider.
61    pub is_scim_managed: bool,
62}
63
64/// Paginated list of organization groups.
65#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
66pub struct GroupListResource {
67    /// The object type, which is always `list`.
68    pub object: String,
69    /// Groups returned in the current page.
70    pub data: Vec<GroupResponse>,
71    /// Whether additional groups are available when paginating.
72    pub has_more: bool,
73    /// Cursor to fetch the next page of results, or `null` if there are no more results.
74    pub next: Option<String>,
75}
76
77/// Confirmation payload returned after deleting a group.
78#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
79pub struct GroupDeletedResource {
80    /// The object type, which is always `group.deleted`.
81    pub object: String,
82    /// Identifier of the deleted group.
83    pub id: String,
84    /// Whether the group was deleted.
85    pub deleted: bool,
86}
87
88/// Response returned after updating a group.
89#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
90pub struct GroupResourceWithSuccess {
91    /// Identifier for the group.
92    pub id: String,
93    /// Updated display name for the group.
94    pub name: String,
95    /// Unix timestamp (in seconds) when the group was created.
96    pub created_at: u64,
97    /// Whether the group is managed through SCIM and controlled by your identity provider.
98    pub is_scim_managed: bool,
99}
100
101/// Request payload for creating a new group in the organization.
102#[derive(Debug, Serialize, Deserialize, Builder, Clone, PartialEq)]
103#[builder(name = "CreateGroupRequestArgs")]
104#[builder(pattern = "mutable")]
105#[builder(setter(into, strip_option))]
106#[builder(derive(Debug))]
107#[builder(build_fn(error = "OpenAIError"))]
108pub struct CreateGroupBody {
109    /// Human readable name for the group.
110    pub name: String,
111}
112
113/// Request payload for updating the details of an existing group.
114#[derive(Debug, Serialize, Deserialize, Builder, Clone, PartialEq)]
115#[builder(name = "UpdateGroupRequestArgs")]
116#[builder(pattern = "mutable")]
117#[builder(setter(into, strip_option))]
118#[builder(derive(Debug))]
119#[builder(build_fn(error = "OpenAIError"))]
120pub struct UpdateGroupBody {
121    /// New display name for the group.
122    pub name: String,
123}
124
125/// Request payload for adding a user to a group.
126#[derive(Debug, Serialize, Deserialize, Builder, Clone, PartialEq)]
127#[builder(name = "CreateGroupUserRequestArgs")]
128#[builder(pattern = "mutable")]
129#[builder(setter(into, strip_option))]
130#[builder(derive(Debug))]
131#[builder(build_fn(error = "OpenAIError"))]
132pub struct CreateGroupUserBody {
133    /// Identifier of the user to add to the group.
134    pub user_id: String,
135}
136
137/// Confirmation payload returned after adding a user to a group.
138#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
139pub struct GroupUserAssignment {
140    /// The object type, which is always `group.user`.
141    pub object: String,
142    /// Identifier of the user that was added.
143    pub user_id: String,
144    /// Identifier of the group the user was added to.
145    pub group_id: String,
146}
147
148/// Confirmation payload returned after removing a user from a group.
149#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
150pub struct GroupUserDeletedResource {
151    /// The object type, which is always `group.user.deleted`.
152    pub object: String,
153    /// Whether the group membership was removed.
154    pub deleted: bool,
155}
156
157/// Role assignment linking a group to a role.
158#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
159pub struct GroupRoleAssignment {
160    /// The object type, which is always `group.role`.
161    pub object: String,
162    /// The group.
163    pub group: Group,
164    /// The role.
165    pub role: Role,
166}
167
168/// Paginated list of role assignments for a group.
169#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
170pub struct GroupRoleAssignmentListResource {
171    /// The object type, which is always `list`.
172    pub object: String,
173    /// Role assignments returned in the current page.
174    pub data: Vec<GroupRoleAssignment>,
175    /// Whether additional assignments are available when paginating.
176    pub has_more: bool,
177    /// Cursor to fetch the next page of results, or `null` when there are no more assignments.
178    pub next: Option<String>,
179}
180
181/// Request payload for assigning a role to a group.
182#[derive(Debug, Serialize, Deserialize, Builder, Clone, PartialEq)]
183#[builder(name = "AssignGroupRoleRequestArgs")]
184#[builder(pattern = "mutable")]
185#[builder(setter(into, strip_option))]
186#[builder(derive(Debug))]
187#[builder(build_fn(error = "OpenAIError"))]
188pub struct PublicAssignOrganizationGroupRoleBody {
189    /// Identifier of the role to assign.
190    pub role_id: String,
191}
192
193/// Paginated list of user objects returned when inspecting group membership.
194#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
195pub struct UserListResource {
196    /// The object type, which is always `list`.
197    pub object: String,
198    /// Users in the current page.
199    pub data: Vec<User>,
200    /// Whether more users are available when paginating.
201    pub has_more: bool,
202    /// Cursor to fetch the next page of results, or `null` when no further users are available.
203    pub next: Option<String>,
204}