uarp_sdk/generated/api/projects.rs
1// Code generated by @uarp/codegen from spec/openapi.json. DO NOT EDIT.
2//!
3//! Projects — a workspace grouping agents, sessions and files
4
5#![allow(unused_imports, clippy::too_many_arguments)]
6
7use reqwest::Method;
8use serde::{Deserialize, Serialize};
9
10use crate::client::{Client, Request, NO_BODY, NO_QUERY};
11use crate::error::Result;
12use crate::generated::models;
13use crate::multipart::{field_text, FilePart};
14use crate::util::encode_path;
15
16/// Query and header parameters for `listProjects`.
17#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
18pub struct ListProjectsParams {
19 /// `true` returns the archived projects instead of the live ones.
20 #[serde(default, skip_serializing_if = "Option::is_none")]
21 pub archived: Option<models::GetRunChangedFiles>,
22}
23
24/// Projects — a workspace grouping agents, sessions and files
25#[derive(Debug, Clone)]
26pub struct ProjectsApi {
27 pub(crate) client: Client,
28}
29
30impl Client {
31 /// Projects — a workspace grouping agents, sessions and files
32 pub fn projects(&self) -> ProjectsApi {
33 ProjectsApi { client: self.clone() }
34 }
35}
36
37impl ProjectsApi {
38 /// Create a project
39 ///
40 /// File ids that do not resolve in this tenant are dropped rather than rejected, so the stored
41 /// project never claims a file the agent cannot read.
42 ///
43 /// `POST /api/v1/projects`
44 pub async fn create(&self, body: &models::CreateProjectRequest) -> Result<models::Project> {
45 self.client
46 .request_json(Request {
47 method: Method::POST,
48 path: "/api/v1/projects".to_string(),
49 query: NO_QUERY,
50 body: Some(body),
51 headers: Vec::new(),
52 idempotent: true,
53 })
54 .await
55 }
56
57 /// Delete a project
58 ///
59 /// Unlinks rather than cascades: every chat filed under the project survives and is simply no
60 /// longer in it. `chats_kept` is how many were unfiled. Deleting a folder that takes the work
61 /// with it is how people lose things they cannot get back.
62 ///
63 /// `DELETE /api/v1/projects/{projectId}`
64 pub async fn delete(&self, project_id: &str) -> Result<models::DeleteProjectResponse> {
65 self.client
66 .request_json(Request {
67 method: Method::DELETE,
68 path: format!("/api/v1/projects/{}", encode_path(project_id)),
69 query: NO_QUERY,
70 body: NO_BODY,
71 headers: Vec::new(),
72 idempotent: true,
73 })
74 .await
75 }
76
77 /// Read a project with its chats
78 ///
79 /// Includes the chats filed under it and the caller's own access level. A project the caller
80 /// may not open answers **404, not 403** — the existence of a private project is itself
81 /// private.
82 ///
83 /// `GET /api/v1/projects/{projectId}`
84 pub async fn get(&self, project_id: &str) -> Result<models::ProjectDetail> {
85 self.client
86 .request_json(Request {
87 method: Method::GET,
88 path: format!("/api/v1/projects/{}", encode_path(project_id)),
89 query: NO_QUERY,
90 body: NO_BODY,
91 headers: Vec::new(),
92 idempotent: false,
93 })
94 .await
95 }
96
97 /// List projects
98 ///
99 /// Live projects, most recently updated first. Archived ones leave this list — ask for them
100 /// with `archived=true`. `archived_count` is always the number of archived projects the caller
101 /// can see, whichever list was requested, so a client can badge the Archived section without a
102 /// second call.
103 ///
104 /// `GET /api/v1/projects`
105 pub async fn list(&self, params: &ListProjectsParams) -> Result<models::ListProjectsResponse> {
106 self.client
107 .request_json(Request {
108 method: Method::GET,
109 path: "/api/v1/projects".to_string(),
110 query: Some(params),
111 body: NO_BODY,
112 headers: Vec::new(),
113 idempotent: false,
114 })
115 .await
116 }
117
118 /// Edit a project
119 ///
120 /// Only fields present in the body are changed. `archived_at` is the archive switch: an ISO
121 /// timestamp archives, and **null restores** — the field must be sent explicitly, because an
122 /// omitted key means “leave as is”.
123 ///
124 /// View access is 403; no access is a project the caller may not open answers **404, not 403**
125 /// — the existence of a private project is itself private.
126 ///
127 /// Turning on `private` for a project with no recorded owner and no signed-in caller is refused
128 /// with 400: it would leave nobody able to open it. Signing in stamps the caller as owner at
129 /// that moment.
130 ///
131 /// `PATCH /api/v1/projects/{projectId}`
132 pub async fn update(&self, project_id: &str, body: &models::UpdateProjectRequest) -> Result<models::Project> {
133 self.client
134 .request_json(Request {
135 method: Method::PATCH,
136 path: format!("/api/v1/projects/{}", encode_path(project_id)),
137 query: NO_QUERY,
138 body: Some(body),
139 headers: Vec::new(),
140 idempotent: true,
141 })
142 .await
143 }
144}