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 CreateScanAllScheduleParams {
20 pub schedule: models::Schedule,
22 pub x_request_id: Option<String>
24}
25
26#[derive(Clone, Debug)]
28pub struct GetLatestScanAllMetricsParams {
29 pub x_request_id: Option<String>
31}
32
33#[derive(Clone, Debug)]
35pub struct GetLatestScheduledScanAllMetricsParams {
36 pub x_request_id: Option<String>
38}
39
40#[derive(Clone, Debug)]
42pub struct GetScanAllScheduleParams {
43 pub x_request_id: Option<String>
45}
46
47#[derive(Clone, Debug)]
49pub struct StopScanAllParams {
50 pub x_request_id: Option<String>
52}
53
54#[derive(Clone, Debug)]
56pub struct UpdateScanAllScheduleParams {
57 pub schedule: models::Schedule,
59 pub x_request_id: Option<String>
61}
62
63
64#[derive(Debug, Clone, Serialize, Deserialize)]
66#[serde(untagged)]
67pub enum CreateScanAllScheduleError {
68 Status400(models::Errors),
69 Status401(models::Errors),
70 Status403(models::Errors),
71 Status409(models::Errors),
72 Status412(models::Errors),
73 Status500(models::Errors),
74 UnknownValue(serde_json::Value),
75}
76
77#[derive(Debug, Clone, Serialize, Deserialize)]
79#[serde(untagged)]
80pub enum GetLatestScanAllMetricsError {
81 Status401(models::Errors),
82 Status403(models::Errors),
83 Status412(models::Errors),
84 Status500(models::Errors),
85 UnknownValue(serde_json::Value),
86}
87
88#[derive(Debug, Clone, Serialize, Deserialize)]
90#[serde(untagged)]
91pub enum GetLatestScheduledScanAllMetricsError {
92 Status401(models::Errors),
93 Status403(models::Errors),
94 Status412(models::Errors),
95 Status500(models::Errors),
96 UnknownValue(serde_json::Value),
97}
98
99#[derive(Debug, Clone, Serialize, Deserialize)]
101#[serde(untagged)]
102pub enum GetScanAllScheduleError {
103 Status401(models::Errors),
104 Status403(models::Errors),
105 Status412(models::Errors),
106 Status500(models::Errors),
107 UnknownValue(serde_json::Value),
108}
109
110#[derive(Debug, Clone, Serialize, Deserialize)]
112#[serde(untagged)]
113pub enum StopScanAllError {
114 Status400(models::Errors),
115 Status401(models::Errors),
116 Status403(models::Errors),
117 Status500(models::Errors),
118 UnknownValue(serde_json::Value),
119}
120
121#[derive(Debug, Clone, Serialize, Deserialize)]
123#[serde(untagged)]
124pub enum UpdateScanAllScheduleError {
125 Status400(models::Errors),
126 Status401(models::Errors),
127 Status403(models::Errors),
128 Status412(models::Errors),
129 Status500(models::Errors),
130 UnknownValue(serde_json::Value),
131}
132
133
134pub async fn create_scan_all_schedule(configuration: &configuration::Configuration, params: CreateScanAllScheduleParams) -> Result<(), Error<CreateScanAllScheduleError>> {
136
137 let uri_str = format!("{}/system/scanAll/schedule", configuration.base_path);
138 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
139
140 if let Some(ref user_agent) = configuration.user_agent {
141 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
142 }
143 if let Some(param_value) = params.x_request_id {
144 req_builder = req_builder.header("X-Request-Id", param_value.to_string());
145 }
146 if let Some(ref auth_conf) = configuration.basic_auth {
147 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
148 };
149 req_builder = req_builder.json(¶ms.schedule);
150
151 let req = req_builder.build()?;
152 let resp = configuration.client.execute(req).await?;
153
154 let status = resp.status();
155
156 if !status.is_client_error() && !status.is_server_error() {
157 Ok(())
158 } else {
159 let content = resp.text().await?;
160 let entity: Option<CreateScanAllScheduleError> = serde_json::from_str(&content).ok();
161 Err(Error::ResponseError(ResponseContent { status, content, entity }))
162 }
163}
164
165pub async fn get_latest_scan_all_metrics(configuration: &configuration::Configuration, params: GetLatestScanAllMetricsParams) -> Result<models::Stats, Error<GetLatestScanAllMetricsError>> {
167
168 let uri_str = format!("{}/scans/all/metrics", configuration.base_path);
169 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
170
171 if let Some(ref user_agent) = configuration.user_agent {
172 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
173 }
174 if let Some(param_value) = params.x_request_id {
175 req_builder = req_builder.header("X-Request-Id", param_value.to_string());
176 }
177 if let Some(ref auth_conf) = configuration.basic_auth {
178 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
179 };
180
181 let req = req_builder.build()?;
182 let resp = configuration.client.execute(req).await?;
183
184 let status = resp.status();
185 let content_type = resp
186 .headers()
187 .get("content-type")
188 .and_then(|v| v.to_str().ok())
189 .unwrap_or("application/octet-stream");
190 let content_type = super::ContentType::from(content_type);
191
192 if !status.is_client_error() && !status.is_server_error() {
193 let content = resp.text().await?;
194 match content_type {
195 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
196 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Stats`"))),
197 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::Stats`")))),
198 }
199 } else {
200 let content = resp.text().await?;
201 let entity: Option<GetLatestScanAllMetricsError> = serde_json::from_str(&content).ok();
202 Err(Error::ResponseError(ResponseContent { status, content, entity }))
203 }
204}
205
206#[deprecated]
208pub async fn get_latest_scheduled_scan_all_metrics(configuration: &configuration::Configuration, params: GetLatestScheduledScanAllMetricsParams) -> Result<models::Stats, Error<GetLatestScheduledScanAllMetricsError>> {
209
210 let uri_str = format!("{}/scans/schedule/metrics", configuration.base_path);
211 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
212
213 if let Some(ref user_agent) = configuration.user_agent {
214 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
215 }
216 if let Some(param_value) = params.x_request_id {
217 req_builder = req_builder.header("X-Request-Id", param_value.to_string());
218 }
219 if let Some(ref auth_conf) = configuration.basic_auth {
220 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
221 };
222
223 let req = req_builder.build()?;
224 let resp = configuration.client.execute(req).await?;
225
226 let status = resp.status();
227 let content_type = resp
228 .headers()
229 .get("content-type")
230 .and_then(|v| v.to_str().ok())
231 .unwrap_or("application/octet-stream");
232 let content_type = super::ContentType::from(content_type);
233
234 if !status.is_client_error() && !status.is_server_error() {
235 let content = resp.text().await?;
236 match content_type {
237 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
238 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Stats`"))),
239 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::Stats`")))),
240 }
241 } else {
242 let content = resp.text().await?;
243 let entity: Option<GetLatestScheduledScanAllMetricsError> = serde_json::from_str(&content).ok();
244 Err(Error::ResponseError(ResponseContent { status, content, entity }))
245 }
246}
247
248pub async fn get_scan_all_schedule(configuration: &configuration::Configuration, params: GetScanAllScheduleParams) -> Result<models::Schedule, Error<GetScanAllScheduleError>> {
250
251 let uri_str = format!("{}/system/scanAll/schedule", configuration.base_path);
252 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
253
254 if let Some(ref user_agent) = configuration.user_agent {
255 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
256 }
257 if let Some(param_value) = params.x_request_id {
258 req_builder = req_builder.header("X-Request-Id", param_value.to_string());
259 }
260 if let Some(ref auth_conf) = configuration.basic_auth {
261 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
262 };
263
264 let req = req_builder.build()?;
265 let resp = configuration.client.execute(req).await?;
266
267 let status = resp.status();
268 let content_type = resp
269 .headers()
270 .get("content-type")
271 .and_then(|v| v.to_str().ok())
272 .unwrap_or("application/octet-stream");
273 let content_type = super::ContentType::from(content_type);
274
275 if !status.is_client_error() && !status.is_server_error() {
276 let content = resp.text().await?;
277 match content_type {
278 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
279 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Schedule`"))),
280 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::Schedule`")))),
281 }
282 } else {
283 let content = resp.text().await?;
284 let entity: Option<GetScanAllScheduleError> = serde_json::from_str(&content).ok();
285 Err(Error::ResponseError(ResponseContent { status, content, entity }))
286 }
287}
288
289pub async fn stop_scan_all(configuration: &configuration::Configuration, params: StopScanAllParams) -> Result<(), Error<StopScanAllError>> {
291
292 let uri_str = format!("{}/system/scanAll/stop", configuration.base_path);
293 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
294
295 if let Some(ref user_agent) = configuration.user_agent {
296 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
297 }
298 if let Some(param_value) = params.x_request_id {
299 req_builder = req_builder.header("X-Request-Id", param_value.to_string());
300 }
301 if let Some(ref auth_conf) = configuration.basic_auth {
302 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
303 };
304
305 let req = req_builder.build()?;
306 let resp = configuration.client.execute(req).await?;
307
308 let status = resp.status();
309
310 if !status.is_client_error() && !status.is_server_error() {
311 Ok(())
312 } else {
313 let content = resp.text().await?;
314 let entity: Option<StopScanAllError> = serde_json::from_str(&content).ok();
315 Err(Error::ResponseError(ResponseContent { status, content, entity }))
316 }
317}
318
319pub async fn update_scan_all_schedule(configuration: &configuration::Configuration, params: UpdateScanAllScheduleParams) -> Result<(), Error<UpdateScanAllScheduleError>> {
321
322 let uri_str = format!("{}/system/scanAll/schedule", configuration.base_path);
323 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
324
325 if let Some(ref user_agent) = configuration.user_agent {
326 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
327 }
328 if let Some(param_value) = params.x_request_id {
329 req_builder = req_builder.header("X-Request-Id", param_value.to_string());
330 }
331 if let Some(ref auth_conf) = configuration.basic_auth {
332 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
333 };
334 req_builder = req_builder.json(¶ms.schedule);
335
336 let req = req_builder.build()?;
337 let resp = configuration.client.execute(req).await?;
338
339 let status = resp.status();
340
341 if !status.is_client_error() && !status.is_server_error() {
342 Ok(())
343 } else {
344 let content = resp.text().await?;
345 let entity: Option<UpdateScanAllScheduleError> = serde_json::from_str(&content).ok();
346 Err(Error::ResponseError(ResponseContent { status, content, entity }))
347 }
348}
349