1use 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 CreateAppError {
22 Status401(models::ApiError),
23 UnknownValue(serde_json::Value),
24}
25
26#[derive(Debug, Clone, Serialize, Deserialize)]
28#[serde(untagged)]
29pub enum DeleteAppError {
30 Status401(models::ApiError),
31 UnknownValue(serde_json::Value),
32}
33
34#[derive(Debug, Clone, Serialize, Deserialize)]
36#[serde(untagged)]
37pub enum DeleteAppFileError {
38 Status401(models::ApiError),
39 UnknownValue(serde_json::Value),
40}
41
42#[derive(Debug, Clone, Serialize, Deserialize)]
44#[serde(untagged)]
45pub enum GetAppError {
46 Status401(models::ApiError),
47 Status404(models::ApiError),
48 UnknownValue(serde_json::Value),
49}
50
51#[derive(Debug, Clone, Serialize, Deserialize)]
53#[serde(untagged)]
54pub enum ListAppFilesError {
55 Status401(models::ApiError),
56 UnknownValue(serde_json::Value),
57}
58
59#[derive(Debug, Clone, Serialize, Deserialize)]
61#[serde(untagged)]
62pub enum ListAppsError {
63 Status401(models::ApiError),
64 UnknownValue(serde_json::Value),
65}
66
67#[derive(Debug, Clone, Serialize, Deserialize)]
69#[serde(untagged)]
70pub enum ReadAppFileError {
71 Status401(models::ApiError),
72 UnknownValue(serde_json::Value),
73}
74
75#[derive(Debug, Clone, Serialize, Deserialize)]
77#[serde(untagged)]
78pub enum UpdateAppError {
79 Status401(models::ApiError),
80 UnknownValue(serde_json::Value),
81}
82
83#[derive(Debug, Clone, Serialize, Deserialize)]
85#[serde(untagged)]
86pub enum WorkspaceCreateAppError {
87 Status401(models::ApiError),
88 Status403(models::ApiError),
89 UnknownValue(serde_json::Value),
90}
91
92#[derive(Debug, Clone, Serialize, Deserialize)]
94#[serde(untagged)]
95pub enum WorkspaceDeleteAppError {
96 Status401(models::ApiError),
97 Status403(models::ApiError),
98 UnknownValue(serde_json::Value),
99}
100
101#[derive(Debug, Clone, Serialize, Deserialize)]
103#[serde(untagged)]
104pub enum WorkspaceGetAppError {
105 Status401(models::ApiError),
106 Status403(models::ApiError),
107 Status404(models::ApiError),
108 UnknownValue(serde_json::Value),
109}
110
111#[derive(Debug, Clone, Serialize, Deserialize)]
113#[serde(untagged)]
114pub enum WorkspaceListAppsError {
115 Status401(models::ApiError),
116 Status403(models::ApiError),
117 UnknownValue(serde_json::Value),
118}
119
120#[derive(Debug, Clone, Serialize, Deserialize)]
122#[serde(untagged)]
123pub enum WorkspaceUpdateAppError {
124 Status401(models::ApiError),
125 Status403(models::ApiError),
126 UnknownValue(serde_json::Value),
127}
128
129#[derive(Debug, Clone, Serialize, Deserialize)]
131#[serde(untagged)]
132pub enum WriteAppFileError {
133 Status401(models::ApiError),
134 UnknownValue(serde_json::Value),
135}
136
137
138pub async fn create_app(configuration: &configuration::Configuration, create_app_request: models::CreateAppRequest) -> Result<models::App, Error<CreateAppError>> {
139 let p_body_create_app_request = create_app_request;
141
142 let uri_str = format!("{}/v1/apps", configuration.base_path);
143 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
144
145 if let Some(ref user_agent) = configuration.user_agent {
146 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
147 }
148 if let Some(ref token) = configuration.bearer_access_token {
149 req_builder = req_builder.bearer_auth(token.to_owned());
150 };
151 req_builder = req_builder.json(&p_body_create_app_request);
152
153 let req = req_builder.build()?;
154 let resp = configuration.client.execute(req).await?;
155
156 let status = resp.status();
157 let content_type = resp
158 .headers()
159 .get("content-type")
160 .and_then(|v| v.to_str().ok())
161 .unwrap_or("application/octet-stream");
162 let content_type = super::ContentType::from(content_type);
163
164 if !status.is_client_error() && !status.is_server_error() {
165 let content = resp.text().await?;
166 match content_type {
167 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
168 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::App`"))),
169 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::App`")))),
170 }
171 } else {
172 let content = resp.text().await?;
173 let entity: Option<CreateAppError> = serde_json::from_str(&content).ok();
174 Err(Error::ResponseError(ResponseContent { status, content, entity }))
175 }
176}
177
178pub async fn delete_app(configuration: &configuration::Configuration, id: &str) -> Result<(), Error<DeleteAppError>> {
179 let p_path_id = id;
181
182 let uri_str = format!("{}/v1/apps/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
183 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
184
185 if let Some(ref user_agent) = configuration.user_agent {
186 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
187 }
188 if let Some(ref token) = configuration.bearer_access_token {
189 req_builder = req_builder.bearer_auth(token.to_owned());
190 };
191
192 let req = req_builder.build()?;
193 let resp = configuration.client.execute(req).await?;
194
195 let status = resp.status();
196
197 if !status.is_client_error() && !status.is_server_error() {
198 Ok(())
199 } else {
200 let content = resp.text().await?;
201 let entity: Option<DeleteAppError> = serde_json::from_str(&content).ok();
202 Err(Error::ResponseError(ResponseContent { status, content, entity }))
203 }
204}
205
206pub async fn delete_app_file(configuration: &configuration::Configuration, id: &str, path: &str) -> Result<(), Error<DeleteAppFileError>> {
207 let p_path_id = id;
209 let p_query_path = path;
210
211 let uri_str = format!("{}/v1/apps/{id}/file", configuration.base_path, id=crate::apis::urlencode(p_path_id));
212 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
213
214 req_builder = req_builder.query(&[("path", &p_query_path.to_string())]);
215 if let Some(ref user_agent) = configuration.user_agent {
216 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
217 }
218 if let Some(ref token) = configuration.bearer_access_token {
219 req_builder = req_builder.bearer_auth(token.to_owned());
220 };
221
222 let req = req_builder.build()?;
223 let resp = configuration.client.execute(req).await?;
224
225 let status = resp.status();
226
227 if !status.is_client_error() && !status.is_server_error() {
228 Ok(())
229 } else {
230 let content = resp.text().await?;
231 let entity: Option<DeleteAppFileError> = serde_json::from_str(&content).ok();
232 Err(Error::ResponseError(ResponseContent { status, content, entity }))
233 }
234}
235
236pub async fn get_app(configuration: &configuration::Configuration, id: &str) -> Result<models::App, Error<GetAppError>> {
237 let p_path_id = id;
239
240 let uri_str = format!("{}/v1/apps/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
241 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
242
243 if let Some(ref user_agent) = configuration.user_agent {
244 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
245 }
246 if let Some(ref token) = configuration.bearer_access_token {
247 req_builder = req_builder.bearer_auth(token.to_owned());
248 };
249
250 let req = req_builder.build()?;
251 let resp = configuration.client.execute(req).await?;
252
253 let status = resp.status();
254 let content_type = resp
255 .headers()
256 .get("content-type")
257 .and_then(|v| v.to_str().ok())
258 .unwrap_or("application/octet-stream");
259 let content_type = super::ContentType::from(content_type);
260
261 if !status.is_client_error() && !status.is_server_error() {
262 let content = resp.text().await?;
263 match content_type {
264 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
265 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::App`"))),
266 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::App`")))),
267 }
268 } else {
269 let content = resp.text().await?;
270 let entity: Option<GetAppError> = serde_json::from_str(&content).ok();
271 Err(Error::ResponseError(ResponseContent { status, content, entity }))
272 }
273}
274
275pub async fn list_app_files(configuration: &configuration::Configuration, id: &str, path: Option<&str>) -> Result<models::AppFileListResponse, Error<ListAppFilesError>> {
276 let p_path_id = id;
278 let p_query_path = path;
279
280 let uri_str = format!("{}/v1/apps/{id}/files", configuration.base_path, id=crate::apis::urlencode(p_path_id));
281 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
282
283 if let Some(ref param_value) = p_query_path {
284 req_builder = req_builder.query(&[("path", ¶m_value.to_string())]);
285 }
286 if let Some(ref user_agent) = configuration.user_agent {
287 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
288 }
289 if let Some(ref token) = configuration.bearer_access_token {
290 req_builder = req_builder.bearer_auth(token.to_owned());
291 };
292
293 let req = req_builder.build()?;
294 let resp = configuration.client.execute(req).await?;
295
296 let status = resp.status();
297 let content_type = resp
298 .headers()
299 .get("content-type")
300 .and_then(|v| v.to_str().ok())
301 .unwrap_or("application/octet-stream");
302 let content_type = super::ContentType::from(content_type);
303
304 if !status.is_client_error() && !status.is_server_error() {
305 let content = resp.text().await?;
306 match content_type {
307 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
308 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AppFileListResponse`"))),
309 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::AppFileListResponse`")))),
310 }
311 } else {
312 let content = resp.text().await?;
313 let entity: Option<ListAppFilesError> = serde_json::from_str(&content).ok();
314 Err(Error::ResponseError(ResponseContent { status, content, entity }))
315 }
316}
317
318pub async fn list_apps(configuration: &configuration::Configuration, ) -> Result<models::AppListResponse, Error<ListAppsError>> {
319
320 let uri_str = format!("{}/v1/apps", configuration.base_path);
321 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
322
323 if let Some(ref user_agent) = configuration.user_agent {
324 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
325 }
326 if let Some(ref token) = configuration.bearer_access_token {
327 req_builder = req_builder.bearer_auth(token.to_owned());
328 };
329
330 let req = req_builder.build()?;
331 let resp = configuration.client.execute(req).await?;
332
333 let status = resp.status();
334 let content_type = resp
335 .headers()
336 .get("content-type")
337 .and_then(|v| v.to_str().ok())
338 .unwrap_or("application/octet-stream");
339 let content_type = super::ContentType::from(content_type);
340
341 if !status.is_client_error() && !status.is_server_error() {
342 let content = resp.text().await?;
343 match content_type {
344 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
345 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AppListResponse`"))),
346 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::AppListResponse`")))),
347 }
348 } else {
349 let content = resp.text().await?;
350 let entity: Option<ListAppsError> = serde_json::from_str(&content).ok();
351 Err(Error::ResponseError(ResponseContent { status, content, entity }))
352 }
353}
354
355pub async fn read_app_file(configuration: &configuration::Configuration, id: &str, path: &str) -> Result<models::AppFileContentResponse, Error<ReadAppFileError>> {
356 let p_path_id = id;
358 let p_query_path = path;
359
360 let uri_str = format!("{}/v1/apps/{id}/file", configuration.base_path, id=crate::apis::urlencode(p_path_id));
361 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
362
363 req_builder = req_builder.query(&[("path", &p_query_path.to_string())]);
364 if let Some(ref user_agent) = configuration.user_agent {
365 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
366 }
367 if let Some(ref token) = configuration.bearer_access_token {
368 req_builder = req_builder.bearer_auth(token.to_owned());
369 };
370
371 let req = req_builder.build()?;
372 let resp = configuration.client.execute(req).await?;
373
374 let status = resp.status();
375 let content_type = resp
376 .headers()
377 .get("content-type")
378 .and_then(|v| v.to_str().ok())
379 .unwrap_or("application/octet-stream");
380 let content_type = super::ContentType::from(content_type);
381
382 if !status.is_client_error() && !status.is_server_error() {
383 let content = resp.text().await?;
384 match content_type {
385 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
386 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AppFileContentResponse`"))),
387 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::AppFileContentResponse`")))),
388 }
389 } else {
390 let content = resp.text().await?;
391 let entity: Option<ReadAppFileError> = serde_json::from_str(&content).ok();
392 Err(Error::ResponseError(ResponseContent { status, content, entity }))
393 }
394}
395
396pub async fn update_app(configuration: &configuration::Configuration, id: &str, update_app_request: models::UpdateAppRequest) -> Result<models::App, Error<UpdateAppError>> {
397 let p_path_id = id;
399 let p_body_update_app_request = update_app_request;
400
401 let uri_str = format!("{}/v1/apps/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
402 let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
403
404 if let Some(ref user_agent) = configuration.user_agent {
405 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
406 }
407 if let Some(ref token) = configuration.bearer_access_token {
408 req_builder = req_builder.bearer_auth(token.to_owned());
409 };
410 req_builder = req_builder.json(&p_body_update_app_request);
411
412 let req = req_builder.build()?;
413 let resp = configuration.client.execute(req).await?;
414
415 let status = resp.status();
416 let content_type = resp
417 .headers()
418 .get("content-type")
419 .and_then(|v| v.to_str().ok())
420 .unwrap_or("application/octet-stream");
421 let content_type = super::ContentType::from(content_type);
422
423 if !status.is_client_error() && !status.is_server_error() {
424 let content = resp.text().await?;
425 match content_type {
426 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
427 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::App`"))),
428 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::App`")))),
429 }
430 } else {
431 let content = resp.text().await?;
432 let entity: Option<UpdateAppError> = serde_json::from_str(&content).ok();
433 Err(Error::ResponseError(ResponseContent { status, content, entity }))
434 }
435}
436
437pub async fn workspace_create_app(configuration: &configuration::Configuration, org: &str, workspace: &str, request_body: std::collections::HashMap<String, serde_json::Value>) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<WorkspaceCreateAppError>> {
438 let p_path_org = org;
440 let p_path_workspace = workspace;
441 let p_body_request_body = request_body;
442
443 let uri_str = format!("{}/v1/organizations/{org}/workspaces/{workspace}/apps", configuration.base_path, org=crate::apis::urlencode(p_path_org), workspace=crate::apis::urlencode(p_path_workspace));
444 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
445
446 if let Some(ref user_agent) = configuration.user_agent {
447 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
448 }
449 if let Some(ref token) = configuration.bearer_access_token {
450 req_builder = req_builder.bearer_auth(token.to_owned());
451 };
452 req_builder = req_builder.json(&p_body_request_body);
453
454 let req = req_builder.build()?;
455 let resp = configuration.client.execute(req).await?;
456
457 let status = resp.status();
458 let content_type = resp
459 .headers()
460 .get("content-type")
461 .and_then(|v| v.to_str().ok())
462 .unwrap_or("application/octet-stream");
463 let content_type = super::ContentType::from(content_type);
464
465 if !status.is_client_error() && !status.is_server_error() {
466 let content = resp.text().await?;
467 match content_type {
468 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
469 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>`"))),
470 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>`")))),
471 }
472 } else {
473 let content = resp.text().await?;
474 let entity: Option<WorkspaceCreateAppError> = serde_json::from_str(&content).ok();
475 Err(Error::ResponseError(ResponseContent { status, content, entity }))
476 }
477}
478
479pub async fn workspace_delete_app(configuration: &configuration::Configuration, org: &str, workspace: &str, id: &str) -> Result<(), Error<WorkspaceDeleteAppError>> {
480 let p_path_org = org;
482 let p_path_workspace = workspace;
483 let p_path_id = id;
484
485 let uri_str = format!("{}/v1/organizations/{org}/workspaces/{workspace}/apps/{id}", configuration.base_path, org=crate::apis::urlencode(p_path_org), workspace=crate::apis::urlencode(p_path_workspace), id=crate::apis::urlencode(p_path_id));
486 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
487
488 if let Some(ref user_agent) = configuration.user_agent {
489 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
490 }
491 if let Some(ref token) = configuration.bearer_access_token {
492 req_builder = req_builder.bearer_auth(token.to_owned());
493 };
494
495 let req = req_builder.build()?;
496 let resp = configuration.client.execute(req).await?;
497
498 let status = resp.status();
499
500 if !status.is_client_error() && !status.is_server_error() {
501 Ok(())
502 } else {
503 let content = resp.text().await?;
504 let entity: Option<WorkspaceDeleteAppError> = serde_json::from_str(&content).ok();
505 Err(Error::ResponseError(ResponseContent { status, content, entity }))
506 }
507}
508
509pub async fn workspace_get_app(configuration: &configuration::Configuration, org: &str, workspace: &str, id: &str) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<WorkspaceGetAppError>> {
510 let p_path_org = org;
512 let p_path_workspace = workspace;
513 let p_path_id = id;
514
515 let uri_str = format!("{}/v1/organizations/{org}/workspaces/{workspace}/apps/{id}", configuration.base_path, org=crate::apis::urlencode(p_path_org), workspace=crate::apis::urlencode(p_path_workspace), id=crate::apis::urlencode(p_path_id));
516 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
517
518 if let Some(ref user_agent) = configuration.user_agent {
519 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
520 }
521 if let Some(ref token) = configuration.bearer_access_token {
522 req_builder = req_builder.bearer_auth(token.to_owned());
523 };
524
525 let req = req_builder.build()?;
526 let resp = configuration.client.execute(req).await?;
527
528 let status = resp.status();
529 let content_type = resp
530 .headers()
531 .get("content-type")
532 .and_then(|v| v.to_str().ok())
533 .unwrap_or("application/octet-stream");
534 let content_type = super::ContentType::from(content_type);
535
536 if !status.is_client_error() && !status.is_server_error() {
537 let content = resp.text().await?;
538 match content_type {
539 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
540 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>`"))),
541 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>`")))),
542 }
543 } else {
544 let content = resp.text().await?;
545 let entity: Option<WorkspaceGetAppError> = serde_json::from_str(&content).ok();
546 Err(Error::ResponseError(ResponseContent { status, content, entity }))
547 }
548}
549
550pub async fn workspace_list_apps(configuration: &configuration::Configuration, org: &str, workspace: &str) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<WorkspaceListAppsError>> {
551 let p_path_org = org;
553 let p_path_workspace = workspace;
554
555 let uri_str = format!("{}/v1/organizations/{org}/workspaces/{workspace}/apps", configuration.base_path, org=crate::apis::urlencode(p_path_org), workspace=crate::apis::urlencode(p_path_workspace));
556 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
557
558 if let Some(ref user_agent) = configuration.user_agent {
559 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
560 }
561 if let Some(ref token) = configuration.bearer_access_token {
562 req_builder = req_builder.bearer_auth(token.to_owned());
563 };
564
565 let req = req_builder.build()?;
566 let resp = configuration.client.execute(req).await?;
567
568 let status = resp.status();
569 let content_type = resp
570 .headers()
571 .get("content-type")
572 .and_then(|v| v.to_str().ok())
573 .unwrap_or("application/octet-stream");
574 let content_type = super::ContentType::from(content_type);
575
576 if !status.is_client_error() && !status.is_server_error() {
577 let content = resp.text().await?;
578 match content_type {
579 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
580 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>`"))),
581 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>`")))),
582 }
583 } else {
584 let content = resp.text().await?;
585 let entity: Option<WorkspaceListAppsError> = serde_json::from_str(&content).ok();
586 Err(Error::ResponseError(ResponseContent { status, content, entity }))
587 }
588}
589
590pub async fn workspace_update_app(configuration: &configuration::Configuration, org: &str, workspace: &str, id: &str, request_body: std::collections::HashMap<String, serde_json::Value>) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<WorkspaceUpdateAppError>> {
591 let p_path_org = org;
593 let p_path_workspace = workspace;
594 let p_path_id = id;
595 let p_body_request_body = request_body;
596
597 let uri_str = format!("{}/v1/organizations/{org}/workspaces/{workspace}/apps/{id}", configuration.base_path, org=crate::apis::urlencode(p_path_org), workspace=crate::apis::urlencode(p_path_workspace), id=crate::apis::urlencode(p_path_id));
598 let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
599
600 if let Some(ref user_agent) = configuration.user_agent {
601 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
602 }
603 if let Some(ref token) = configuration.bearer_access_token {
604 req_builder = req_builder.bearer_auth(token.to_owned());
605 };
606 req_builder = req_builder.json(&p_body_request_body);
607
608 let req = req_builder.build()?;
609 let resp = configuration.client.execute(req).await?;
610
611 let status = resp.status();
612 let content_type = resp
613 .headers()
614 .get("content-type")
615 .and_then(|v| v.to_str().ok())
616 .unwrap_or("application/octet-stream");
617 let content_type = super::ContentType::from(content_type);
618
619 if !status.is_client_error() && !status.is_server_error() {
620 let content = resp.text().await?;
621 match content_type {
622 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
623 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>`"))),
624 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>`")))),
625 }
626 } else {
627 let content = resp.text().await?;
628 let entity: Option<WorkspaceUpdateAppError> = serde_json::from_str(&content).ok();
629 Err(Error::ResponseError(ResponseContent { status, content, entity }))
630 }
631}
632
633pub async fn write_app_file(configuration: &configuration::Configuration, id: &str, write_app_file_request: models::WriteAppFileRequest) -> Result<(), Error<WriteAppFileError>> {
634 let p_path_id = id;
636 let p_body_write_app_file_request = write_app_file_request;
637
638 let uri_str = format!("{}/v1/apps/{id}/file", configuration.base_path, id=crate::apis::urlencode(p_path_id));
639 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
640
641 if let Some(ref user_agent) = configuration.user_agent {
642 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
643 }
644 if let Some(ref token) = configuration.bearer_access_token {
645 req_builder = req_builder.bearer_auth(token.to_owned());
646 };
647 req_builder = req_builder.json(&p_body_write_app_file_request);
648
649 let req = req_builder.build()?;
650 let resp = configuration.client.execute(req).await?;
651
652 let status = resp.status();
653
654 if !status.is_client_error() && !status.is_server_error() {
655 Ok(())
656 } else {
657 let content = resp.text().await?;
658 let entity: Option<WriteAppFileError> = serde_json::from_str(&content).ok();
659 Err(Error::ResponseError(ResponseContent { status, content, entity }))
660 }
661}
662