Skip to main content

spatio_sdk/apis/
terminal_api.rs

1/*
2 * SpatioAPI
3 *
4 * The REST API that owns every resource in your Spatio workspace: notes, sheets, slides, tasks, calendar events, mail, chat, files, and contacts. SpatioMCP wraps this API; Spatio Desktop reads from it. You can call it directly from your own code.  All requests must be authenticated with a Personal Access Token (`Authorization: Bearer pat_...`) or an OAuth 2.1 access token, and use HTTPS.  Official SDKs (MIT, generated from this spec on every release):  - TypeScript: https://github.com/spatio-labs/spatio-ts (`npm install @spatio-labs/spatio-ts`) - Python: https://github.com/spatio-labs/spatio-py (`pip install spatio-sdk`) - Go: https://github.com/spatio-labs/spatio-go (`go get github.com/spatio-labs/spatio-go`)  This specification is generated from the platform-service Go source on every push to `main`. The spec, not hand-written documentation, is the source of truth: server stubs and SDKs are generated from it, and any drift between the spec and the running service fails CI. 
5 *
6 * The version of the OpenAPI document: v1
7 * Contact: hello@spatio.app
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17
18/// struct for typed errors of method [`create_terminal_session`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum CreateTerminalSessionError {
22    Status401(models::ApiError),
23    UnknownValue(serde_json::Value),
24}
25
26/// struct for typed errors of method [`delete_terminal_session`]
27#[derive(Debug, Clone, Serialize, Deserialize)]
28#[serde(untagged)]
29pub enum DeleteTerminalSessionError {
30    Status401(models::ApiError),
31    UnknownValue(serde_json::Value),
32}
33
34/// struct for typed errors of method [`get_terminal_session`]
35#[derive(Debug, Clone, Serialize, Deserialize)]
36#[serde(untagged)]
37pub enum GetTerminalSessionError {
38    Status401(models::ApiError),
39    Status404(models::ApiError),
40    UnknownValue(serde_json::Value),
41}
42
43/// struct for typed errors of method [`list_terminal_sessions`]
44#[derive(Debug, Clone, Serialize, Deserialize)]
45#[serde(untagged)]
46pub enum ListTerminalSessionsError {
47    Status401(models::ApiError),
48    UnknownValue(serde_json::Value),
49}
50
51/// struct for typed errors of method [`update_terminal_session`]
52#[derive(Debug, Clone, Serialize, Deserialize)]
53#[serde(untagged)]
54pub enum UpdateTerminalSessionError {
55    Status401(models::ApiError),
56    UnknownValue(serde_json::Value),
57}
58
59
60pub async fn create_terminal_session(configuration: &configuration::Configuration, request_body: std::collections::HashMap<String, serde_json::Value>) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<CreateTerminalSessionError>> {
61    // add a prefix to parameters to efficiently prevent name collisions
62    let p_body_request_body = request_body;
63
64    let uri_str = format!("{}/v1/terminal/sessions", configuration.base_path);
65    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
66
67    if let Some(ref user_agent) = configuration.user_agent {
68        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
69    }
70    if let Some(ref token) = configuration.bearer_access_token {
71        req_builder = req_builder.bearer_auth(token.to_owned());
72    };
73    req_builder = req_builder.json(&p_body_request_body);
74
75    let req = req_builder.build()?;
76    let resp = configuration.client.execute(req).await?;
77
78    let status = resp.status();
79    let content_type = resp
80        .headers()
81        .get("content-type")
82        .and_then(|v| v.to_str().ok())
83        .unwrap_or("application/octet-stream");
84    let content_type = super::ContentType::from(content_type);
85
86    if !status.is_client_error() && !status.is_server_error() {
87        let content = resp.text().await?;
88        match content_type {
89            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
90            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap&lt;String, serde_json::Value&gt;`"))),
91            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap&lt;String, serde_json::Value&gt;`")))),
92        }
93    } else {
94        let content = resp.text().await?;
95        let entity: Option<CreateTerminalSessionError> = serde_json::from_str(&content).ok();
96        Err(Error::ResponseError(ResponseContent { status, content, entity }))
97    }
98}
99
100pub async fn delete_terminal_session(configuration: &configuration::Configuration, id: &str) -> Result<(), Error<DeleteTerminalSessionError>> {
101    // add a prefix to parameters to efficiently prevent name collisions
102    let p_path_id = id;
103
104    let uri_str = format!("{}/v1/terminal/sessions/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
105    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
106
107    if let Some(ref user_agent) = configuration.user_agent {
108        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
109    }
110    if let Some(ref token) = configuration.bearer_access_token {
111        req_builder = req_builder.bearer_auth(token.to_owned());
112    };
113
114    let req = req_builder.build()?;
115    let resp = configuration.client.execute(req).await?;
116
117    let status = resp.status();
118
119    if !status.is_client_error() && !status.is_server_error() {
120        Ok(())
121    } else {
122        let content = resp.text().await?;
123        let entity: Option<DeleteTerminalSessionError> = serde_json::from_str(&content).ok();
124        Err(Error::ResponseError(ResponseContent { status, content, entity }))
125    }
126}
127
128pub async fn get_terminal_session(configuration: &configuration::Configuration, id: &str) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<GetTerminalSessionError>> {
129    // add a prefix to parameters to efficiently prevent name collisions
130    let p_path_id = id;
131
132    let uri_str = format!("{}/v1/terminal/sessions/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
133    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
134
135    if let Some(ref user_agent) = configuration.user_agent {
136        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
137    }
138    if let Some(ref token) = configuration.bearer_access_token {
139        req_builder = req_builder.bearer_auth(token.to_owned());
140    };
141
142    let req = req_builder.build()?;
143    let resp = configuration.client.execute(req).await?;
144
145    let status = resp.status();
146    let content_type = resp
147        .headers()
148        .get("content-type")
149        .and_then(|v| v.to_str().ok())
150        .unwrap_or("application/octet-stream");
151    let content_type = super::ContentType::from(content_type);
152
153    if !status.is_client_error() && !status.is_server_error() {
154        let content = resp.text().await?;
155        match content_type {
156            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
157            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap&lt;String, serde_json::Value&gt;`"))),
158            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap&lt;String, serde_json::Value&gt;`")))),
159        }
160    } else {
161        let content = resp.text().await?;
162        let entity: Option<GetTerminalSessionError> = serde_json::from_str(&content).ok();
163        Err(Error::ResponseError(ResponseContent { status, content, entity }))
164    }
165}
166
167pub async fn list_terminal_sessions(configuration: &configuration::Configuration, ) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<ListTerminalSessionsError>> {
168
169    let uri_str = format!("{}/v1/terminal/sessions", configuration.base_path);
170    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
171
172    if let Some(ref user_agent) = configuration.user_agent {
173        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
174    }
175    if let Some(ref token) = configuration.bearer_access_token {
176        req_builder = req_builder.bearer_auth(token.to_owned());
177    };
178
179    let req = req_builder.build()?;
180    let resp = configuration.client.execute(req).await?;
181
182    let status = resp.status();
183    let content_type = resp
184        .headers()
185        .get("content-type")
186        .and_then(|v| v.to_str().ok())
187        .unwrap_or("application/octet-stream");
188    let content_type = super::ContentType::from(content_type);
189
190    if !status.is_client_error() && !status.is_server_error() {
191        let content = resp.text().await?;
192        match content_type {
193            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
194            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap&lt;String, serde_json::Value&gt;`"))),
195            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap&lt;String, serde_json::Value&gt;`")))),
196        }
197    } else {
198        let content = resp.text().await?;
199        let entity: Option<ListTerminalSessionsError> = serde_json::from_str(&content).ok();
200        Err(Error::ResponseError(ResponseContent { status, content, entity }))
201    }
202}
203
204pub async fn update_terminal_session(configuration: &configuration::Configuration, id: &str, request_body: std::collections::HashMap<String, serde_json::Value>) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<UpdateTerminalSessionError>> {
205    // add a prefix to parameters to efficiently prevent name collisions
206    let p_path_id = id;
207    let p_body_request_body = request_body;
208
209    let uri_str = format!("{}/v1/terminal/sessions/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
210    let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
211
212    if let Some(ref user_agent) = configuration.user_agent {
213        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
214    }
215    if let Some(ref token) = configuration.bearer_access_token {
216        req_builder = req_builder.bearer_auth(token.to_owned());
217    };
218    req_builder = req_builder.json(&p_body_request_body);
219
220    let req = req_builder.build()?;
221    let resp = configuration.client.execute(req).await?;
222
223    let status = resp.status();
224    let content_type = resp
225        .headers()
226        .get("content-type")
227        .and_then(|v| v.to_str().ok())
228        .unwrap_or("application/octet-stream");
229    let content_type = super::ContentType::from(content_type);
230
231    if !status.is_client_error() && !status.is_server_error() {
232        let content = resp.text().await?;
233        match content_type {
234            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
235            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap&lt;String, serde_json::Value&gt;`"))),
236            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap&lt;String, serde_json::Value&gt;`")))),
237        }
238    } else {
239        let content = resp.text().await?;
240        let entity: Option<UpdateTerminalSessionError> = serde_json::from_str(&content).ok();
241        Err(Error::ResponseError(ResponseContent { status, content, entity }))
242    }
243}
244