opencode_sdk/http/
permissions.rs1use crate::error::Result;
6use crate::http::HttpClient;
7use crate::types::api::PermissionReplyResponse;
8use crate::types::permission::{PermissionReplyRequest, PermissionRequest};
9use reqwest::Method;
10
11#[derive(Clone)]
13pub struct PermissionsApi {
14 http: HttpClient,
15}
16
17impl PermissionsApi {
18 pub fn new(http: HttpClient) -> Self {
20 Self { http }
21 }
22
23 pub async fn list(&self) -> Result<Vec<PermissionRequest>> {
29 self.http
30 .request_json(Method::GET, "/permission", None)
31 .await
32 }
33
34 pub async fn reply(
40 &self,
41 request_id: &str,
42 reply: &PermissionReplyRequest,
43 ) -> Result<PermissionReplyResponse> {
44 let body = serde_json::to_value(reply)?;
45 self.http
46 .request_json(
47 Method::POST,
48 &format!("/permission/{}/reply", request_id),
49 Some(body),
50 )
51 .await
52 }
53}