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