Skip to main content

outfox_openai/spec/admin/projects/
projects_.rs

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