1use super::{configuration, ContentType, Error};
12use crate::{apis::ResponseContent, models};
13use reqwest;
14use serde::{de::Error as _, Deserialize, Serialize};
15
16#[derive(Debug, Clone, Serialize, Deserialize)]
18#[serde(untagged)]
19pub enum TestSuiteRunControllerCreateError {
20 UnknownValue(serde_json::Value),
21}
22
23#[derive(Debug, Clone, Serialize, Deserialize)]
25#[serde(untagged)]
26pub enum TestSuiteRunControllerFindAllPaginatedError {
27 UnknownValue(serde_json::Value),
28}
29
30#[derive(Debug, Clone, Serialize, Deserialize)]
32#[serde(untagged)]
33pub enum TestSuiteRunControllerFindOneError {
34 UnknownValue(serde_json::Value),
35}
36
37#[derive(Debug, Clone, Serialize, Deserialize)]
39#[serde(untagged)]
40pub enum TestSuiteRunControllerRemoveError {
41 UnknownValue(serde_json::Value),
42}
43
44#[derive(Debug, Clone, Serialize, Deserialize)]
46#[serde(untagged)]
47pub enum TestSuiteRunControllerUpdateError {
48 UnknownValue(serde_json::Value),
49}
50
51pub async fn test_suite_run_controller_create(
52 configuration: &configuration::Configuration,
53 test_suite_id: &str,
54 create_test_suite_run_dto: models::CreateTestSuiteRunDto,
55) -> Result<models::TestSuiteRun, Error<TestSuiteRunControllerCreateError>> {
56 let p_test_suite_id = test_suite_id;
58 let p_create_test_suite_run_dto = create_test_suite_run_dto;
59
60 let uri_str = format!(
61 "{}/test-suite/{testSuiteId}/run",
62 configuration.base_path,
63 testSuiteId = crate::apis::urlencode(p_test_suite_id)
64 );
65 let mut req_builder = configuration
66 .client
67 .request(reqwest::Method::POST, &uri_str);
68
69 if let Some(ref user_agent) = configuration.user_agent {
70 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
71 }
72 if let Some(ref token) = configuration.bearer_access_token {
73 req_builder = req_builder.bearer_auth(token.to_owned());
74 };
75 req_builder = req_builder.json(&p_create_test_suite_run_dto);
76
77 let req = req_builder.build()?;
78 let resp = configuration.client.execute(req).await?;
79
80 let status = resp.status();
81 let content_type = resp
82 .headers()
83 .get("content-type")
84 .and_then(|v| v.to_str().ok())
85 .unwrap_or("application/octet-stream");
86 let content_type = super::ContentType::from(content_type);
87
88 if !status.is_client_error() && !status.is_server_error() {
89 let content = resp.text().await?;
90 match content_type {
91 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
92 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TestSuiteRun`"))),
93 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::TestSuiteRun`")))),
94 }
95 } else {
96 let content = resp.text().await?;
97 let entity: Option<TestSuiteRunControllerCreateError> = serde_json::from_str(&content).ok();
98 Err(Error::ResponseError(ResponseContent {
99 status,
100 content,
101 entity,
102 }))
103 }
104}
105
106pub async fn test_suite_run_controller_find_all_paginated(
107 configuration: &configuration::Configuration,
108 test_suite_id: &str,
109 page: Option<f64>,
110 sort_order: Option<&str>,
111 limit: Option<f64>,
112 created_at_gt: Option<String>,
113 created_at_lt: Option<String>,
114 created_at_ge: Option<String>,
115 created_at_le: Option<String>,
116 updated_at_gt: Option<String>,
117 updated_at_lt: Option<String>,
118 updated_at_ge: Option<String>,
119 updated_at_le: Option<String>,
120) -> Result<
121 models::TestSuiteRunsPaginatedResponse,
122 Error<TestSuiteRunControllerFindAllPaginatedError>,
123> {
124 let p_test_suite_id = test_suite_id;
126 let p_page = page;
127 let p_sort_order = sort_order;
128 let p_limit = limit;
129 let p_created_at_gt = created_at_gt;
130 let p_created_at_lt = created_at_lt;
131 let p_created_at_ge = created_at_ge;
132 let p_created_at_le = created_at_le;
133 let p_updated_at_gt = updated_at_gt;
134 let p_updated_at_lt = updated_at_lt;
135 let p_updated_at_ge = updated_at_ge;
136 let p_updated_at_le = updated_at_le;
137
138 let uri_str = format!(
139 "{}/test-suite/{testSuiteId}/run",
140 configuration.base_path,
141 testSuiteId = crate::apis::urlencode(p_test_suite_id)
142 );
143 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
144
145 if let Some(ref param_value) = p_page {
146 req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
147 }
148 if let Some(ref param_value) = p_sort_order {
149 req_builder = req_builder.query(&[("sortOrder", ¶m_value.to_string())]);
150 }
151 if let Some(ref param_value) = p_limit {
152 req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
153 }
154 if let Some(ref param_value) = p_created_at_gt {
155 req_builder = req_builder.query(&[("createdAtGt", ¶m_value.to_string())]);
156 }
157 if let Some(ref param_value) = p_created_at_lt {
158 req_builder = req_builder.query(&[("createdAtLt", ¶m_value.to_string())]);
159 }
160 if let Some(ref param_value) = p_created_at_ge {
161 req_builder = req_builder.query(&[("createdAtGe", ¶m_value.to_string())]);
162 }
163 if let Some(ref param_value) = p_created_at_le {
164 req_builder = req_builder.query(&[("createdAtLe", ¶m_value.to_string())]);
165 }
166 if let Some(ref param_value) = p_updated_at_gt {
167 req_builder = req_builder.query(&[("updatedAtGt", ¶m_value.to_string())]);
168 }
169 if let Some(ref param_value) = p_updated_at_lt {
170 req_builder = req_builder.query(&[("updatedAtLt", ¶m_value.to_string())]);
171 }
172 if let Some(ref param_value) = p_updated_at_ge {
173 req_builder = req_builder.query(&[("updatedAtGe", ¶m_value.to_string())]);
174 }
175 if let Some(ref param_value) = p_updated_at_le {
176 req_builder = req_builder.query(&[("updatedAtLe", ¶m_value.to_string())]);
177 }
178 if let Some(ref user_agent) = configuration.user_agent {
179 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
180 }
181 if let Some(ref token) = configuration.bearer_access_token {
182 req_builder = req_builder.bearer_auth(token.to_owned());
183 };
184
185 let req = req_builder.build()?;
186 let resp = configuration.client.execute(req).await?;
187
188 let status = resp.status();
189 let content_type = resp
190 .headers()
191 .get("content-type")
192 .and_then(|v| v.to_str().ok())
193 .unwrap_or("application/octet-stream");
194 let content_type = super::ContentType::from(content_type);
195
196 if !status.is_client_error() && !status.is_server_error() {
197 let content = resp.text().await?;
198 match content_type {
199 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
200 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TestSuiteRunsPaginatedResponse`"))),
201 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::TestSuiteRunsPaginatedResponse`")))),
202 }
203 } else {
204 let content = resp.text().await?;
205 let entity: Option<TestSuiteRunControllerFindAllPaginatedError> =
206 serde_json::from_str(&content).ok();
207 Err(Error::ResponseError(ResponseContent {
208 status,
209 content,
210 entity,
211 }))
212 }
213}
214
215pub async fn test_suite_run_controller_find_one(
216 configuration: &configuration::Configuration,
217 test_suite_id: &str,
218 id: &str,
219) -> Result<models::TestSuiteRun, Error<TestSuiteRunControllerFindOneError>> {
220 let p_test_suite_id = test_suite_id;
222 let p_id = id;
223
224 let uri_str = format!(
225 "{}/test-suite/{testSuiteId}/run/{id}",
226 configuration.base_path,
227 testSuiteId = crate::apis::urlencode(p_test_suite_id),
228 id = crate::apis::urlencode(p_id)
229 );
230 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
231
232 if let Some(ref user_agent) = configuration.user_agent {
233 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
234 }
235 if let Some(ref token) = configuration.bearer_access_token {
236 req_builder = req_builder.bearer_auth(token.to_owned());
237 };
238
239 let req = req_builder.build()?;
240 let resp = configuration.client.execute(req).await?;
241
242 let status = resp.status();
243 let content_type = resp
244 .headers()
245 .get("content-type")
246 .and_then(|v| v.to_str().ok())
247 .unwrap_or("application/octet-stream");
248 let content_type = super::ContentType::from(content_type);
249
250 if !status.is_client_error() && !status.is_server_error() {
251 let content = resp.text().await?;
252 match content_type {
253 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
254 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TestSuiteRun`"))),
255 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::TestSuiteRun`")))),
256 }
257 } else {
258 let content = resp.text().await?;
259 let entity: Option<TestSuiteRunControllerFindOneError> =
260 serde_json::from_str(&content).ok();
261 Err(Error::ResponseError(ResponseContent {
262 status,
263 content,
264 entity,
265 }))
266 }
267}
268
269pub async fn test_suite_run_controller_remove(
270 configuration: &configuration::Configuration,
271 test_suite_id: &str,
272 id: &str,
273) -> Result<models::TestSuiteRun, Error<TestSuiteRunControllerRemoveError>> {
274 let p_test_suite_id = test_suite_id;
276 let p_id = id;
277
278 let uri_str = format!(
279 "{}/test-suite/{testSuiteId}/run/{id}",
280 configuration.base_path,
281 testSuiteId = crate::apis::urlencode(p_test_suite_id),
282 id = crate::apis::urlencode(p_id)
283 );
284 let mut req_builder = configuration
285 .client
286 .request(reqwest::Method::DELETE, &uri_str);
287
288 if let Some(ref user_agent) = configuration.user_agent {
289 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
290 }
291 if let Some(ref token) = configuration.bearer_access_token {
292 req_builder = req_builder.bearer_auth(token.to_owned());
293 };
294
295 let req = req_builder.build()?;
296 let resp = configuration.client.execute(req).await?;
297
298 let status = resp.status();
299 let content_type = resp
300 .headers()
301 .get("content-type")
302 .and_then(|v| v.to_str().ok())
303 .unwrap_or("application/octet-stream");
304 let content_type = super::ContentType::from(content_type);
305
306 if !status.is_client_error() && !status.is_server_error() {
307 let content = resp.text().await?;
308 match content_type {
309 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
310 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TestSuiteRun`"))),
311 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::TestSuiteRun`")))),
312 }
313 } else {
314 let content = resp.text().await?;
315 let entity: Option<TestSuiteRunControllerRemoveError> = serde_json::from_str(&content).ok();
316 Err(Error::ResponseError(ResponseContent {
317 status,
318 content,
319 entity,
320 }))
321 }
322}
323
324pub async fn test_suite_run_controller_update(
325 configuration: &configuration::Configuration,
326 test_suite_id: &str,
327 id: &str,
328 update_test_suite_run_dto: models::UpdateTestSuiteRunDto,
329) -> Result<models::TestSuiteRun, Error<TestSuiteRunControllerUpdateError>> {
330 let p_test_suite_id = test_suite_id;
332 let p_id = id;
333 let p_update_test_suite_run_dto = update_test_suite_run_dto;
334
335 let uri_str = format!(
336 "{}/test-suite/{testSuiteId}/run/{id}",
337 configuration.base_path,
338 testSuiteId = crate::apis::urlencode(p_test_suite_id),
339 id = crate::apis::urlencode(p_id)
340 );
341 let mut req_builder = configuration
342 .client
343 .request(reqwest::Method::PATCH, &uri_str);
344
345 if let Some(ref user_agent) = configuration.user_agent {
346 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
347 }
348 if let Some(ref token) = configuration.bearer_access_token {
349 req_builder = req_builder.bearer_auth(token.to_owned());
350 };
351 req_builder = req_builder.json(&p_update_test_suite_run_dto);
352
353 let req = req_builder.build()?;
354 let resp = configuration.client.execute(req).await?;
355
356 let status = resp.status();
357 let content_type = resp
358 .headers()
359 .get("content-type")
360 .and_then(|v| v.to_str().ok())
361 .unwrap_or("application/octet-stream");
362 let content_type = super::ContentType::from(content_type);
363
364 if !status.is_client_error() && !status.is_server_error() {
365 let content = resp.text().await?;
366 match content_type {
367 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
368 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TestSuiteRun`"))),
369 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::TestSuiteRun`")))),
370 }
371 } else {
372 let content = resp.text().await?;
373 let entity: Option<TestSuiteRunControllerUpdateError> = serde_json::from_str(&content).ok();
374 Err(Error::ResponseError(ResponseContent {
375 status,
376 content,
377 entity,
378 }))
379 }
380}