opencode_sdk/http/
config.rs1use crate::error::Result;
6use crate::http::HttpClient;
7use crate::types::config::{Config, ConfigProviders, UpdateConfigRequest};
8use reqwest::Method;
9
10#[derive(Clone)]
12pub struct ConfigApi {
13 http: HttpClient,
14}
15
16impl ConfigApi {
17 pub fn new(http: HttpClient) -> Self {
19 Self { http }
20 }
21
22 pub async fn get(&self) -> Result<Config> {
28 self.http.request_json(Method::GET, "/config", None).await
29 }
30
31 pub async fn update(&self, req: &UpdateConfigRequest) -> Result<Config> {
37 let body = serde_json::to_value(req)?;
38 self.http
39 .request_json(Method::PATCH, "/config", Some(body))
40 .await
41 }
42
43 pub async fn providers(&self) -> Result<ConfigProviders> {
49 self.http
50 .request_json(Method::GET, "/config/providers", None)
51 .await
52 }
53}