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