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 CreateProjectParams {
20 pub project: models::ProjectReq,
22 pub x_request_id: Option<String>,
24 pub x_resource_name_in_location: Option<bool>
26}
27
28#[derive(Clone, Debug)]
30pub struct DeleteProjectParams {
31 pub project_name_or_id: String,
33 pub x_request_id: Option<String>,
35 pub x_is_resource_name: Option<bool>
37}
38
39#[derive(Clone, Debug)]
41pub struct GetLogsParams {
42 pub project_name: String,
44 pub x_request_id: Option<String>,
46 pub q: Option<String>,
48 pub sort: Option<String>,
50 pub page: Option<i64>,
52 pub page_size: Option<i64>
54}
55
56#[derive(Clone, Debug)]
58pub struct GetProjectParams {
59 pub project_name_or_id: String,
61 pub x_request_id: Option<String>,
63 pub x_is_resource_name: Option<bool>
65}
66
67#[derive(Clone, Debug)]
69pub struct GetProjectDeletableParams {
70 pub project_name_or_id: String,
72 pub x_request_id: Option<String>,
74 pub x_is_resource_name: Option<bool>
76}
77
78#[derive(Clone, Debug)]
80pub struct GetProjectSummaryParams {
81 pub project_name_or_id: String,
83 pub x_request_id: Option<String>,
85 pub x_is_resource_name: Option<bool>
87}
88
89#[derive(Clone, Debug)]
91pub struct GetScannerOfProjectParams {
92 pub project_name_or_id: String,
94 pub x_request_id: Option<String>,
96 pub x_is_resource_name: Option<bool>
98}
99
100#[derive(Clone, Debug)]
102pub struct HeadProjectParams {
103 pub project_name: String,
105 pub x_request_id: Option<String>
107}
108
109#[derive(Clone, Debug)]
111pub struct ListArtifactsOfProjectParams {
112 pub project_name_or_id: String,
114 pub x_request_id: Option<String>,
116 pub x_is_resource_name: Option<bool>,
118 pub q: Option<String>,
120 pub sort: Option<String>,
122 pub page: Option<i64>,
124 pub page_size: Option<i64>,
126 pub x_accept_vulnerabilities: Option<String>,
128 pub with_tag: Option<bool>,
130 pub with_label: Option<bool>,
132 pub with_scan_overview: Option<bool>,
134 pub with_sbom_overview: Option<bool>,
136 pub with_immutable_status: Option<bool>,
138 pub with_accessory: Option<bool>,
140 pub latest_in_repository: Option<bool>
142}
143
144#[derive(Clone, Debug)]
146pub struct ListProjectsParams {
147 pub x_request_id: Option<String>,
149 pub q: Option<String>,
151 pub page: Option<i64>,
153 pub page_size: Option<i64>,
155 pub sort: Option<String>,
157 pub name: Option<String>,
159 pub public: Option<bool>,
161 pub owner: Option<String>,
163 pub with_detail: Option<bool>
165}
166
167#[derive(Clone, Debug)]
169pub struct ListScannerCandidatesOfProjectParams {
170 pub project_name_or_id: String,
172 pub x_request_id: Option<String>,
174 pub x_is_resource_name: Option<bool>,
176 pub q: Option<String>,
178 pub sort: Option<String>,
180 pub page: Option<i64>,
182 pub page_size: Option<i64>
184}
185
186#[derive(Clone, Debug)]
188pub struct SetScannerOfProjectParams {
189 pub project_name_or_id: String,
191 pub payload: models::ProjectScanner,
192 pub x_request_id: Option<String>,
194 pub x_is_resource_name: Option<bool>
196}
197
198#[derive(Clone, Debug)]
200pub struct UpdateProjectParams {
201 pub project_name_or_id: String,
203 pub project: models::ProjectReq,
205 pub x_request_id: Option<String>,
207 pub x_is_resource_name: Option<bool>
209}
210
211
212#[derive(Debug, Clone, Serialize, Deserialize)]
214#[serde(untagged)]
215pub enum CreateProjectError {
216 Status400(models::Errors),
217 Status401(models::Errors),
218 Status409(models::Errors),
219 Status500(models::Errors),
220 UnknownValue(serde_json::Value),
221}
222
223#[derive(Debug, Clone, Serialize, Deserialize)]
225#[serde(untagged)]
226pub enum DeleteProjectError {
227 Status400(models::Errors),
228 Status403(models::Errors),
229 Status404(models::Errors),
230 Status412(models::Errors),
231 Status500(models::Errors),
232 UnknownValue(serde_json::Value),
233}
234
235#[derive(Debug, Clone, Serialize, Deserialize)]
237#[serde(untagged)]
238pub enum GetLogsError {
239 Status400(models::Errors),
240 Status401(models::Errors),
241 Status500(models::Errors),
242 UnknownValue(serde_json::Value),
243}
244
245#[derive(Debug, Clone, Serialize, Deserialize)]
247#[serde(untagged)]
248pub enum GetProjectError {
249 Status401(models::Errors),
250 Status500(models::Errors),
251 UnknownValue(serde_json::Value),
252}
253
254#[derive(Debug, Clone, Serialize, Deserialize)]
256#[serde(untagged)]
257pub enum GetProjectDeletableError {
258 Status401(models::Errors),
259 Status403(models::Errors),
260 Status404(models::Errors),
261 Status500(models::Errors),
262 UnknownValue(serde_json::Value),
263}
264
265#[derive(Debug, Clone, Serialize, Deserialize)]
267#[serde(untagged)]
268pub enum GetProjectSummaryError {
269 Status400(models::Errors),
270 Status401(models::Errors),
271 Status403(models::Errors),
272 Status404(models::Errors),
273 Status500(models::Errors),
274 UnknownValue(serde_json::Value),
275}
276
277#[derive(Debug, Clone, Serialize, Deserialize)]
279#[serde(untagged)]
280pub enum GetScannerOfProjectError {
281 Status400(),
282 Status401(),
283 Status403(),
284 Status404(),
285 Status500(),
286 UnknownValue(serde_json::Value),
287}
288
289#[derive(Debug, Clone, Serialize, Deserialize)]
291#[serde(untagged)]
292pub enum HeadProjectError {
293 Status404(models::Errors),
294 Status500(models::Errors),
295 UnknownValue(serde_json::Value),
296}
297
298#[derive(Debug, Clone, Serialize, Deserialize)]
300#[serde(untagged)]
301pub enum ListArtifactsOfProjectError {
302 Status400(models::Errors),
303 Status401(models::Errors),
304 Status403(models::Errors),
305 Status404(models::Errors),
306 Status500(models::Errors),
307 UnknownValue(serde_json::Value),
308}
309
310#[derive(Debug, Clone, Serialize, Deserialize)]
312#[serde(untagged)]
313pub enum ListProjectsError {
314 Status401(models::Errors),
315 Status500(models::Errors),
316 UnknownValue(serde_json::Value),
317}
318
319#[derive(Debug, Clone, Serialize, Deserialize)]
321#[serde(untagged)]
322pub enum ListScannerCandidatesOfProjectError {
323 Status400(models::Errors),
324 Status401(models::Errors),
325 Status403(models::Errors),
326 Status500(models::Errors),
327 UnknownValue(serde_json::Value),
328}
329
330#[derive(Debug, Clone, Serialize, Deserialize)]
332#[serde(untagged)]
333pub enum SetScannerOfProjectError {
334 Status400(models::Errors),
335 Status401(models::Errors),
336 Status403(models::Errors),
337 Status404(models::Errors),
338 Status500(models::Errors),
339 UnknownValue(serde_json::Value),
340}
341
342#[derive(Debug, Clone, Serialize, Deserialize)]
344#[serde(untagged)]
345pub enum UpdateProjectError {
346 Status400(models::Errors),
347 Status401(models::Errors),
348 Status403(models::Errors),
349 Status404(models::Errors),
350 Status500(models::Errors),
351 UnknownValue(serde_json::Value),
352}
353
354
355pub async fn create_project(configuration: &configuration::Configuration, params: CreateProjectParams) -> Result<(), Error<CreateProjectError>> {
357
358 let uri_str = format!("{}/projects", configuration.base_path);
359 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
360
361 if let Some(ref user_agent) = configuration.user_agent {
362 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
363 }
364 if let Some(param_value) = params.x_request_id {
365 req_builder = req_builder.header("X-Request-Id", param_value.to_string());
366 }
367 if let Some(param_value) = params.x_resource_name_in_location {
368 req_builder = req_builder.header("X-Resource-Name-In-Location", param_value.to_string());
369 }
370 if let Some(ref auth_conf) = configuration.basic_auth {
371 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
372 };
373 req_builder = req_builder.json(¶ms.project);
374
375 let req = req_builder.build()?;
376 let resp = configuration.client.execute(req).await?;
377
378 let status = resp.status();
379
380 if !status.is_client_error() && !status.is_server_error() {
381 Ok(())
382 } else {
383 let content = resp.text().await?;
384 let entity: Option<CreateProjectError> = serde_json::from_str(&content).ok();
385 Err(Error::ResponseError(ResponseContent { status, content, entity }))
386 }
387}
388
389pub async fn delete_project(configuration: &configuration::Configuration, params: DeleteProjectParams) -> Result<(), Error<DeleteProjectError>> {
391
392 let uri_str = format!("{}/projects/{project_name_or_id}", configuration.base_path, project_name_or_id=crate::apis::urlencode(params.project_name_or_id));
393 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
394
395 if let Some(ref user_agent) = configuration.user_agent {
396 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
397 }
398 if let Some(param_value) = params.x_request_id {
399 req_builder = req_builder.header("X-Request-Id", param_value.to_string());
400 }
401 if let Some(param_value) = params.x_is_resource_name {
402 req_builder = req_builder.header("X-Is-Resource-Name", param_value.to_string());
403 }
404 if let Some(ref auth_conf) = configuration.basic_auth {
405 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
406 };
407
408 let req = req_builder.build()?;
409 let resp = configuration.client.execute(req).await?;
410
411 let status = resp.status();
412
413 if !status.is_client_error() && !status.is_server_error() {
414 Ok(())
415 } else {
416 let content = resp.text().await?;
417 let entity: Option<DeleteProjectError> = serde_json::from_str(&content).ok();
418 Err(Error::ResponseError(ResponseContent { status, content, entity }))
419 }
420}
421
422pub async fn get_logs(configuration: &configuration::Configuration, params: GetLogsParams) -> Result<Vec<models::AuditLog>, Error<GetLogsError>> {
424
425 let uri_str = format!("{}/projects/{project_name}/logs", configuration.base_path, project_name=crate::apis::urlencode(params.project_name));
426 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
427
428 if let Some(ref param_value) = params.q {
429 req_builder = req_builder.query(&[("q", ¶m_value.to_string())]);
430 }
431 if let Some(ref param_value) = params.sort {
432 req_builder = req_builder.query(&[("sort", ¶m_value.to_string())]);
433 }
434 if let Some(ref param_value) = params.page {
435 req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
436 }
437 if let Some(ref param_value) = params.page_size {
438 req_builder = req_builder.query(&[("page_size", ¶m_value.to_string())]);
439 }
440 if let Some(ref user_agent) = configuration.user_agent {
441 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
442 }
443 if let Some(param_value) = params.x_request_id {
444 req_builder = req_builder.header("X-Request-Id", param_value.to_string());
445 }
446 if let Some(ref auth_conf) = configuration.basic_auth {
447 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
448 };
449
450 let req = req_builder.build()?;
451 let resp = configuration.client.execute(req).await?;
452
453 let status = resp.status();
454 let content_type = resp
455 .headers()
456 .get("content-type")
457 .and_then(|v| v.to_str().ok())
458 .unwrap_or("application/octet-stream");
459 let content_type = super::ContentType::from(content_type);
460
461 if !status.is_client_error() && !status.is_server_error() {
462 let content = resp.text().await?;
463 match content_type {
464 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
465 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::AuditLog>`"))),
466 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::AuditLog>`")))),
467 }
468 } else {
469 let content = resp.text().await?;
470 let entity: Option<GetLogsError> = serde_json::from_str(&content).ok();
471 Err(Error::ResponseError(ResponseContent { status, content, entity }))
472 }
473}
474
475pub async fn get_project(configuration: &configuration::Configuration, params: GetProjectParams) -> Result<models::Project, Error<GetProjectError>> {
477
478 let uri_str = format!("{}/projects/{project_name_or_id}", configuration.base_path, project_name_or_id=crate::apis::urlencode(params.project_name_or_id));
479 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
480
481 if let Some(ref user_agent) = configuration.user_agent {
482 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
483 }
484 if let Some(param_value) = params.x_request_id {
485 req_builder = req_builder.header("X-Request-Id", param_value.to_string());
486 }
487 if let Some(param_value) = params.x_is_resource_name {
488 req_builder = req_builder.header("X-Is-Resource-Name", param_value.to_string());
489 }
490 if let Some(ref auth_conf) = configuration.basic_auth {
491 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
492 };
493
494 let req = req_builder.build()?;
495 let resp = configuration.client.execute(req).await?;
496
497 let status = resp.status();
498 let content_type = resp
499 .headers()
500 .get("content-type")
501 .and_then(|v| v.to_str().ok())
502 .unwrap_or("application/octet-stream");
503 let content_type = super::ContentType::from(content_type);
504
505 if !status.is_client_error() && !status.is_server_error() {
506 let content = resp.text().await?;
507 match content_type {
508 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
509 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Project`"))),
510 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::Project`")))),
511 }
512 } else {
513 let content = resp.text().await?;
514 let entity: Option<GetProjectError> = serde_json::from_str(&content).ok();
515 Err(Error::ResponseError(ResponseContent { status, content, entity }))
516 }
517}
518
519pub async fn get_project_deletable(configuration: &configuration::Configuration, params: GetProjectDeletableParams) -> Result<models::ProjectDeletable, Error<GetProjectDeletableError>> {
521
522 let uri_str = format!("{}/projects/{project_name_or_id}/_deletable", configuration.base_path, project_name_or_id=crate::apis::urlencode(params.project_name_or_id));
523 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
524
525 if let Some(ref user_agent) = configuration.user_agent {
526 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
527 }
528 if let Some(param_value) = params.x_request_id {
529 req_builder = req_builder.header("X-Request-Id", param_value.to_string());
530 }
531 if let Some(param_value) = params.x_is_resource_name {
532 req_builder = req_builder.header("X-Is-Resource-Name", param_value.to_string());
533 }
534 if let Some(ref auth_conf) = configuration.basic_auth {
535 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
536 };
537
538 let req = req_builder.build()?;
539 let resp = configuration.client.execute(req).await?;
540
541 let status = resp.status();
542 let content_type = resp
543 .headers()
544 .get("content-type")
545 .and_then(|v| v.to_str().ok())
546 .unwrap_or("application/octet-stream");
547 let content_type = super::ContentType::from(content_type);
548
549 if !status.is_client_error() && !status.is_server_error() {
550 let content = resp.text().await?;
551 match content_type {
552 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
553 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProjectDeletable`"))),
554 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::ProjectDeletable`")))),
555 }
556 } else {
557 let content = resp.text().await?;
558 let entity: Option<GetProjectDeletableError> = serde_json::from_str(&content).ok();
559 Err(Error::ResponseError(ResponseContent { status, content, entity }))
560 }
561}
562
563pub async fn get_project_summary(configuration: &configuration::Configuration, params: GetProjectSummaryParams) -> Result<models::ProjectSummary, Error<GetProjectSummaryError>> {
565
566 let uri_str = format!("{}/projects/{project_name_or_id}/summary", configuration.base_path, project_name_or_id=crate::apis::urlencode(params.project_name_or_id));
567 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
568
569 if let Some(ref user_agent) = configuration.user_agent {
570 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
571 }
572 if let Some(param_value) = params.x_request_id {
573 req_builder = req_builder.header("X-Request-Id", param_value.to_string());
574 }
575 if let Some(param_value) = params.x_is_resource_name {
576 req_builder = req_builder.header("X-Is-Resource-Name", param_value.to_string());
577 }
578 if let Some(ref auth_conf) = configuration.basic_auth {
579 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
580 };
581
582 let req = req_builder.build()?;
583 let resp = configuration.client.execute(req).await?;
584
585 let status = resp.status();
586 let content_type = resp
587 .headers()
588 .get("content-type")
589 .and_then(|v| v.to_str().ok())
590 .unwrap_or("application/octet-stream");
591 let content_type = super::ContentType::from(content_type);
592
593 if !status.is_client_error() && !status.is_server_error() {
594 let content = resp.text().await?;
595 match content_type {
596 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
597 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProjectSummary`"))),
598 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::ProjectSummary`")))),
599 }
600 } else {
601 let content = resp.text().await?;
602 let entity: Option<GetProjectSummaryError> = serde_json::from_str(&content).ok();
603 Err(Error::ResponseError(ResponseContent { status, content, entity }))
604 }
605}
606
607pub async fn get_scanner_of_project(configuration: &configuration::Configuration, params: GetScannerOfProjectParams) -> Result<models::ScannerRegistration, Error<GetScannerOfProjectError>> {
609
610 let uri_str = format!("{}/projects/{project_name_or_id}/scanner", configuration.base_path, project_name_or_id=crate::apis::urlencode(params.project_name_or_id));
611 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
612
613 if let Some(ref user_agent) = configuration.user_agent {
614 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
615 }
616 if let Some(param_value) = params.x_request_id {
617 req_builder = req_builder.header("X-Request-Id", param_value.to_string());
618 }
619 if let Some(param_value) = params.x_is_resource_name {
620 req_builder = req_builder.header("X-Is-Resource-Name", param_value.to_string());
621 }
622 if let Some(ref auth_conf) = configuration.basic_auth {
623 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
624 };
625
626 let req = req_builder.build()?;
627 let resp = configuration.client.execute(req).await?;
628
629 let status = resp.status();
630 let content_type = resp
631 .headers()
632 .get("content-type")
633 .and_then(|v| v.to_str().ok())
634 .unwrap_or("application/octet-stream");
635 let content_type = super::ContentType::from(content_type);
636
637 if !status.is_client_error() && !status.is_server_error() {
638 let content = resp.text().await?;
639 match content_type {
640 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
641 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ScannerRegistration`"))),
642 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::ScannerRegistration`")))),
643 }
644 } else {
645 let content = resp.text().await?;
646 let entity: Option<GetScannerOfProjectError> = serde_json::from_str(&content).ok();
647 Err(Error::ResponseError(ResponseContent { status, content, entity }))
648 }
649}
650
651pub async fn head_project(configuration: &configuration::Configuration, params: HeadProjectParams) -> Result<(), Error<HeadProjectError>> {
653
654 let uri_str = format!("{}/projects", configuration.base_path);
655 let mut req_builder = configuration.client.request(reqwest::Method::HEAD, &uri_str);
656
657 req_builder = req_builder.query(&[("project_name", ¶ms.project_name.to_string())]);
658 if let Some(ref user_agent) = configuration.user_agent {
659 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
660 }
661 if let Some(param_value) = params.x_request_id {
662 req_builder = req_builder.header("X-Request-Id", param_value.to_string());
663 }
664 if let Some(ref auth_conf) = configuration.basic_auth {
665 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
666 };
667
668 let req = req_builder.build()?;
669 let resp = configuration.client.execute(req).await?;
670
671 let status = resp.status();
672
673 if !status.is_client_error() && !status.is_server_error() {
674 Ok(())
675 } else {
676 let content = resp.text().await?;
677 let entity: Option<HeadProjectError> = serde_json::from_str(&content).ok();
678 Err(Error::ResponseError(ResponseContent { status, content, entity }))
679 }
680}
681
682pub async fn list_artifacts_of_project(configuration: &configuration::Configuration, params: ListArtifactsOfProjectParams) -> Result<Vec<models::Artifact>, Error<ListArtifactsOfProjectError>> {
684
685 let uri_str = format!("{}/projects/{project_name_or_id}/artifacts", configuration.base_path, project_name_or_id=crate::apis::urlencode(params.project_name_or_id));
686 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
687
688 if let Some(ref param_value) = params.q {
689 req_builder = req_builder.query(&[("q", ¶m_value.to_string())]);
690 }
691 if let Some(ref param_value) = params.sort {
692 req_builder = req_builder.query(&[("sort", ¶m_value.to_string())]);
693 }
694 if let Some(ref param_value) = params.page {
695 req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
696 }
697 if let Some(ref param_value) = params.page_size {
698 req_builder = req_builder.query(&[("page_size", ¶m_value.to_string())]);
699 }
700 if let Some(ref param_value) = params.with_tag {
701 req_builder = req_builder.query(&[("with_tag", ¶m_value.to_string())]);
702 }
703 if let Some(ref param_value) = params.with_label {
704 req_builder = req_builder.query(&[("with_label", ¶m_value.to_string())]);
705 }
706 if let Some(ref param_value) = params.with_scan_overview {
707 req_builder = req_builder.query(&[("with_scan_overview", ¶m_value.to_string())]);
708 }
709 if let Some(ref param_value) = params.with_sbom_overview {
710 req_builder = req_builder.query(&[("with_sbom_overview", ¶m_value.to_string())]);
711 }
712 if let Some(ref param_value) = params.with_immutable_status {
713 req_builder = req_builder.query(&[("with_immutable_status", ¶m_value.to_string())]);
714 }
715 if let Some(ref param_value) = params.with_accessory {
716 req_builder = req_builder.query(&[("with_accessory", ¶m_value.to_string())]);
717 }
718 if let Some(ref param_value) = params.latest_in_repository {
719 req_builder = req_builder.query(&[("latest_in_repository", ¶m_value.to_string())]);
720 }
721 if let Some(ref user_agent) = configuration.user_agent {
722 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
723 }
724 if let Some(param_value) = params.x_request_id {
725 req_builder = req_builder.header("X-Request-Id", param_value.to_string());
726 }
727 if let Some(param_value) = params.x_is_resource_name {
728 req_builder = req_builder.header("X-Is-Resource-Name", param_value.to_string());
729 }
730 if let Some(param_value) = params.x_accept_vulnerabilities {
731 req_builder = req_builder.header("X-Accept-Vulnerabilities", param_value.to_string());
732 }
733 if let Some(ref auth_conf) = configuration.basic_auth {
734 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
735 };
736
737 let req = req_builder.build()?;
738 let resp = configuration.client.execute(req).await?;
739
740 let status = resp.status();
741 let content_type = resp
742 .headers()
743 .get("content-type")
744 .and_then(|v| v.to_str().ok())
745 .unwrap_or("application/octet-stream");
746 let content_type = super::ContentType::from(content_type);
747
748 if !status.is_client_error() && !status.is_server_error() {
749 let content = resp.text().await?;
750 match content_type {
751 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
752 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::Artifact>`"))),
753 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::Artifact>`")))),
754 }
755 } else {
756 let content = resp.text().await?;
757 let entity: Option<ListArtifactsOfProjectError> = serde_json::from_str(&content).ok();
758 Err(Error::ResponseError(ResponseContent { status, content, entity }))
759 }
760}
761
762pub async fn list_projects(configuration: &configuration::Configuration, params: ListProjectsParams) -> Result<Vec<models::Project>, Error<ListProjectsError>> {
764
765 let uri_str = format!("{}/projects", configuration.base_path);
766 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
767
768 if let Some(ref param_value) = params.q {
769 req_builder = req_builder.query(&[("q", ¶m_value.to_string())]);
770 }
771 if let Some(ref param_value) = params.page {
772 req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
773 }
774 if let Some(ref param_value) = params.page_size {
775 req_builder = req_builder.query(&[("page_size", ¶m_value.to_string())]);
776 }
777 if let Some(ref param_value) = params.sort {
778 req_builder = req_builder.query(&[("sort", ¶m_value.to_string())]);
779 }
780 if let Some(ref param_value) = params.name {
781 req_builder = req_builder.query(&[("name", ¶m_value.to_string())]);
782 }
783 if let Some(ref param_value) = params.public {
784 req_builder = req_builder.query(&[("public", ¶m_value.to_string())]);
785 }
786 if let Some(ref param_value) = params.owner {
787 req_builder = req_builder.query(&[("owner", ¶m_value.to_string())]);
788 }
789 if let Some(ref param_value) = params.with_detail {
790 req_builder = req_builder.query(&[("with_detail", ¶m_value.to_string())]);
791 }
792 if let Some(ref user_agent) = configuration.user_agent {
793 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
794 }
795 if let Some(param_value) = params.x_request_id {
796 req_builder = req_builder.header("X-Request-Id", param_value.to_string());
797 }
798 if let Some(ref auth_conf) = configuration.basic_auth {
799 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
800 };
801
802 let req = req_builder.build()?;
803 let resp = configuration.client.execute(req).await?;
804
805 let status = resp.status();
806 let content_type = resp
807 .headers()
808 .get("content-type")
809 .and_then(|v| v.to_str().ok())
810 .unwrap_or("application/octet-stream");
811 let content_type = super::ContentType::from(content_type);
812
813 if !status.is_client_error() && !status.is_server_error() {
814 let content = resp.text().await?;
815 match content_type {
816 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
817 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::Project>`"))),
818 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::Project>`")))),
819 }
820 } else {
821 let content = resp.text().await?;
822 let entity: Option<ListProjectsError> = serde_json::from_str(&content).ok();
823 Err(Error::ResponseError(ResponseContent { status, content, entity }))
824 }
825}
826
827pub async fn list_scanner_candidates_of_project(configuration: &configuration::Configuration, params: ListScannerCandidatesOfProjectParams) -> Result<Vec<models::ScannerRegistration>, Error<ListScannerCandidatesOfProjectError>> {
829
830 let uri_str = format!("{}/projects/{project_name_or_id}/scanner/candidates", configuration.base_path, project_name_or_id=crate::apis::urlencode(params.project_name_or_id));
831 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
832
833 if let Some(ref param_value) = params.q {
834 req_builder = req_builder.query(&[("q", ¶m_value.to_string())]);
835 }
836 if let Some(ref param_value) = params.sort {
837 req_builder = req_builder.query(&[("sort", ¶m_value.to_string())]);
838 }
839 if let Some(ref param_value) = params.page {
840 req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
841 }
842 if let Some(ref param_value) = params.page_size {
843 req_builder = req_builder.query(&[("page_size", ¶m_value.to_string())]);
844 }
845 if let Some(ref user_agent) = configuration.user_agent {
846 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
847 }
848 if let Some(param_value) = params.x_request_id {
849 req_builder = req_builder.header("X-Request-Id", param_value.to_string());
850 }
851 if let Some(param_value) = params.x_is_resource_name {
852 req_builder = req_builder.header("X-Is-Resource-Name", param_value.to_string());
853 }
854 if let Some(ref auth_conf) = configuration.basic_auth {
855 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
856 };
857
858 let req = req_builder.build()?;
859 let resp = configuration.client.execute(req).await?;
860
861 let status = resp.status();
862 let content_type = resp
863 .headers()
864 .get("content-type")
865 .and_then(|v| v.to_str().ok())
866 .unwrap_or("application/octet-stream");
867 let content_type = super::ContentType::from(content_type);
868
869 if !status.is_client_error() && !status.is_server_error() {
870 let content = resp.text().await?;
871 match content_type {
872 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
873 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::ScannerRegistration>`"))),
874 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::ScannerRegistration>`")))),
875 }
876 } else {
877 let content = resp.text().await?;
878 let entity: Option<ListScannerCandidatesOfProjectError> = serde_json::from_str(&content).ok();
879 Err(Error::ResponseError(ResponseContent { status, content, entity }))
880 }
881}
882
883pub async fn set_scanner_of_project(configuration: &configuration::Configuration, params: SetScannerOfProjectParams) -> Result<(), Error<SetScannerOfProjectError>> {
885
886 let uri_str = format!("{}/projects/{project_name_or_id}/scanner", configuration.base_path, project_name_or_id=crate::apis::urlencode(params.project_name_or_id));
887 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
888
889 if let Some(ref user_agent) = configuration.user_agent {
890 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
891 }
892 if let Some(param_value) = params.x_request_id {
893 req_builder = req_builder.header("X-Request-Id", param_value.to_string());
894 }
895 if let Some(param_value) = params.x_is_resource_name {
896 req_builder = req_builder.header("X-Is-Resource-Name", param_value.to_string());
897 }
898 if let Some(ref auth_conf) = configuration.basic_auth {
899 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
900 };
901 req_builder = req_builder.json(¶ms.payload);
902
903 let req = req_builder.build()?;
904 let resp = configuration.client.execute(req).await?;
905
906 let status = resp.status();
907
908 if !status.is_client_error() && !status.is_server_error() {
909 Ok(())
910 } else {
911 let content = resp.text().await?;
912 let entity: Option<SetScannerOfProjectError> = serde_json::from_str(&content).ok();
913 Err(Error::ResponseError(ResponseContent { status, content, entity }))
914 }
915}
916
917pub async fn update_project(configuration: &configuration::Configuration, params: UpdateProjectParams) -> Result<(), Error<UpdateProjectError>> {
919
920 let uri_str = format!("{}/projects/{project_name_or_id}", configuration.base_path, project_name_or_id=crate::apis::urlencode(params.project_name_or_id));
921 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
922
923 if let Some(ref user_agent) = configuration.user_agent {
924 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
925 }
926 if let Some(param_value) = params.x_request_id {
927 req_builder = req_builder.header("X-Request-Id", param_value.to_string());
928 }
929 if let Some(param_value) = params.x_is_resource_name {
930 req_builder = req_builder.header("X-Is-Resource-Name", param_value.to_string());
931 }
932 if let Some(ref auth_conf) = configuration.basic_auth {
933 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
934 };
935 req_builder = req_builder.json(¶ms.project);
936
937 let req = req_builder.build()?;
938 let resp = configuration.client.execute(req).await?;
939
940 let status = resp.status();
941
942 if !status.is_client_error() && !status.is_server_error() {
943 Ok(())
944 } else {
945 let content = resp.text().await?;
946 let entity: Option<UpdateProjectError> = serde_json::from_str(&content).ok();
947 Err(Error::ResponseError(ResponseContent { status, content, entity }))
948 }
949}
950