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 AppError {
22 UnknownValue(serde_json::Value),
23}
24
25#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum App2FaError {
29 UnknownValue(serde_json::Value),
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum App2FaCheckError {
36 UnknownValue(serde_json::Value),
37}
38
39#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum AppCheckVersionError {
43 UnknownValue(serde_json::Value),
44}
45
46#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum AppDeleteError {
50 UnknownValue(serde_json::Value),
51}
52
53#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum AppInfoError {
57 UnknownValue(serde_json::Value),
58}
59
60#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum AppPostError {
64 UnknownValue(serde_json::Value),
65}
66
67#[derive(Debug, Clone, Serialize, Deserialize)]
69#[serde(untagged)]
70pub enum AppPutError {
71 UnknownValue(serde_json::Value),
72}
73
74#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(untagged)]
77pub enum AppTransferError {
78 UnknownValue(serde_json::Value),
79}
80
81#[derive(Debug, Clone, Serialize, Deserialize)]
83#[serde(untagged)]
84pub enum AppsError {
85 UnknownValue(serde_json::Value),
86}
87
88
89pub async fn app(configuration: &configuration::Configuration, app_key: &str) -> Result<models::AppApiResponse, Error<AppError>> {
91 let p_app_key = app_key;
93
94 let uri_str = format!("{}/App/{appKey}", configuration.base_path, appKey=crate::apis::urlencode(p_app_key));
95 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
96
97 if let Some(ref user_agent) = configuration.user_agent {
98 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
99 }
100 if let Some(ref token) = configuration.bearer_access_token {
101 req_builder = req_builder.bearer_auth(token.to_owned());
102 };
103
104 let req = req_builder.build()?;
105 let resp = configuration.client.execute(req).await?;
106
107 let status = resp.status();
108 let content_type = resp
109 .headers()
110 .get("content-type")
111 .and_then(|v| v.to_str().ok())
112 .unwrap_or("application/octet-stream");
113 let content_type = super::ContentType::from(content_type);
114
115 if !status.is_client_error() && !status.is_server_error() {
116 let content = resp.text().await?;
117 match content_type {
118 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
119 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AppApiResponse`"))),
120 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::AppApiResponse`")))),
121 }
122 } else {
123 let content = resp.text().await?;
124 let entity: Option<AppError> = serde_json::from_str(&content).ok();
125 Err(Error::ResponseError(ResponseContent { status, content, entity }))
126 }
127}
128
129pub async fn app2_fa(configuration: &configuration::Configuration, app_key: &str) -> Result<models::SetupCodeApiResponse, Error<App2FaError>> {
131 let p_app_key = app_key;
133
134 let uri_str = format!("{}/App/{appKey}/2FA", configuration.base_path, appKey=crate::apis::urlencode(p_app_key));
135 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
136
137 if let Some(ref user_agent) = configuration.user_agent {
138 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
139 }
140 if let Some(ref token) = configuration.bearer_access_token {
141 req_builder = req_builder.bearer_auth(token.to_owned());
142 };
143
144 let req = req_builder.build()?;
145 let resp = configuration.client.execute(req).await?;
146
147 let status = resp.status();
148 let content_type = resp
149 .headers()
150 .get("content-type")
151 .and_then(|v| v.to_str().ok())
152 .unwrap_or("application/octet-stream");
153 let content_type = super::ContentType::from(content_type);
154
155 if !status.is_client_error() && !status.is_server_error() {
156 let content = resp.text().await?;
157 match content_type {
158 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
159 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SetupCodeApiResponse`"))),
160 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::SetupCodeApiResponse`")))),
161 }
162 } else {
163 let content = resp.text().await?;
164 let entity: Option<App2FaError> = serde_json::from_str(&content).ok();
165 Err(Error::ResponseError(ResponseContent { status, content, entity }))
166 }
167}
168
169pub async fn app2_fa_check(configuration: &configuration::Configuration, app_key: &str, code: Option<&str>) -> Result<models::BooleanApiResponse, Error<App2FaCheckError>> {
171 let p_app_key = app_key;
173 let p_code = code;
174
175 let uri_str = format!("{}/App/{appKey}/2FACheck", configuration.base_path, appKey=crate::apis::urlencode(p_app_key));
176 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
177
178 if let Some(ref param_value) = p_code {
179 req_builder = req_builder.query(&[("code", ¶m_value.to_string())]);
180 }
181 if let Some(ref user_agent) = configuration.user_agent {
182 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
183 }
184 if let Some(ref token) = configuration.bearer_access_token {
185 req_builder = req_builder.bearer_auth(token.to_owned());
186 };
187
188 let req = req_builder.build()?;
189 let resp = configuration.client.execute(req).await?;
190
191 let status = resp.status();
192 let content_type = resp
193 .headers()
194 .get("content-type")
195 .and_then(|v| v.to_str().ok())
196 .unwrap_or("application/octet-stream");
197 let content_type = super::ContentType::from(content_type);
198
199 if !status.is_client_error() && !status.is_server_error() {
200 let content = resp.text().await?;
201 match content_type {
202 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
203 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::BooleanApiResponse`"))),
204 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::BooleanApiResponse`")))),
205 }
206 } else {
207 let content = resp.text().await?;
208 let entity: Option<App2FaCheckError> = serde_json::from_str(&content).ok();
209 Err(Error::ResponseError(ResponseContent { status, content, entity }))
210 }
211}
212
213pub async fn app_check_version(configuration: &configuration::Configuration, app_key: &str, check_only: Option<bool>) -> Result<models::AppCheckVersionResultApiResponse, Error<AppCheckVersionError>> {
215 let p_app_key = app_key;
217 let p_check_only = check_only;
218
219 let uri_str = format!("{}/App/{appKey}/CheckVersion", configuration.base_path, appKey=crate::apis::urlencode(p_app_key));
220 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
221
222 if let Some(ref param_value) = p_check_only {
223 req_builder = req_builder.query(&[("checkOnly", ¶m_value.to_string())]);
224 }
225 if let Some(ref user_agent) = configuration.user_agent {
226 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
227 }
228 if let Some(ref token) = configuration.bearer_access_token {
229 req_builder = req_builder.bearer_auth(token.to_owned());
230 };
231
232 let req = req_builder.build()?;
233 let resp = configuration.client.execute(req).await?;
234
235 let status = resp.status();
236 let content_type = resp
237 .headers()
238 .get("content-type")
239 .and_then(|v| v.to_str().ok())
240 .unwrap_or("application/octet-stream");
241 let content_type = super::ContentType::from(content_type);
242
243 if !status.is_client_error() && !status.is_server_error() {
244 let content = resp.text().await?;
245 match content_type {
246 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
247 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AppCheckVersionResultApiResponse`"))),
248 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::AppCheckVersionResultApiResponse`")))),
249 }
250 } else {
251 let content = resp.text().await?;
252 let entity: Option<AppCheckVersionError> = serde_json::from_str(&content).ok();
253 Err(Error::ResponseError(ResponseContent { status, content, entity }))
254 }
255}
256
257pub async fn app_delete(configuration: &configuration::Configuration, app_key: &str) -> Result<models::BooleanApiResponse, Error<AppDeleteError>> {
259 let p_app_key = app_key;
261
262 let uri_str = format!("{}/App/{appKey}", configuration.base_path, appKey=crate::apis::urlencode(p_app_key));
263 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
264
265 if let Some(ref user_agent) = configuration.user_agent {
266 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
267 }
268 if let Some(ref token) = configuration.bearer_access_token {
269 req_builder = req_builder.bearer_auth(token.to_owned());
270 };
271
272 let req = req_builder.build()?;
273 let resp = configuration.client.execute(req).await?;
274
275 let status = resp.status();
276 let content_type = resp
277 .headers()
278 .get("content-type")
279 .and_then(|v| v.to_str().ok())
280 .unwrap_or("application/octet-stream");
281 let content_type = super::ContentType::from(content_type);
282
283 if !status.is_client_error() && !status.is_server_error() {
284 let content = resp.text().await?;
285 match content_type {
286 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
287 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::BooleanApiResponse`"))),
288 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::BooleanApiResponse`")))),
289 }
290 } else {
291 let content = resp.text().await?;
292 let entity: Option<AppDeleteError> = serde_json::from_str(&content).ok();
293 Err(Error::ResponseError(ResponseContent { status, content, entity }))
294 }
295}
296
297pub async fn app_info(configuration: &configuration::Configuration, app_key: &str, prop_code: Option<&str>) -> Result<models::AppInfoResultApiResponse, Error<AppInfoError>> {
299 let p_app_key = app_key;
301 let p_prop_code = prop_code;
302
303 let uri_str = format!("{}/App/{appKey}/Info", configuration.base_path, appKey=crate::apis::urlencode(p_app_key));
304 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
305
306 if let Some(ref param_value) = p_prop_code {
307 req_builder = req_builder.query(&[("propCode", ¶m_value.to_string())]);
308 }
309 if let Some(ref user_agent) = configuration.user_agent {
310 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
311 }
312 if let Some(ref token) = configuration.bearer_access_token {
313 req_builder = req_builder.bearer_auth(token.to_owned());
314 };
315
316 let req = req_builder.build()?;
317 let resp = configuration.client.execute(req).await?;
318
319 let status = resp.status();
320 let content_type = resp
321 .headers()
322 .get("content-type")
323 .and_then(|v| v.to_str().ok())
324 .unwrap_or("application/octet-stream");
325 let content_type = super::ContentType::from(content_type);
326
327 if !status.is_client_error() && !status.is_server_error() {
328 let content = resp.text().await?;
329 match content_type {
330 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
331 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AppInfoResultApiResponse`"))),
332 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::AppInfoResultApiResponse`")))),
333 }
334 } else {
335 let content = resp.text().await?;
336 let entity: Option<AppInfoError> = serde_json::from_str(&content).ok();
337 Err(Error::ResponseError(ResponseContent { status, content, entity }))
338 }
339}
340
341pub async fn app_post(configuration: &configuration::Configuration, app: Option<models::App>) -> Result<models::AppPostResultApiResponse, Error<AppPostError>> {
343 let p_app = app;
345
346 let uri_str = format!("{}/App", configuration.base_path);
347 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
348
349 if let Some(ref user_agent) = configuration.user_agent {
350 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
351 }
352 if let Some(ref token) = configuration.bearer_access_token {
353 req_builder = req_builder.bearer_auth(token.to_owned());
354 };
355 req_builder = req_builder.json(&p_app);
356
357 let req = req_builder.build()?;
358 let resp = configuration.client.execute(req).await?;
359
360 let status = resp.status();
361 let content_type = resp
362 .headers()
363 .get("content-type")
364 .and_then(|v| v.to_str().ok())
365 .unwrap_or("application/octet-stream");
366 let content_type = super::ContentType::from(content_type);
367
368 if !status.is_client_error() && !status.is_server_error() {
369 let content = resp.text().await?;
370 match content_type {
371 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
372 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AppPostResultApiResponse`"))),
373 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::AppPostResultApiResponse`")))),
374 }
375 } else {
376 let content = resp.text().await?;
377 let entity: Option<AppPostError> = serde_json::from_str(&content).ok();
378 Err(Error::ResponseError(ResponseContent { status, content, entity }))
379 }
380}
381
382pub async fn app_put(configuration: &configuration::Configuration, app_key: &str, app: Option<models::App>) -> Result<models::BooleanApiResponse, Error<AppPutError>> {
384 let p_app_key = app_key;
386 let p_app = app;
387
388 let uri_str = format!("{}/App/{appKey}", configuration.base_path, appKey=crate::apis::urlencode(p_app_key));
389 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
390
391 if let Some(ref user_agent) = configuration.user_agent {
392 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
393 }
394 if let Some(ref token) = configuration.bearer_access_token {
395 req_builder = req_builder.bearer_auth(token.to_owned());
396 };
397 req_builder = req_builder.json(&p_app);
398
399 let req = req_builder.build()?;
400 let resp = configuration.client.execute(req).await?;
401
402 let status = resp.status();
403 let content_type = resp
404 .headers()
405 .get("content-type")
406 .and_then(|v| v.to_str().ok())
407 .unwrap_or("application/octet-stream");
408 let content_type = super::ContentType::from(content_type);
409
410 if !status.is_client_error() && !status.is_server_error() {
411 let content = resp.text().await?;
412 match content_type {
413 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
414 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::BooleanApiResponse`"))),
415 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::BooleanApiResponse`")))),
416 }
417 } else {
418 let content = resp.text().await?;
419 let entity: Option<AppPutError> = serde_json::from_str(&content).ok();
420 Err(Error::ResponseError(ResponseContent { status, content, entity }))
421 }
422}
423
424pub async fn app_transfer(configuration: &configuration::Configuration, app_key: &str, project_id: Option<i64>) -> Result<models::AppApiResponse, Error<AppTransferError>> {
426 let p_app_key = app_key;
428 let p_project_id = project_id;
429
430 let uri_str = format!("{}/App/{appKey}/Transfer", configuration.base_path, appKey=crate::apis::urlencode(p_app_key));
431 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
432
433 if let Some(ref param_value) = p_project_id {
434 req_builder = req_builder.query(&[("projectId", ¶m_value.to_string())]);
435 }
436 if let Some(ref user_agent) = configuration.user_agent {
437 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
438 }
439 if let Some(ref token) = configuration.bearer_access_token {
440 req_builder = req_builder.bearer_auth(token.to_owned());
441 };
442
443 let req = req_builder.build()?;
444 let resp = configuration.client.execute(req).await?;
445
446 let status = resp.status();
447 let content_type = resp
448 .headers()
449 .get("content-type")
450 .and_then(|v| v.to_str().ok())
451 .unwrap_or("application/octet-stream");
452 let content_type = super::ContentType::from(content_type);
453
454 if !status.is_client_error() && !status.is_server_error() {
455 let content = resp.text().await?;
456 match content_type {
457 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
458 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AppApiResponse`"))),
459 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::AppApiResponse`")))),
460 }
461 } else {
462 let content = resp.text().await?;
463 let entity: Option<AppTransferError> = serde_json::from_str(&content).ok();
464 Err(Error::ResponseError(ResponseContent { status, content, entity }))
465 }
466}
467
468pub async fn apps(configuration: &configuration::Configuration, project_id: Option<i64>, skip: Option<i32>, take: Option<i32>) -> Result<models::AppListResultApiResponse, Error<AppsError>> {
470 let p_project_id = project_id;
472 let p_skip = skip;
473 let p_take = take;
474
475 let uri_str = format!("{}/App", configuration.base_path);
476 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
477
478 if let Some(ref param_value) = p_project_id {
479 req_builder = req_builder.query(&[("projectId", ¶m_value.to_string())]);
480 }
481 if let Some(ref param_value) = p_skip {
482 req_builder = req_builder.query(&[("skip", ¶m_value.to_string())]);
483 }
484 if let Some(ref param_value) = p_take {
485 req_builder = req_builder.query(&[("take", ¶m_value.to_string())]);
486 }
487 if let Some(ref user_agent) = configuration.user_agent {
488 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
489 }
490 if let Some(ref token) = configuration.bearer_access_token {
491 req_builder = req_builder.bearer_auth(token.to_owned());
492 };
493
494 let req = req_builder.build()?;
495 let resp = configuration.client.execute(req).await?;
496
497 let status = resp.status();
498 let content_type = resp
499 .headers()
500 .get("content-type")
501 .and_then(|v| v.to_str().ok())
502 .unwrap_or("application/octet-stream");
503 let content_type = super::ContentType::from(content_type);
504
505 if !status.is_client_error() && !status.is_server_error() {
506 let content = resp.text().await?;
507 match content_type {
508 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
509 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AppListResultApiResponse`"))),
510 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::AppListResultApiResponse`")))),
511 }
512 } else {
513 let content = resp.text().await?;
514 let entity: Option<AppsError> = serde_json::from_str(&content).ok();
515 Err(Error::ResponseError(ResponseContent { status, content, entity }))
516 }
517}
518