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