1use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17#[derive(Clone, Debug)]
19pub struct CreateGcScheduleParams {
20 pub schedule: models::Schedule,
22 pub x_request_id: Option<String>
24}
25
26#[derive(Clone, Debug)]
28pub struct GetGcParams {
29 pub gc_id: i64,
31 pub x_request_id: Option<String>
33}
34
35#[derive(Clone, Debug)]
37pub struct GetGcHistoryParams {
38 pub x_request_id: Option<String>,
40 pub q: Option<String>,
42 pub sort: Option<String>,
44 pub page: Option<i64>,
46 pub page_size: Option<i64>
48}
49
50#[derive(Clone, Debug)]
52pub struct GetGcLogParams {
53 pub gc_id: i64,
55 pub x_request_id: Option<String>
57}
58
59#[derive(Clone, Debug)]
61pub struct GetGcScheduleParams {
62 pub x_request_id: Option<String>
64}
65
66#[derive(Clone, Debug)]
68pub struct StopGcParams {
69 pub gc_id: i64,
71 pub x_request_id: Option<String>
73}
74
75#[derive(Clone, Debug)]
77pub struct UpdateGcScheduleParams {
78 pub schedule: models::Schedule,
80 pub x_request_id: Option<String>
82}
83
84
85#[derive(Debug, Clone, Serialize, Deserialize)]
87#[serde(untagged)]
88pub enum CreateGcScheduleError {
89 Status400(models::Errors),
90 Status401(models::Errors),
91 Status403(models::Errors),
92 Status409(models::Errors),
93 Status500(models::Errors),
94 UnknownValue(serde_json::Value),
95}
96
97#[derive(Debug, Clone, Serialize, Deserialize)]
99#[serde(untagged)]
100pub enum GetGcError {
101 Status401(models::Errors),
102 Status403(models::Errors),
103 Status404(models::Errors),
104 Status500(models::Errors),
105 UnknownValue(serde_json::Value),
106}
107
108#[derive(Debug, Clone, Serialize, Deserialize)]
110#[serde(untagged)]
111pub enum GetGcHistoryError {
112 Status401(models::Errors),
113 Status403(models::Errors),
114 Status500(models::Errors),
115 UnknownValue(serde_json::Value),
116}
117
118#[derive(Debug, Clone, Serialize, Deserialize)]
120#[serde(untagged)]
121pub enum GetGcLogError {
122 Status400(models::Errors),
123 Status401(models::Errors),
124 Status403(models::Errors),
125 Status404(models::Errors),
126 Status500(models::Errors),
127 UnknownValue(serde_json::Value),
128}
129
130#[derive(Debug, Clone, Serialize, Deserialize)]
132#[serde(untagged)]
133pub enum GetGcScheduleError {
134 Status401(models::Errors),
135 Status403(models::Errors),
136 Status500(models::Errors),
137 UnknownValue(serde_json::Value),
138}
139
140#[derive(Debug, Clone, Serialize, Deserialize)]
142#[serde(untagged)]
143pub enum StopGcError {
144 Status401(models::Errors),
145 Status403(models::Errors),
146 Status404(models::Errors),
147 Status500(models::Errors),
148 UnknownValue(serde_json::Value),
149}
150
151#[derive(Debug, Clone, Serialize, Deserialize)]
153#[serde(untagged)]
154pub enum UpdateGcScheduleError {
155 Status400(models::Errors),
156 Status401(models::Errors),
157 Status403(models::Errors),
158 Status500(models::Errors),
159 UnknownValue(serde_json::Value),
160}
161
162
163pub async fn create_gc_schedule(configuration: &configuration::Configuration, params: CreateGcScheduleParams) -> Result<(), Error<CreateGcScheduleError>> {
165
166 let uri_str = format!("{}/system/gc/schedule", configuration.base_path);
167 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
168
169 if let Some(ref user_agent) = configuration.user_agent {
170 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
171 }
172 if let Some(param_value) = params.x_request_id {
173 req_builder = req_builder.header("X-Request-Id", param_value.to_string());
174 }
175 if let Some(ref auth_conf) = configuration.basic_auth {
176 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
177 };
178 req_builder = req_builder.json(¶ms.schedule);
179
180 let req = req_builder.build()?;
181 let resp = configuration.client.execute(req).await?;
182
183 let status = resp.status();
184
185 if !status.is_client_error() && !status.is_server_error() {
186 Ok(())
187 } else {
188 let content = resp.text().await?;
189 let entity: Option<CreateGcScheduleError> = serde_json::from_str(&content).ok();
190 Err(Error::ResponseError(ResponseContent { status, content, entity }))
191 }
192}
193
194pub async fn get_gc(configuration: &configuration::Configuration, params: GetGcParams) -> Result<models::GcHistory, Error<GetGcError>> {
196
197 let uri_str = format!("{}/system/gc/{gc_id}", configuration.base_path, gc_id=params.gc_id);
198 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
199
200 if let Some(ref user_agent) = configuration.user_agent {
201 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
202 }
203 if let Some(param_value) = params.x_request_id {
204 req_builder = req_builder.header("X-Request-Id", param_value.to_string());
205 }
206 if let Some(ref auth_conf) = configuration.basic_auth {
207 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
208 };
209
210 let req = req_builder.build()?;
211 let resp = configuration.client.execute(req).await?;
212
213 let status = resp.status();
214 let content_type = resp
215 .headers()
216 .get("content-type")
217 .and_then(|v| v.to_str().ok())
218 .unwrap_or("application/octet-stream");
219 let content_type = super::ContentType::from(content_type);
220
221 if !status.is_client_error() && !status.is_server_error() {
222 let content = resp.text().await?;
223 match content_type {
224 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
225 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GcHistory`"))),
226 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::GcHistory`")))),
227 }
228 } else {
229 let content = resp.text().await?;
230 let entity: Option<GetGcError> = serde_json::from_str(&content).ok();
231 Err(Error::ResponseError(ResponseContent { status, content, entity }))
232 }
233}
234
235pub async fn get_gc_history(configuration: &configuration::Configuration, params: GetGcHistoryParams) -> Result<Vec<models::GcHistory>, Error<GetGcHistoryError>> {
237
238 let uri_str = format!("{}/system/gc", configuration.base_path);
239 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
240
241 if let Some(ref param_value) = params.q {
242 req_builder = req_builder.query(&[("q", ¶m_value.to_string())]);
243 }
244 if let Some(ref param_value) = params.sort {
245 req_builder = req_builder.query(&[("sort", ¶m_value.to_string())]);
246 }
247 if let Some(ref param_value) = params.page {
248 req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
249 }
250 if let Some(ref param_value) = params.page_size {
251 req_builder = req_builder.query(&[("page_size", ¶m_value.to_string())]);
252 }
253 if let Some(ref user_agent) = configuration.user_agent {
254 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
255 }
256 if let Some(param_value) = params.x_request_id {
257 req_builder = req_builder.header("X-Request-Id", param_value.to_string());
258 }
259 if let Some(ref auth_conf) = configuration.basic_auth {
260 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
261 };
262
263 let req = req_builder.build()?;
264 let resp = configuration.client.execute(req).await?;
265
266 let status = resp.status();
267 let content_type = resp
268 .headers()
269 .get("content-type")
270 .and_then(|v| v.to_str().ok())
271 .unwrap_or("application/octet-stream");
272 let content_type = super::ContentType::from(content_type);
273
274 if !status.is_client_error() && !status.is_server_error() {
275 let content = resp.text().await?;
276 match content_type {
277 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
278 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GcHistory>`"))),
279 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::GcHistory>`")))),
280 }
281 } else {
282 let content = resp.text().await?;
283 let entity: Option<GetGcHistoryError> = serde_json::from_str(&content).ok();
284 Err(Error::ResponseError(ResponseContent { status, content, entity }))
285 }
286}
287
288pub async fn get_gc_log(configuration: &configuration::Configuration, params: GetGcLogParams) -> Result<String, Error<GetGcLogError>> {
290
291 let uri_str = format!("{}/system/gc/{gc_id}/log", configuration.base_path, gc_id=params.gc_id);
292 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
293
294 if let Some(ref user_agent) = configuration.user_agent {
295 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
296 }
297 if let Some(param_value) = params.x_request_id {
298 req_builder = req_builder.header("X-Request-Id", param_value.to_string());
299 }
300 if let Some(ref auth_conf) = configuration.basic_auth {
301 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
302 };
303
304 let req = req_builder.build()?;
305 let resp = configuration.client.execute(req).await?;
306
307 let status = resp.status();
308 let content_type = resp
309 .headers()
310 .get("content-type")
311 .and_then(|v| v.to_str().ok())
312 .unwrap_or("application/octet-stream");
313 let content_type = super::ContentType::from(content_type);
314
315 if !status.is_client_error() && !status.is_server_error() {
316 let content = resp.text().await?;
317 match content_type {
318 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
319 ContentType::Text => return Ok(content),
320 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `String`")))),
321 }
322 } else {
323 let content = resp.text().await?;
324 let entity: Option<GetGcLogError> = serde_json::from_str(&content).ok();
325 Err(Error::ResponseError(ResponseContent { status, content, entity }))
326 }
327}
328
329pub async fn get_gc_schedule(configuration: &configuration::Configuration, params: GetGcScheduleParams) -> Result<models::GcHistory, Error<GetGcScheduleError>> {
331
332 let uri_str = format!("{}/system/gc/schedule", configuration.base_path);
333 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
334
335 if let Some(ref user_agent) = configuration.user_agent {
336 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
337 }
338 if let Some(param_value) = params.x_request_id {
339 req_builder = req_builder.header("X-Request-Id", param_value.to_string());
340 }
341 if let Some(ref auth_conf) = configuration.basic_auth {
342 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
343 };
344
345 let req = req_builder.build()?;
346 let resp = configuration.client.execute(req).await?;
347
348 let status = resp.status();
349 let content_type = resp
350 .headers()
351 .get("content-type")
352 .and_then(|v| v.to_str().ok())
353 .unwrap_or("application/octet-stream");
354 let content_type = super::ContentType::from(content_type);
355
356 if !status.is_client_error() && !status.is_server_error() {
357 let content = resp.text().await?;
358 match content_type {
359 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
360 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GcHistory`"))),
361 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::GcHistory`")))),
362 }
363 } else {
364 let content = resp.text().await?;
365 let entity: Option<GetGcScheduleError> = serde_json::from_str(&content).ok();
366 Err(Error::ResponseError(ResponseContent { status, content, entity }))
367 }
368}
369
370pub async fn stop_gc(configuration: &configuration::Configuration, params: StopGcParams) -> Result<(), Error<StopGcError>> {
372
373 let uri_str = format!("{}/system/gc/{gc_id}", configuration.base_path, gc_id=params.gc_id);
374 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
375
376 if let Some(ref user_agent) = configuration.user_agent {
377 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
378 }
379 if let Some(param_value) = params.x_request_id {
380 req_builder = req_builder.header("X-Request-Id", param_value.to_string());
381 }
382 if let Some(ref auth_conf) = configuration.basic_auth {
383 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
384 };
385
386 let req = req_builder.build()?;
387 let resp = configuration.client.execute(req).await?;
388
389 let status = resp.status();
390
391 if !status.is_client_error() && !status.is_server_error() {
392 Ok(())
393 } else {
394 let content = resp.text().await?;
395 let entity: Option<StopGcError> = serde_json::from_str(&content).ok();
396 Err(Error::ResponseError(ResponseContent { status, content, entity }))
397 }
398}
399
400pub async fn update_gc_schedule(configuration: &configuration::Configuration, params: UpdateGcScheduleParams) -> Result<(), Error<UpdateGcScheduleError>> {
402
403 let uri_str = format!("{}/system/gc/schedule", configuration.base_path);
404 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
405
406 if let Some(ref user_agent) = configuration.user_agent {
407 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
408 }
409 if let Some(param_value) = params.x_request_id {
410 req_builder = req_builder.header("X-Request-Id", param_value.to_string());
411 }
412 if let Some(ref auth_conf) = configuration.basic_auth {
413 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
414 };
415 req_builder = req_builder.json(¶ms.schedule);
416
417 let req = req_builder.build()?;
418 let resp = configuration.client.execute(req).await?;
419
420 let status = resp.status();
421
422 if !status.is_client_error() && !status.is_server_error() {
423 Ok(())
424 } else {
425 let content = resp.text().await?;
426 let entity: Option<UpdateGcScheduleError> = serde_json::from_str(&content).ok();
427 Err(Error::ResponseError(ResponseContent { status, content, entity }))
428 }
429}
430