openapp_sdk_core/resources/
lan_agent.rs1use std::sync::Arc;
4
5use reqwest::Method;
6
7use super::JsonValue;
8use crate::{
9 error::SdkError,
10 transport::{RequestSpec, Transport},
11};
12
13#[derive(Debug, Clone)]
14pub struct LanAgentClient {
15 transport: Arc<Transport>,
16}
17
18impl LanAgentClient {
19 pub(crate) fn new(transport: Arc<Transport>) -> Self {
20 Self { transport }
21 }
22
23 pub async fn meta(&self) -> Result<JsonValue, SdkError> {
24 self.transport
25 .request_json::<(), JsonValue>(RequestSpec {
26 method: Method::GET,
27 path: "/lan-agent/meta",
28 ..Default::default()
29 })
30 .await
31 }
32
33 pub async fn bootstrap_script(&self) -> Result<JsonValue, SdkError> {
34 self.transport
35 .request_json::<(), JsonValue>(RequestSpec {
36 method: Method::GET,
37 path: "/lan-agent/cli/bootstrap.sh",
38 ..Default::default()
39 })
40 .await
41 }
42
43 pub async fn bootstrap_token(&self, body: &JsonValue) -> Result<JsonValue, SdkError> {
44 self.transport
45 .request_json::<JsonValue, JsonValue>(RequestSpec {
46 method: Method::POST,
47 path: "/lan-agent/cli/bootstrap-token",
48 body: Some(body),
49 ..Default::default()
50 })
51 .await
52 }
53
54 pub async fn token(&self, body: &JsonValue) -> Result<JsonValue, SdkError> {
55 self.transport
56 .request_json::<JsonValue, JsonValue>(RequestSpec {
57 method: Method::POST,
58 path: "/lan-agent/cli/token",
59 body: Some(body),
60 ..Default::default()
61 })
62 .await
63 }
64
65 pub async fn submit_task_spec(
66 &self,
67 integration_id: &str,
68 body: &JsonValue,
69 ) -> Result<JsonValue, SdkError> {
70 let path = format!("/integrations/{integration_id}/lan-agent/task-spec");
71 self.transport
72 .request_json::<JsonValue, JsonValue>(RequestSpec {
73 method: Method::POST,
74 path: &path,
75 body: Some(body),
76 ..Default::default()
77 })
78 .await
79 }
80
81 pub async fn list_tasks(&self, integration_id: &str) -> Result<Vec<JsonValue>, SdkError> {
82 let path = format!("/integrations/{integration_id}/lan-agent/tasks");
83 self.transport
84 .request_json::<(), Vec<JsonValue>>(RequestSpec {
85 method: Method::GET,
86 path: &path,
87 ..Default::default()
88 })
89 .await
90 }
91}