async_openai/types/admin/
projects.rs

1use crate::types::OpenAIError;
2use derive_builder::Builder;
3use serde::{Deserialize, Serialize};
4
5/// Query parameters for listing projects.
6#[derive(Debug, Serialize, Default, Clone, Builder, PartialEq)]
7#[builder(name = "ListProjectsQueryArgs")]
8#[builder(pattern = "mutable")]
9#[builder(setter(into, strip_option), default)]
10#[builder(derive(Debug))]
11#[builder(build_fn(error = "OpenAIError"))]
12pub struct ListProjectsQuery {
13    /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.
14    #[serde(skip_serializing_if = "Option::is_none")]
15    pub limit: Option<u32>,
16    /// A cursor for use in pagination. `after` is an object ID that defines your place in the list.
17    #[serde(skip_serializing_if = "Option::is_none")]
18    pub after: Option<String>,
19    /// If `true` returns all projects including those that have been `archived`. Archived projects are not included by default.
20    #[serde(skip_serializing_if = "Option::is_none")]
21    pub include_archived: Option<bool>,
22}
23
24/// `active` or `archived`
25#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq)]
26#[serde(rename_all = "lowercase")]
27pub enum ProjectStatus {
28    Active,
29    Archived,
30}
31
32/// Represents an individual project.
33#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
34pub struct Project {
35    /// The identifier, which can be referenced in API endpoints
36    pub id: String,
37    /// The object type, which is always `organization.project`
38    pub object: String,
39    /// The name of the project. This appears in reporting.
40    pub name: String,
41    /// The Unix timestamp (in seconds) of when the project was created.
42    pub created_at: u64,
43    /// The Unix timestamp (in seconds) of when the project was archived or `null`.
44    pub archived_at: Option<u64>,
45    /// `active` or `archived`
46    pub status: ProjectStatus,
47}
48
49/// A list of Project objects.
50#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
51pub struct ProjectListResponse {
52    pub object: String,
53    pub data: Vec<Project>,
54    pub first_id: String,
55    pub last_id: String,
56    pub has_more: String,
57}
58
59/// The project create request payload.
60#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Builder)]
61#[builder(name = "ProjectCreateRequestArgs")]
62#[builder(pattern = "mutable")]
63#[builder(setter(into, strip_option))]
64#[builder(derive(Debug))]
65#[builder(build_fn(error = "OpenAIError"))]
66pub struct ProjectCreateRequest {
67    /// The friendly name of the project, this name appears in reports.
68    pub name: String,
69}
70
71/// The project update request payload.
72#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Builder)]
73#[builder(name = "ProjectUpdateRequestArgs")]
74#[builder(pattern = "mutable")]
75#[builder(setter(into, strip_option))]
76#[builder(derive(Debug))]
77#[builder(build_fn(error = "OpenAIError"))]
78pub struct ProjectUpdateRequest {
79    /// The updated name of the project, this name appears in reports.
80    pub name: String,
81}
82
83/// Details about a group's membership in a project.
84#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
85pub struct ProjectGroup {
86    /// The object type, which is always `project.group`.
87    pub object: String,
88    /// Identifier of the project.
89    pub project_id: String,
90    /// Identifier of the group that has access to the project.
91    pub group_id: String,
92    /// Display name of the group.
93    pub group_name: String,
94    /// Unix timestamp (in seconds) when the group was granted project access.
95    pub created_at: u64,
96}
97
98/// Paginated list of groups that have access to a project.
99#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
100pub struct ProjectGroupListResource {
101    /// The object type, which is always `list`.
102    pub object: String,
103    /// Project group memberships returned in the current page.
104    pub data: Vec<ProjectGroup>,
105    /// Whether additional project group memberships are available.
106    pub has_more: bool,
107    /// Cursor to fetch the next page of results, or `null` when there are no more results.
108    pub next: Option<String>,
109}
110
111/// Confirmation payload returned after removing a group from a project.
112#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
113pub struct ProjectGroupDeletedResource {
114    /// The object type, which is always `project.group.deleted`.
115    pub object: String,
116    /// Whether the group membership in the project was removed.
117    pub deleted: bool,
118}
119
120/// Request payload for granting a group access to a project.
121#[derive(Debug, Serialize, Deserialize, Builder, Clone, PartialEq)]
122#[builder(name = "InviteProjectGroupRequestArgs")]
123#[builder(pattern = "mutable")]
124#[builder(setter(into, strip_option))]
125#[builder(derive(Debug))]
126#[builder(build_fn(error = "OpenAIError"))]
127pub struct InviteProjectGroupBody {
128    /// Identifier of the group to add to the project.
129    pub group_id: String,
130    /// Identifier of the project role to grant to the group.
131    pub role: String,
132}