Skip to main content

spatio_sdk/apis/
actions_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 [`execute_action`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum ExecuteActionError {
22    Status401(models::ApiError),
23    UnknownValue(serde_json::Value),
24}
25
26/// struct for typed errors of method [`get_core_action`]
27#[derive(Debug, Clone, Serialize, Deserialize)]
28#[serde(untagged)]
29pub enum GetCoreActionError {
30    Status401(models::ApiError),
31    Status404(models::ApiError),
32    UnknownValue(serde_json::Value),
33}
34
35/// struct for typed errors of method [`list_available_actions`]
36#[derive(Debug, Clone, Serialize, Deserialize)]
37#[serde(untagged)]
38pub enum ListAvailableActionsError {
39    Status401(models::ApiError),
40    UnknownValue(serde_json::Value),
41}
42
43/// struct for typed errors of method [`list_core_actions`]
44#[derive(Debug, Clone, Serialize, Deserialize)]
45#[serde(untagged)]
46pub enum ListCoreActionsError {
47    Status401(models::ApiError),
48    UnknownValue(serde_json::Value),
49}
50
51/// struct for typed errors of method [`list_core_actions_by_platform`]
52#[derive(Debug, Clone, Serialize, Deserialize)]
53#[serde(untagged)]
54pub enum ListCoreActionsByPlatformError {
55    Status401(models::ApiError),
56    UnknownValue(serde_json::Value),
57}
58
59/// struct for typed errors of method [`list_platform_actions`]
60#[derive(Debug, Clone, Serialize, Deserialize)]
61#[serde(untagged)]
62pub enum ListPlatformActionsError {
63    Status401(models::ApiError),
64    UnknownValue(serde_json::Value),
65}
66
67
68pub async fn execute_action(configuration: &configuration::Configuration, execute_action_request: models::ExecuteActionRequest) -> Result<models::ExecuteActionResponse, Error<ExecuteActionError>> {
69    // add a prefix to parameters to efficiently prevent name collisions
70    let p_body_execute_action_request = execute_action_request;
71
72    let uri_str = format!("{}/v1/actions/execute", configuration.base_path);
73    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
74
75    if let Some(ref user_agent) = configuration.user_agent {
76        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
77    }
78    if let Some(ref token) = configuration.bearer_access_token {
79        req_builder = req_builder.bearer_auth(token.to_owned());
80    };
81    req_builder = req_builder.json(&p_body_execute_action_request);
82
83    let req = req_builder.build()?;
84    let resp = configuration.client.execute(req).await?;
85
86    let status = resp.status();
87    let content_type = resp
88        .headers()
89        .get("content-type")
90        .and_then(|v| v.to_str().ok())
91        .unwrap_or("application/octet-stream");
92    let content_type = super::ContentType::from(content_type);
93
94    if !status.is_client_error() && !status.is_server_error() {
95        let content = resp.text().await?;
96        match content_type {
97            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
98            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ExecuteActionResponse`"))),
99            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ExecuteActionResponse`")))),
100        }
101    } else {
102        let content = resp.text().await?;
103        let entity: Option<ExecuteActionError> = serde_json::from_str(&content).ok();
104        Err(Error::ResponseError(ResponseContent { status, content, entity }))
105    }
106}
107
108pub async fn get_core_action(configuration: &configuration::Configuration, id: &str) -> Result<models::CoreAction, Error<GetCoreActionError>> {
109    // add a prefix to parameters to efficiently prevent name collisions
110    let p_path_id = id;
111
112    let uri_str = format!("{}/v1/actions/core/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
113    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
114
115    if let Some(ref user_agent) = configuration.user_agent {
116        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
117    }
118    if let Some(ref token) = configuration.bearer_access_token {
119        req_builder = req_builder.bearer_auth(token.to_owned());
120    };
121
122    let req = req_builder.build()?;
123    let resp = configuration.client.execute(req).await?;
124
125    let status = resp.status();
126    let content_type = resp
127        .headers()
128        .get("content-type")
129        .and_then(|v| v.to_str().ok())
130        .unwrap_or("application/octet-stream");
131    let content_type = super::ContentType::from(content_type);
132
133    if !status.is_client_error() && !status.is_server_error() {
134        let content = resp.text().await?;
135        match content_type {
136            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
137            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CoreAction`"))),
138            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CoreAction`")))),
139        }
140    } else {
141        let content = resp.text().await?;
142        let entity: Option<GetCoreActionError> = serde_json::from_str(&content).ok();
143        Err(Error::ResponseError(ResponseContent { status, content, entity }))
144    }
145}
146
147pub async fn list_available_actions(configuration: &configuration::Configuration, ) -> Result<Vec<models::ActionDescriptor>, Error<ListAvailableActionsError>> {
148
149    let uri_str = format!("{}/v1/actions/available", configuration.base_path);
150    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
151
152    if let Some(ref user_agent) = configuration.user_agent {
153        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
154    }
155    if let Some(ref token) = configuration.bearer_access_token {
156        req_builder = req_builder.bearer_auth(token.to_owned());
157    };
158
159    let req = req_builder.build()?;
160    let resp = configuration.client.execute(req).await?;
161
162    let status = resp.status();
163    let content_type = resp
164        .headers()
165        .get("content-type")
166        .and_then(|v| v.to_str().ok())
167        .unwrap_or("application/octet-stream");
168    let content_type = super::ContentType::from(content_type);
169
170    if !status.is_client_error() && !status.is_server_error() {
171        let content = resp.text().await?;
172        match content_type {
173            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
174            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::ActionDescriptor&gt;`"))),
175            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec&lt;models::ActionDescriptor&gt;`")))),
176        }
177    } else {
178        let content = resp.text().await?;
179        let entity: Option<ListAvailableActionsError> = serde_json::from_str(&content).ok();
180        Err(Error::ResponseError(ResponseContent { status, content, entity }))
181    }
182}
183
184pub async fn list_core_actions(configuration: &configuration::Configuration, ) -> Result<models::CoreActionListResponse, Error<ListCoreActionsError>> {
185
186    let uri_str = format!("{}/v1/actions/core", configuration.base_path);
187    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
188
189    if let Some(ref user_agent) = configuration.user_agent {
190        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
191    }
192    if let Some(ref token) = configuration.bearer_access_token {
193        req_builder = req_builder.bearer_auth(token.to_owned());
194    };
195
196    let req = req_builder.build()?;
197    let resp = configuration.client.execute(req).await?;
198
199    let status = resp.status();
200    let content_type = resp
201        .headers()
202        .get("content-type")
203        .and_then(|v| v.to_str().ok())
204        .unwrap_or("application/octet-stream");
205    let content_type = super::ContentType::from(content_type);
206
207    if !status.is_client_error() && !status.is_server_error() {
208        let content = resp.text().await?;
209        match content_type {
210            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
211            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CoreActionListResponse`"))),
212            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CoreActionListResponse`")))),
213        }
214    } else {
215        let content = resp.text().await?;
216        let entity: Option<ListCoreActionsError> = serde_json::from_str(&content).ok();
217        Err(Error::ResponseError(ResponseContent { status, content, entity }))
218    }
219}
220
221pub async fn list_core_actions_by_platform(configuration: &configuration::Configuration, platform: &str) -> Result<models::CoreActionListResponse, Error<ListCoreActionsByPlatformError>> {
222    // add a prefix to parameters to efficiently prevent name collisions
223    let p_path_platform = platform;
224
225    let uri_str = format!("{}/v1/actions/core/platform/{platform}", configuration.base_path, platform=crate::apis::urlencode(p_path_platform));
226    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
227
228    if let Some(ref user_agent) = configuration.user_agent {
229        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
230    }
231    if let Some(ref token) = configuration.bearer_access_token {
232        req_builder = req_builder.bearer_auth(token.to_owned());
233    };
234
235    let req = req_builder.build()?;
236    let resp = configuration.client.execute(req).await?;
237
238    let status = resp.status();
239    let content_type = resp
240        .headers()
241        .get("content-type")
242        .and_then(|v| v.to_str().ok())
243        .unwrap_or("application/octet-stream");
244    let content_type = super::ContentType::from(content_type);
245
246    if !status.is_client_error() && !status.is_server_error() {
247        let content = resp.text().await?;
248        match content_type {
249            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
250            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CoreActionListResponse`"))),
251            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CoreActionListResponse`")))),
252        }
253    } else {
254        let content = resp.text().await?;
255        let entity: Option<ListCoreActionsByPlatformError> = serde_json::from_str(&content).ok();
256        Err(Error::ResponseError(ResponseContent { status, content, entity }))
257    }
258}
259
260pub async fn list_platform_actions(configuration: &configuration::Configuration, platform: &str) -> Result<Vec<models::ActionDescriptor>, Error<ListPlatformActionsError>> {
261    // add a prefix to parameters to efficiently prevent name collisions
262    let p_path_platform = platform;
263
264    let uri_str = format!("{}/v1/actions/platform/{platform}", configuration.base_path, platform=crate::apis::urlencode(p_path_platform));
265    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
266
267    if let Some(ref user_agent) = configuration.user_agent {
268        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
269    }
270    if let Some(ref token) = configuration.bearer_access_token {
271        req_builder = req_builder.bearer_auth(token.to_owned());
272    };
273
274    let req = req_builder.build()?;
275    let resp = configuration.client.execute(req).await?;
276
277    let status = resp.status();
278    let content_type = resp
279        .headers()
280        .get("content-type")
281        .and_then(|v| v.to_str().ok())
282        .unwrap_or("application/octet-stream");
283    let content_type = super::ContentType::from(content_type);
284
285    if !status.is_client_error() && !status.is_server_error() {
286        let content = resp.text().await?;
287        match content_type {
288            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
289            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::ActionDescriptor&gt;`"))),
290            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec&lt;models::ActionDescriptor&gt;`")))),
291        }
292    } else {
293        let content = resp.text().await?;
294        let entity: Option<ListPlatformActionsError> = serde_json::from_str(&content).ok();
295        Err(Error::ResponseError(ResponseContent { status, content, entity }))
296    }
297}
298