Skip to main content

outfox_openai/spec/admin/groups/
groups_.rs

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