ebbmem_client_generated/apis/
tasks_api.rs1use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17
18#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum CancelTaskError {
22 Status400(models::ErrorResponse),
23 Status401(models::ErrorResponse),
24 Status403(models::ErrorResponse),
25 Status404(models::ErrorResponse),
26 Status429(models::ErrorResponse),
27 Status422(models::HttpValidationError),
28 UnknownValue(serde_json::Value),
29}
30
31#[derive(Debug, Clone, Serialize, Deserialize)]
33#[serde(untagged)]
34pub enum CancelTaskByPostError {
35 Status400(models::ErrorResponse),
36 Status401(models::ErrorResponse),
37 Status403(models::ErrorResponse),
38 Status404(models::ErrorResponse),
39 Status429(models::ErrorResponse),
40 Status422(models::HttpValidationError),
41 UnknownValue(serde_json::Value),
42}
43
44#[derive(Debug, Clone, Serialize, Deserialize)]
46#[serde(untagged)]
47pub enum GetTaskError {
48 Status400(models::ErrorResponse),
49 Status401(models::ErrorResponse),
50 Status403(models::ErrorResponse),
51 Status404(models::ErrorResponse),
52 Status429(models::ErrorResponse),
53 Status422(models::HttpValidationError),
54 UnknownValue(serde_json::Value),
55}
56
57#[derive(Debug, Clone, Serialize, Deserialize)]
59#[serde(untagged)]
60pub enum ListTasksError {
61 Status400(models::ErrorResponse),
62 Status401(models::ErrorResponse),
63 Status403(models::ErrorResponse),
64 Status404(models::ErrorResponse),
65 Status429(models::ErrorResponse),
66 Status422(models::HttpValidationError),
67 UnknownValue(serde_json::Value),
68}
69
70
71pub async fn cancel_task(configuration: &configuration::Configuration, task_id: &str) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<CancelTaskError>> {
73 let p_path_task_id = task_id;
75
76 let uri_str = format!("{}/api/v1/tasks/{task_id}", configuration.base_path, task_id=crate::apis::urlencode(p_path_task_id));
77 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
78
79 if let Some(ref user_agent) = configuration.user_agent {
80 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
81 }
82 if let Some(ref token) = configuration.bearer_access_token {
83 req_builder = req_builder.bearer_auth(token.to_owned());
84 };
85 if let Some(ref apikey) = configuration.api_key {
86 let key = apikey.key.clone();
87 let value = match apikey.prefix {
88 Some(ref prefix) => format!("{} {}", prefix, key),
89 None => key,
90 };
91 req_builder = req_builder.header("X-API-Key", value);
92 };
93
94 let req = req_builder.build()?;
95 let resp = configuration.client.execute(req).await?;
96
97 let status = resp.status();
98 let content_type = resp
99 .headers()
100 .get("content-type")
101 .and_then(|v| v.to_str().ok())
102 .unwrap_or("application/octet-stream");
103 let content_type = super::ContentType::from(content_type);
104
105 if !status.is_client_error() && !status.is_server_error() {
106 let content = resp.text().await?;
107 match content_type {
108 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
109 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`"))),
110 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<String, serde_json::Value>`")))),
111 }
112 } else {
113 let content = resp.text().await?;
114 let entity: Option<CancelTaskError> = serde_json::from_str(&content).ok();
115 Err(Error::ResponseError(ResponseContent { status, content, entity }))
116 }
117}
118
119pub async fn cancel_task_by_post(configuration: &configuration::Configuration, task_id: &str) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<CancelTaskByPostError>> {
121 let p_path_task_id = task_id;
123
124 let uri_str = format!("{}/api/v1/tasks/{task_id}/cancel", configuration.base_path, task_id=crate::apis::urlencode(p_path_task_id));
125 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
126
127 if let Some(ref user_agent) = configuration.user_agent {
128 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
129 }
130 if let Some(ref token) = configuration.bearer_access_token {
131 req_builder = req_builder.bearer_auth(token.to_owned());
132 };
133 if let Some(ref apikey) = configuration.api_key {
134 let key = apikey.key.clone();
135 let value = match apikey.prefix {
136 Some(ref prefix) => format!("{} {}", prefix, key),
137 None => key,
138 };
139 req_builder = req_builder.header("X-API-Key", value);
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<String, serde_json::Value>`"))),
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<String, serde_json::Value>`")))),
159 }
160 } else {
161 let content = resp.text().await?;
162 let entity: Option<CancelTaskByPostError> = serde_json::from_str(&content).ok();
163 Err(Error::ResponseError(ResponseContent { status, content, entity }))
164 }
165}
166
167pub async fn get_task(configuration: &configuration::Configuration, task_id: &str) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<GetTaskError>> {
169 let p_path_task_id = task_id;
171
172 let uri_str = format!("{}/api/v1/tasks/{task_id}", configuration.base_path, task_id=crate::apis::urlencode(p_path_task_id));
173 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
174
175 if let Some(ref user_agent) = configuration.user_agent {
176 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
177 }
178 if let Some(ref token) = configuration.bearer_access_token {
179 req_builder = req_builder.bearer_auth(token.to_owned());
180 };
181 if let Some(ref apikey) = configuration.api_key {
182 let key = apikey.key.clone();
183 let value = match apikey.prefix {
184 Some(ref prefix) => format!("{} {}", prefix, key),
185 None => key,
186 };
187 req_builder = req_builder.header("X-API-Key", value);
188 };
189
190 let req = req_builder.build()?;
191 let resp = configuration.client.execute(req).await?;
192
193 let status = resp.status();
194 let content_type = resp
195 .headers()
196 .get("content-type")
197 .and_then(|v| v.to_str().ok())
198 .unwrap_or("application/octet-stream");
199 let content_type = super::ContentType::from(content_type);
200
201 if !status.is_client_error() && !status.is_server_error() {
202 let content = resp.text().await?;
203 match content_type {
204 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
205 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`"))),
206 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<String, serde_json::Value>`")))),
207 }
208 } else {
209 let content = resp.text().await?;
210 let entity: Option<GetTaskError> = serde_json::from_str(&content).ok();
211 Err(Error::ResponseError(ResponseContent { status, content, entity }))
212 }
213}
214
215pub async fn list_tasks(configuration: &configuration::Configuration, status: Option<&str>, namespace: Option<&str>, limit: Option<i32>) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<ListTasksError>> {
217 let p_query_status = status;
219 let p_query_namespace = namespace;
220 let p_query_limit = limit;
221
222 let uri_str = format!("{}/api/v1/tasks", configuration.base_path);
223 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
224
225 if let Some(ref param_value) = p_query_status {
226 req_builder = req_builder.query(&[("status", ¶m_value.to_string())]);
227 }
228 if let Some(ref param_value) = p_query_namespace {
229 req_builder = req_builder.query(&[("namespace", ¶m_value.to_string())]);
230 }
231 if let Some(ref param_value) = p_query_limit {
232 req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
233 }
234 if let Some(ref user_agent) = configuration.user_agent {
235 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
236 }
237 if let Some(ref token) = configuration.bearer_access_token {
238 req_builder = req_builder.bearer_auth(token.to_owned());
239 };
240 if let Some(ref apikey) = configuration.api_key {
241 let key = apikey.key.clone();
242 let value = match apikey.prefix {
243 Some(ref prefix) => format!("{} {}", prefix, key),
244 None => key,
245 };
246 req_builder = req_builder.header("X-API-Key", value);
247 };
248
249 let req = req_builder.build()?;
250 let resp = configuration.client.execute(req).await?;
251
252 let status = resp.status();
253 let content_type = resp
254 .headers()
255 .get("content-type")
256 .and_then(|v| v.to_str().ok())
257 .unwrap_or("application/octet-stream");
258 let content_type = super::ContentType::from(content_type);
259
260 if !status.is_client_error() && !status.is_server_error() {
261 let content = resp.text().await?;
262 match content_type {
263 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
264 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`"))),
265 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<String, serde_json::Value>`")))),
266 }
267 } else {
268 let content = resp.text().await?;
269 let entity: Option<ListTasksError> = serde_json::from_str(&content).ok();
270 Err(Error::ResponseError(ResponseContent { status, content, entity }))
271 }
272}
273