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 TestSuiteRunControllerCreateError {
22 UnknownValue(serde_json::Value),
23}
24
25#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum TestSuiteRunControllerFindAllPaginatedError {
29 UnknownValue(serde_json::Value),
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum TestSuiteRunControllerFindOneError {
36 UnknownValue(serde_json::Value),
37}
38
39#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum TestSuiteRunControllerRemoveError {
43 UnknownValue(serde_json::Value),
44}
45
46#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum TestSuiteRunControllerUpdateError {
50 UnknownValue(serde_json::Value),
51}
52
53
54pub async fn test_suite_run_controller_create(configuration: &configuration::Configuration, test_suite_id: &str, create_test_suite_run_dto: models::CreateTestSuiteRunDto) -> Result<models::TestSuiteRun, Error<TestSuiteRunControllerCreateError>> {
55 let p_test_suite_id = test_suite_id;
57 let p_create_test_suite_run_dto = create_test_suite_run_dto;
58
59 let uri_str = format!("{}/test-suite/{testSuiteId}/run", configuration.base_path, testSuiteId=crate::apis::urlencode(p_test_suite_id));
60 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
61
62 if let Some(ref user_agent) = configuration.user_agent {
63 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
64 }
65 if let Some(ref token) = configuration.bearer_access_token {
66 req_builder = req_builder.bearer_auth(token.to_owned());
67 };
68 req_builder = req_builder.json(&p_create_test_suite_run_dto);
69
70 let req = req_builder.build()?;
71 let resp = configuration.client.execute(req).await?;
72
73 let status = resp.status();
74 let content_type = resp
75 .headers()
76 .get("content-type")
77 .and_then(|v| v.to_str().ok())
78 .unwrap_or("application/octet-stream");
79 let content_type = super::ContentType::from(content_type);
80
81 if !status.is_client_error() && !status.is_server_error() {
82 let content = resp.text().await?;
83 match content_type {
84 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
85 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TestSuiteRun`"))),
86 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`")))),
87 }
88 } else {
89 let content = resp.text().await?;
90 let entity: Option<TestSuiteRunControllerCreateError> = serde_json::from_str(&content).ok();
91 Err(Error::ResponseError(ResponseContent { status, content, entity }))
92 }
93}
94
95pub async fn test_suite_run_controller_find_all_paginated(configuration: &configuration::Configuration, test_suite_id: &str, page: Option<f64>, sort_order: Option<&str>, limit: Option<f64>, created_at_gt: Option<String>, created_at_lt: Option<String>, created_at_ge: Option<String>, created_at_le: Option<String>, updated_at_gt: Option<String>, updated_at_lt: Option<String>, updated_at_ge: Option<String>, updated_at_le: Option<String>) -> Result<models::TestSuiteRunsPaginatedResponse, Error<TestSuiteRunControllerFindAllPaginatedError>> {
96 let p_test_suite_id = test_suite_id;
98 let p_page = page;
99 let p_sort_order = sort_order;
100 let p_limit = limit;
101 let p_created_at_gt = created_at_gt;
102 let p_created_at_lt = created_at_lt;
103 let p_created_at_ge = created_at_ge;
104 let p_created_at_le = created_at_le;
105 let p_updated_at_gt = updated_at_gt;
106 let p_updated_at_lt = updated_at_lt;
107 let p_updated_at_ge = updated_at_ge;
108 let p_updated_at_le = updated_at_le;
109
110 let uri_str = format!("{}/test-suite/{testSuiteId}/run", configuration.base_path, testSuiteId=crate::apis::urlencode(p_test_suite_id));
111 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
112
113 if let Some(ref param_value) = p_page {
114 req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
115 }
116 if let Some(ref param_value) = p_sort_order {
117 req_builder = req_builder.query(&[("sortOrder", ¶m_value.to_string())]);
118 }
119 if let Some(ref param_value) = p_limit {
120 req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
121 }
122 if let Some(ref param_value) = p_created_at_gt {
123 req_builder = req_builder.query(&[("createdAtGt", ¶m_value.to_string())]);
124 }
125 if let Some(ref param_value) = p_created_at_lt {
126 req_builder = req_builder.query(&[("createdAtLt", ¶m_value.to_string())]);
127 }
128 if let Some(ref param_value) = p_created_at_ge {
129 req_builder = req_builder.query(&[("createdAtGe", ¶m_value.to_string())]);
130 }
131 if let Some(ref param_value) = p_created_at_le {
132 req_builder = req_builder.query(&[("createdAtLe", ¶m_value.to_string())]);
133 }
134 if let Some(ref param_value) = p_updated_at_gt {
135 req_builder = req_builder.query(&[("updatedAtGt", ¶m_value.to_string())]);
136 }
137 if let Some(ref param_value) = p_updated_at_lt {
138 req_builder = req_builder.query(&[("updatedAtLt", ¶m_value.to_string())]);
139 }
140 if let Some(ref param_value) = p_updated_at_ge {
141 req_builder = req_builder.query(&[("updatedAtGe", ¶m_value.to_string())]);
142 }
143 if let Some(ref param_value) = p_updated_at_le {
144 req_builder = req_builder.query(&[("updatedAtLe", ¶m_value.to_string())]);
145 }
146 if let Some(ref user_agent) = configuration.user_agent {
147 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
148 }
149 if let Some(ref token) = configuration.bearer_access_token {
150 req_builder = req_builder.bearer_auth(token.to_owned());
151 };
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::TestSuiteRunsPaginatedResponse`"))),
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::TestSuiteRunsPaginatedResponse`")))),
170 }
171 } else {
172 let content = resp.text().await?;
173 let entity: Option<TestSuiteRunControllerFindAllPaginatedError> = serde_json::from_str(&content).ok();
174 Err(Error::ResponseError(ResponseContent { status, content, entity }))
175 }
176}
177
178pub async fn test_suite_run_controller_find_one(configuration: &configuration::Configuration, test_suite_id: &str, id: &str) -> Result<models::TestSuiteRun, Error<TestSuiteRunControllerFindOneError>> {
179 let p_test_suite_id = test_suite_id;
181 let p_id = id;
182
183 let uri_str = format!("{}/test-suite/{testSuiteId}/run/{id}", configuration.base_path, testSuiteId=crate::apis::urlencode(p_test_suite_id), id=crate::apis::urlencode(p_id));
184 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
185
186 if let Some(ref user_agent) = configuration.user_agent {
187 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
188 }
189 if let Some(ref token) = configuration.bearer_access_token {
190 req_builder = req_builder.bearer_auth(token.to_owned());
191 };
192
193 let req = req_builder.build()?;
194 let resp = configuration.client.execute(req).await?;
195
196 let status = resp.status();
197 let content_type = resp
198 .headers()
199 .get("content-type")
200 .and_then(|v| v.to_str().ok())
201 .unwrap_or("application/octet-stream");
202 let content_type = super::ContentType::from(content_type);
203
204 if !status.is_client_error() && !status.is_server_error() {
205 let content = resp.text().await?;
206 match content_type {
207 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
208 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TestSuiteRun`"))),
209 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`")))),
210 }
211 } else {
212 let content = resp.text().await?;
213 let entity: Option<TestSuiteRunControllerFindOneError> = serde_json::from_str(&content).ok();
214 Err(Error::ResponseError(ResponseContent { status, content, entity }))
215 }
216}
217
218pub async fn test_suite_run_controller_remove(configuration: &configuration::Configuration, test_suite_id: &str, id: &str) -> Result<models::TestSuiteRun, Error<TestSuiteRunControllerRemoveError>> {
219 let p_test_suite_id = test_suite_id;
221 let p_id = id;
222
223 let uri_str = format!("{}/test-suite/{testSuiteId}/run/{id}", configuration.base_path, testSuiteId=crate::apis::urlencode(p_test_suite_id), id=crate::apis::urlencode(p_id));
224 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
225
226 if let Some(ref user_agent) = configuration.user_agent {
227 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
228 }
229 if let Some(ref token) = configuration.bearer_access_token {
230 req_builder = req_builder.bearer_auth(token.to_owned());
231 };
232
233 let req = req_builder.build()?;
234 let resp = configuration.client.execute(req).await?;
235
236 let status = resp.status();
237 let content_type = resp
238 .headers()
239 .get("content-type")
240 .and_then(|v| v.to_str().ok())
241 .unwrap_or("application/octet-stream");
242 let content_type = super::ContentType::from(content_type);
243
244 if !status.is_client_error() && !status.is_server_error() {
245 let content = resp.text().await?;
246 match content_type {
247 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
248 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TestSuiteRun`"))),
249 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`")))),
250 }
251 } else {
252 let content = resp.text().await?;
253 let entity: Option<TestSuiteRunControllerRemoveError> = serde_json::from_str(&content).ok();
254 Err(Error::ResponseError(ResponseContent { status, content, entity }))
255 }
256}
257
258pub async fn test_suite_run_controller_update(configuration: &configuration::Configuration, test_suite_id: &str, id: &str, update_test_suite_run_dto: models::UpdateTestSuiteRunDto) -> Result<models::TestSuiteRun, Error<TestSuiteRunControllerUpdateError>> {
259 let p_test_suite_id = test_suite_id;
261 let p_id = id;
262 let p_update_test_suite_run_dto = update_test_suite_run_dto;
263
264 let uri_str = format!("{}/test-suite/{testSuiteId}/run/{id}", configuration.base_path, testSuiteId=crate::apis::urlencode(p_test_suite_id), id=crate::apis::urlencode(p_id));
265 let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
266
267 if let Some(ref user_agent) = configuration.user_agent {
268 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
269 }
270 if let Some(ref token) = configuration.bearer_access_token {
271 req_builder = req_builder.bearer_auth(token.to_owned());
272 };
273 req_builder = req_builder.json(&p_update_test_suite_run_dto);
274
275 let req = req_builder.build()?;
276 let resp = configuration.client.execute(req).await?;
277
278 let status = resp.status();
279 let content_type = resp
280 .headers()
281 .get("content-type")
282 .and_then(|v| v.to_str().ok())
283 .unwrap_or("application/octet-stream");
284 let content_type = super::ContentType::from(content_type);
285
286 if !status.is_client_error() && !status.is_server_error() {
287 let content = resp.text().await?;
288 match content_type {
289 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
290 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TestSuiteRun`"))),
291 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`")))),
292 }
293 } else {
294 let content = resp.text().await?;
295 let entity: Option<TestSuiteRunControllerUpdateError> = serde_json::from_str(&content).ok();
296 Err(Error::ResponseError(ResponseContent { status, content, entity }))
297 }
298}
299