opencode_sdk/http/
project.rs1use crate::error::Result;
6use crate::http::HttpClient;
7use crate::types::project::{Project, UpdateProjectRequest};
8use reqwest::Method;
9
10#[derive(Clone)]
12pub struct ProjectApi {
13 http: HttpClient,
14}
15
16impl ProjectApi {
17 pub fn new(http: HttpClient) -> Self {
19 Self { http }
20 }
21
22 pub async fn list(&self) -> Result<Vec<Project>> {
28 self.http.request_json(Method::GET, "/project", None).await
29 }
30
31 pub async fn current(&self) -> Result<Project> {
37 self.http
38 .request_json(Method::GET, "/project/current", None)
39 .await
40 }
41
42 pub async fn update(&self, project_id: &str, req: &UpdateProjectRequest) -> Result<Project> {
48 let body = serde_json::to_value(req)?;
49 self.http
50 .request_json(
51 Method::PATCH,
52 &format!("/project/{}", project_id),
53 Some(body),
54 )
55 .await
56 }
57}