1use std::sync::Arc;
12
13use async_trait::async_trait;
14use reqwest;
15use serde::{de::Error as _, Deserialize, Serialize};
16
17use super::{configuration, Error};
18use crate::{
19 apis::{ContentType, ResponseContent},
20 models,
21};
22
23#[async_trait]
24pub trait TestSuitesApi: Send + Sync {
25 async fn test_suite_controller_create<'create_test_suite_dto>(
27 &self,
28 create_test_suite_dto: models::CreateTestSuiteDto,
29 ) -> Result<models::TestSuite, Error<TestSuiteControllerCreateError>>;
30
31 async fn test_suite_controller_find_all_paginated<
33 'page,
34 'sort_order,
35 'limit,
36 'created_at_gt,
37 'created_at_lt,
38 'created_at_ge,
39 'created_at_le,
40 'updated_at_gt,
41 'updated_at_lt,
42 'updated_at_ge,
43 'updated_at_le,
44 >(
45 &self,
46 page: Option<f64>,
47 sort_order: Option<&'sort_order str>,
48 limit: Option<f64>,
49 created_at_gt: Option<String>,
50 created_at_lt: Option<String>,
51 created_at_ge: Option<String>,
52 created_at_le: Option<String>,
53 updated_at_gt: Option<String>,
54 updated_at_lt: Option<String>,
55 updated_at_ge: Option<String>,
56 updated_at_le: Option<String>,
57 ) -> Result<models::TestSuitesPaginatedResponse, Error<TestSuiteControllerFindAllPaginatedError>>;
58
59 async fn test_suite_controller_find_one<'id>(
61 &self,
62 id: &'id str,
63 ) -> Result<models::TestSuite, Error<TestSuiteControllerFindOneError>>;
64
65 async fn test_suite_controller_remove<'id>(
67 &self,
68 id: &'id str,
69 ) -> Result<models::TestSuite, Error<TestSuiteControllerRemoveError>>;
70
71 async fn test_suite_controller_update<'id, 'update_test_suite_dto>(
73 &self,
74 id: &'id str,
75 update_test_suite_dto: models::UpdateTestSuiteDto,
76 ) -> Result<models::TestSuite, Error<TestSuiteControllerUpdateError>>;
77}
78
79pub struct TestSuitesApiClient {
80 configuration: Arc<configuration::Configuration>,
81}
82
83impl TestSuitesApiClient {
84 pub fn new(configuration: Arc<configuration::Configuration>) -> Self {
85 Self { configuration }
86 }
87}
88
89#[async_trait]
90impl TestSuitesApi for TestSuitesApiClient {
91 async fn test_suite_controller_create<'create_test_suite_dto>(
92 &self,
93 create_test_suite_dto: models::CreateTestSuiteDto,
94 ) -> Result<models::TestSuite, Error<TestSuiteControllerCreateError>> {
95 let local_var_configuration = &self.configuration;
96
97 let local_var_client = &local_var_configuration.client;
98
99 let local_var_uri_str = format!("{}/test-suite", local_var_configuration.base_path);
100 let mut local_var_req_builder =
101 local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
102
103 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
104 local_var_req_builder = local_var_req_builder
105 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
106 }
107 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
108 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
109 };
110 local_var_req_builder = local_var_req_builder.json(&create_test_suite_dto);
111
112 let local_var_req = local_var_req_builder.build()?;
113 let local_var_resp = local_var_client.execute(local_var_req).await?;
114
115 let local_var_status = local_var_resp.status();
116 let local_var_content_type = local_var_resp
117 .headers()
118 .get("content-type")
119 .and_then(|v| v.to_str().ok())
120 .unwrap_or("application/octet-stream");
121 let local_var_content_type = super::ContentType::from(local_var_content_type);
122 let local_var_content = local_var_resp.text().await?;
123
124 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
125 match local_var_content_type {
126 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
127 ContentType::Text => {
128 return Err(Error::from(serde_json::Error::custom(
129 "Received `text/plain` content type response that cannot be converted to \
130 `models::TestSuite`",
131 )))
132 }
133 ContentType::Unsupported(local_var_unknown_type) => {
134 return Err(Error::from(serde_json::Error::custom(format!(
135 "Received `{local_var_unknown_type}` content type response that cannot be \
136 converted to `models::TestSuite`"
137 ))))
138 }
139 }
140 } else {
141 let local_var_entity: Option<TestSuiteControllerCreateError> =
142 serde_json::from_str(&local_var_content).ok();
143 let local_var_error = ResponseContent {
144 status: local_var_status,
145 content: local_var_content,
146 entity: local_var_entity,
147 };
148 Err(Error::ResponseError(local_var_error))
149 }
150 }
151
152 async fn test_suite_controller_find_all_paginated<
153 'page,
154 'sort_order,
155 'limit,
156 'created_at_gt,
157 'created_at_lt,
158 'created_at_ge,
159 'created_at_le,
160 'updated_at_gt,
161 'updated_at_lt,
162 'updated_at_ge,
163 'updated_at_le,
164 >(
165 &self,
166 page: Option<f64>,
167 sort_order: Option<&'sort_order str>,
168 limit: Option<f64>,
169 created_at_gt: Option<String>,
170 created_at_lt: Option<String>,
171 created_at_ge: Option<String>,
172 created_at_le: Option<String>,
173 updated_at_gt: Option<String>,
174 updated_at_lt: Option<String>,
175 updated_at_ge: Option<String>,
176 updated_at_le: Option<String>,
177 ) -> Result<models::TestSuitesPaginatedResponse, Error<TestSuiteControllerFindAllPaginatedError>>
178 {
179 let local_var_configuration = &self.configuration;
180
181 let local_var_client = &local_var_configuration.client;
182
183 let local_var_uri_str = format!("{}/test-suite", local_var_configuration.base_path);
184 let mut local_var_req_builder =
185 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
186
187 if let Some(ref local_var_str) = page {
188 local_var_req_builder =
189 local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
190 }
191 if let Some(ref local_var_str) = sort_order {
192 local_var_req_builder =
193 local_var_req_builder.query(&[("sortOrder", &local_var_str.to_string())]);
194 }
195 if let Some(ref local_var_str) = limit {
196 local_var_req_builder =
197 local_var_req_builder.query(&[("limit", &local_var_str.to_string())]);
198 }
199 if let Some(ref local_var_str) = created_at_gt {
200 local_var_req_builder =
201 local_var_req_builder.query(&[("createdAtGt", &local_var_str.to_string())]);
202 }
203 if let Some(ref local_var_str) = created_at_lt {
204 local_var_req_builder =
205 local_var_req_builder.query(&[("createdAtLt", &local_var_str.to_string())]);
206 }
207 if let Some(ref local_var_str) = created_at_ge {
208 local_var_req_builder =
209 local_var_req_builder.query(&[("createdAtGe", &local_var_str.to_string())]);
210 }
211 if let Some(ref local_var_str) = created_at_le {
212 local_var_req_builder =
213 local_var_req_builder.query(&[("createdAtLe", &local_var_str.to_string())]);
214 }
215 if let Some(ref local_var_str) = updated_at_gt {
216 local_var_req_builder =
217 local_var_req_builder.query(&[("updatedAtGt", &local_var_str.to_string())]);
218 }
219 if let Some(ref local_var_str) = updated_at_lt {
220 local_var_req_builder =
221 local_var_req_builder.query(&[("updatedAtLt", &local_var_str.to_string())]);
222 }
223 if let Some(ref local_var_str) = updated_at_ge {
224 local_var_req_builder =
225 local_var_req_builder.query(&[("updatedAtGe", &local_var_str.to_string())]);
226 }
227 if let Some(ref local_var_str) = updated_at_le {
228 local_var_req_builder =
229 local_var_req_builder.query(&[("updatedAtLe", &local_var_str.to_string())]);
230 }
231 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
232 local_var_req_builder = local_var_req_builder
233 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
234 }
235 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
236 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
237 };
238
239 let local_var_req = local_var_req_builder.build()?;
240 let local_var_resp = local_var_client.execute(local_var_req).await?;
241
242 let local_var_status = local_var_resp.status();
243 let local_var_content_type = local_var_resp
244 .headers()
245 .get("content-type")
246 .and_then(|v| v.to_str().ok())
247 .unwrap_or("application/octet-stream");
248 let local_var_content_type = super::ContentType::from(local_var_content_type);
249 let local_var_content = local_var_resp.text().await?;
250
251 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
252 match local_var_content_type {
253 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
254 ContentType::Text => {
255 return Err(Error::from(serde_json::Error::custom(
256 "Received `text/plain` content type response that cannot be converted to \
257 `models::TestSuitesPaginatedResponse`",
258 )))
259 }
260 ContentType::Unsupported(local_var_unknown_type) => {
261 return Err(Error::from(serde_json::Error::custom(format!(
262 "Received `{local_var_unknown_type}` content type response that cannot be \
263 converted to `models::TestSuitesPaginatedResponse`"
264 ))))
265 }
266 }
267 } else {
268 let local_var_entity: Option<TestSuiteControllerFindAllPaginatedError> =
269 serde_json::from_str(&local_var_content).ok();
270 let local_var_error = ResponseContent {
271 status: local_var_status,
272 content: local_var_content,
273 entity: local_var_entity,
274 };
275 Err(Error::ResponseError(local_var_error))
276 }
277 }
278
279 async fn test_suite_controller_find_one<'id>(
280 &self,
281 id: &'id str,
282 ) -> Result<models::TestSuite, Error<TestSuiteControllerFindOneError>> {
283 let local_var_configuration = &self.configuration;
284
285 let local_var_client = &local_var_configuration.client;
286
287 let local_var_uri_str = format!(
288 "{}/test-suite/{id}",
289 local_var_configuration.base_path,
290 id = crate::apis::urlencode(id)
291 );
292 let mut local_var_req_builder =
293 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
294
295 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
296 local_var_req_builder = local_var_req_builder
297 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
298 }
299 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
300 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
301 };
302
303 let local_var_req = local_var_req_builder.build()?;
304 let local_var_resp = local_var_client.execute(local_var_req).await?;
305
306 let local_var_status = local_var_resp.status();
307 let local_var_content_type = local_var_resp
308 .headers()
309 .get("content-type")
310 .and_then(|v| v.to_str().ok())
311 .unwrap_or("application/octet-stream");
312 let local_var_content_type = super::ContentType::from(local_var_content_type);
313 let local_var_content = local_var_resp.text().await?;
314
315 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
316 match local_var_content_type {
317 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
318 ContentType::Text => {
319 return Err(Error::from(serde_json::Error::custom(
320 "Received `text/plain` content type response that cannot be converted to \
321 `models::TestSuite`",
322 )))
323 }
324 ContentType::Unsupported(local_var_unknown_type) => {
325 return Err(Error::from(serde_json::Error::custom(format!(
326 "Received `{local_var_unknown_type}` content type response that cannot be \
327 converted to `models::TestSuite`"
328 ))))
329 }
330 }
331 } else {
332 let local_var_entity: Option<TestSuiteControllerFindOneError> =
333 serde_json::from_str(&local_var_content).ok();
334 let local_var_error = ResponseContent {
335 status: local_var_status,
336 content: local_var_content,
337 entity: local_var_entity,
338 };
339 Err(Error::ResponseError(local_var_error))
340 }
341 }
342
343 async fn test_suite_controller_remove<'id>(
344 &self,
345 id: &'id str,
346 ) -> Result<models::TestSuite, Error<TestSuiteControllerRemoveError>> {
347 let local_var_configuration = &self.configuration;
348
349 let local_var_client = &local_var_configuration.client;
350
351 let local_var_uri_str = format!(
352 "{}/test-suite/{id}",
353 local_var_configuration.base_path,
354 id = crate::apis::urlencode(id)
355 );
356 let mut local_var_req_builder =
357 local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
358
359 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
360 local_var_req_builder = local_var_req_builder
361 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
362 }
363 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
364 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
365 };
366
367 let local_var_req = local_var_req_builder.build()?;
368 let local_var_resp = local_var_client.execute(local_var_req).await?;
369
370 let local_var_status = local_var_resp.status();
371 let local_var_content_type = local_var_resp
372 .headers()
373 .get("content-type")
374 .and_then(|v| v.to_str().ok())
375 .unwrap_or("application/octet-stream");
376 let local_var_content_type = super::ContentType::from(local_var_content_type);
377 let local_var_content = local_var_resp.text().await?;
378
379 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
380 match local_var_content_type {
381 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
382 ContentType::Text => {
383 return Err(Error::from(serde_json::Error::custom(
384 "Received `text/plain` content type response that cannot be converted to \
385 `models::TestSuite`",
386 )))
387 }
388 ContentType::Unsupported(local_var_unknown_type) => {
389 return Err(Error::from(serde_json::Error::custom(format!(
390 "Received `{local_var_unknown_type}` content type response that cannot be \
391 converted to `models::TestSuite`"
392 ))))
393 }
394 }
395 } else {
396 let local_var_entity: Option<TestSuiteControllerRemoveError> =
397 serde_json::from_str(&local_var_content).ok();
398 let local_var_error = ResponseContent {
399 status: local_var_status,
400 content: local_var_content,
401 entity: local_var_entity,
402 };
403 Err(Error::ResponseError(local_var_error))
404 }
405 }
406
407 async fn test_suite_controller_update<'id, 'update_test_suite_dto>(
408 &self,
409 id: &'id str,
410 update_test_suite_dto: models::UpdateTestSuiteDto,
411 ) -> Result<models::TestSuite, Error<TestSuiteControllerUpdateError>> {
412 let local_var_configuration = &self.configuration;
413
414 let local_var_client = &local_var_configuration.client;
415
416 let local_var_uri_str = format!(
417 "{}/test-suite/{id}",
418 local_var_configuration.base_path,
419 id = crate::apis::urlencode(id)
420 );
421 let mut local_var_req_builder =
422 local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str());
423
424 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
425 local_var_req_builder = local_var_req_builder
426 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
427 }
428 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
429 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
430 };
431 local_var_req_builder = local_var_req_builder.json(&update_test_suite_dto);
432
433 let local_var_req = local_var_req_builder.build()?;
434 let local_var_resp = local_var_client.execute(local_var_req).await?;
435
436 let local_var_status = local_var_resp.status();
437 let local_var_content_type = local_var_resp
438 .headers()
439 .get("content-type")
440 .and_then(|v| v.to_str().ok())
441 .unwrap_or("application/octet-stream");
442 let local_var_content_type = super::ContentType::from(local_var_content_type);
443 let local_var_content = local_var_resp.text().await?;
444
445 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
446 match local_var_content_type {
447 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
448 ContentType::Text => {
449 return Err(Error::from(serde_json::Error::custom(
450 "Received `text/plain` content type response that cannot be converted to \
451 `models::TestSuite`",
452 )))
453 }
454 ContentType::Unsupported(local_var_unknown_type) => {
455 return Err(Error::from(serde_json::Error::custom(format!(
456 "Received `{local_var_unknown_type}` content type response that cannot be \
457 converted to `models::TestSuite`"
458 ))))
459 }
460 }
461 } else {
462 let local_var_entity: Option<TestSuiteControllerUpdateError> =
463 serde_json::from_str(&local_var_content).ok();
464 let local_var_error = ResponseContent {
465 status: local_var_status,
466 content: local_var_content,
467 entity: local_var_entity,
468 };
469 Err(Error::ResponseError(local_var_error))
470 }
471 }
472}
473
474#[derive(Debug, Clone, Serialize, Deserialize)]
476#[serde(untagged)]
477pub enum TestSuiteControllerCreateError {
478 UnknownValue(serde_json::Value),
479}
480
481#[derive(Debug, Clone, Serialize, Deserialize)]
483#[serde(untagged)]
484pub enum TestSuiteControllerFindAllPaginatedError {
485 UnknownValue(serde_json::Value),
486}
487
488#[derive(Debug, Clone, Serialize, Deserialize)]
490#[serde(untagged)]
491pub enum TestSuiteControllerFindOneError {
492 UnknownValue(serde_json::Value),
493}
494
495#[derive(Debug, Clone, Serialize, Deserialize)]
497#[serde(untagged)]
498pub enum TestSuiteControllerRemoveError {
499 UnknownValue(serde_json::Value),
500}
501
502#[derive(Debug, Clone, Serialize, Deserialize)]
504#[serde(untagged)]
505pub enum TestSuiteControllerUpdateError {
506 UnknownValue(serde_json::Value),
507}