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