rusty_falcon/apis/
falcon_container_image_api.rs

1/*
2 * CrowdStrike API Specification
3 *
4 * Use this API specification as a reference for the API endpoints you can use to interact with your Falcon environment. These endpoints support authentication via OAuth2 and interact with detections and network containment. For detailed usage guides and examples, see our [documentation inside the Falcon console](https://falcon.crowdstrike.com/support/documentation).     To use the APIs described below, combine the base URL with the path shown for each API endpoint. For commercial cloud customers, your base URL is `https://api.crowdstrike.com`.    Each API endpoint requires authorization via an OAuth2 token. Your first API request should retrieve an OAuth2 token using the `oauth2/token` endpoint, such as `https://api.crowdstrike.com/oauth2/token`. For subsequent requests, include the OAuth2 token in an HTTP authorization header. Tokens expire after 30 minutes, after which you should make a new token request to continue making API requests.
5 *
6 * The version of the OpenAPI document: rolling
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11use super::{configuration, ContentType, Error};
12use crate::{apis::ResponseContent, models};
13use reqwest;
14use serde::de::Error as _;
15
16/// struct for typed errors of method [`create_registry_entities`]
17#[derive(Debug, Clone, Serialize, Deserialize)]
18#[serde(untagged)]
19pub enum CreateRegistryEntitiesError {
20    Status400(models::DomainExternalRegistryResponse),
21    Status403(models::MsaReplyMetaOnly),
22    Status409(models::DomainExternalRegistryResponse),
23    Status429(models::MsaReplyMetaOnly),
24    Status500(models::DomainExternalRegistryResponse),
25    UnknownValue(serde_json::Value),
26}
27
28/// struct for typed errors of method [`delete_registry_entities`]
29#[derive(Debug, Clone, Serialize, Deserialize)]
30#[serde(untagged)]
31pub enum DeleteRegistryEntitiesError {
32    Status403(models::MsaReplyMetaOnly),
33    Status429(models::MsaReplyMetaOnly),
34    Status500(models::MsaReplyMetaOnly),
35    UnknownValue(serde_json::Value),
36}
37
38/// struct for typed errors of method [`download_export_file`]
39#[derive(Debug, Clone, Serialize, Deserialize)]
40#[serde(untagged)]
41pub enum DownloadExportFileError {
42    Status403(models::MsaReplyMetaOnly),
43    Status404(models::MsaspecResponseFields),
44    Status429(models::MsaReplyMetaOnly),
45    Status500(models::MsaspecResponseFields),
46    UnknownValue(serde_json::Value),
47}
48
49/// struct for typed errors of method [`get_report_by_reference`]
50#[derive(Debug, Clone, Serialize, Deserialize)]
51#[serde(untagged)]
52pub enum GetReportByReferenceError {
53    Status400(models::CoreEntitiesResponse),
54    Status403(models::MsaReplyMetaOnly),
55    Status404(models::CoreEntitiesResponse),
56    Status429(models::MsaReplyMetaOnly),
57    Status500(models::CoreEntitiesResponse),
58    UnknownValue(serde_json::Value),
59}
60
61/// struct for typed errors of method [`get_report_by_scan_id`]
62#[derive(Debug, Clone, Serialize, Deserialize)]
63#[serde(untagged)]
64pub enum GetReportByScanIdError {
65    Status400(models::CoreEntitiesResponse),
66    Status403(models::MsaReplyMetaOnly),
67    Status404(models::CoreEntitiesResponse),
68    Status429(models::MsaReplyMetaOnly),
69    Status500(models::CoreEntitiesResponse),
70    UnknownValue(serde_json::Value),
71}
72
73/// struct for typed errors of method [`head_image_scan_inventory`]
74#[derive(Debug, Clone, Serialize, Deserialize)]
75#[serde(untagged)]
76pub enum HeadImageScanInventoryError {
77    Status400(),
78    Status403(models::CoreEntitiesResponse),
79    Status429(models::MsaReplyMetaOnly),
80    Status500(),
81    UnknownValue(serde_json::Value),
82}
83
84/// struct for typed errors of method [`launch_export_job`]
85#[derive(Debug, Clone, Serialize, Deserialize)]
86#[serde(untagged)]
87pub enum LaunchExportJobError {
88    Status400(models::MsaspecResponseFields),
89    Status403(models::MsaReplyMetaOnly),
90    Status429(models::MsaspecResponseFields),
91    Status500(models::MsaspecResponseFields),
92    UnknownValue(serde_json::Value),
93}
94
95/// struct for typed errors of method [`policy_checks`]
96#[derive(Debug, Clone, Serialize, Deserialize)]
97#[serde(untagged)]
98pub enum PolicyChecksError {
99    Status400(models::ApiPolicyEntitiesResponse),
100    Status403(models::MsaReplyMetaOnly),
101    Status404(models::ApiPolicyEntitiesResponse),
102    Status429(models::MsaReplyMetaOnly),
103    Status500(models::ApiPolicyEntitiesResponse),
104    UnknownValue(serde_json::Value),
105}
106
107/// struct for typed errors of method [`post_image_scan_inventory`]
108#[derive(Debug, Clone, Serialize, Deserialize)]
109#[serde(untagged)]
110pub enum PostImageScanInventoryError {
111    Status400(),
112    Status403(models::CoreEntitiesResponse),
113    Status429(models::MsaReplyMetaOnly),
114    Status500(),
115    UnknownValue(serde_json::Value),
116}
117
118/// struct for typed errors of method [`query_export_jobs`]
119#[derive(Debug, Clone, Serialize, Deserialize)]
120#[serde(untagged)]
121pub enum QueryExportJobsError {
122    Status400(models::MsaspecResponseFields),
123    Status403(models::MsaReplyMetaOnly),
124    Status429(models::MsaReplyMetaOnly),
125    Status500(models::MsaspecResponseFields),
126    UnknownValue(serde_json::Value),
127}
128
129/// struct for typed errors of method [`read_export_jobs`]
130#[derive(Debug, Clone, Serialize, Deserialize)]
131#[serde(untagged)]
132pub enum ReadExportJobsError {
133    Status400(models::MsaspecResponseFields),
134    Status403(models::MsaReplyMetaOnly),
135    Status429(models::MsaReplyMetaOnly),
136    Status500(models::MsaspecResponseFields),
137    UnknownValue(serde_json::Value),
138}
139
140/// struct for typed errors of method [`read_registry_entities`]
141#[derive(Debug, Clone, Serialize, Deserialize)]
142#[serde(untagged)]
143pub enum ReadRegistryEntitiesError {
144    Status403(models::MsaReplyMetaOnly),
145    Status404(models::DomainExternalQueryResponse),
146    Status429(models::MsaReplyMetaOnly),
147    Status500(models::DomainExternalQueryResponse),
148    UnknownValue(serde_json::Value),
149}
150
151/// struct for typed errors of method [`read_registry_entities_by_uuid`]
152#[derive(Debug, Clone, Serialize, Deserialize)]
153#[serde(untagged)]
154pub enum ReadRegistryEntitiesByUuidError {
155    Status403(models::MsaReplyMetaOnly),
156    Status404(models::DomainExternalRegistryListResponse),
157    Status429(models::MsaReplyMetaOnly),
158    Status500(models::DomainExternalRegistryListResponse),
159    UnknownValue(serde_json::Value),
160}
161
162/// struct for typed errors of method [`update_registry_entities`]
163#[derive(Debug, Clone, Serialize, Deserialize)]
164#[serde(untagged)]
165pub enum UpdateRegistryEntitiesError {
166    Status400(models::DomainExternalRegistryResponse),
167    Status403(models::MsaReplyMetaOnly),
168    Status404(models::DomainExternalRegistryResponse),
169    Status429(models::MsaReplyMetaOnly),
170    Status500(models::DomainExternalRegistryResponse),
171    UnknownValue(serde_json::Value),
172}
173
174pub async fn create_registry_entities(
175    configuration: &configuration::Configuration,
176    body: models::RegistryassessmentExternalRegistryPayload,
177) -> Result<models::DomainExternalRegistryResponse, Error<CreateRegistryEntitiesError>> {
178    // add a prefix to parameters to efficiently prevent name collisions
179    let p_body_body = body;
180
181    let uri_str = format!(
182        "{}/container-security/entities/registries/v1",
183        configuration.base_path
184    );
185    let mut req_builder = configuration
186        .client
187        .request(reqwest::Method::POST, &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.oauth_access_token {
193        req_builder = req_builder.bearer_auth(token.to_owned());
194    };
195    req_builder = req_builder.json(&p_body_body);
196
197    let req = req_builder.build()?;
198    let resp = configuration.client.execute(req).await?;
199
200    let status = resp.status();
201    let content_type = resp
202        .headers()
203        .get("content-type")
204        .and_then(|v| v.to_str().ok())
205        .unwrap_or("application/octet-stream");
206    let content_type = super::ContentType::from(content_type);
207
208    if !status.is_client_error() && !status.is_server_error() {
209        let content = resp.text().await?;
210        match content_type {
211            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
212            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DomainExternalRegistryResponse`"))),
213            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::DomainExternalRegistryResponse`")))),
214        }
215    } else {
216        let content = resp.text().await?;
217        let entity: Option<CreateRegistryEntitiesError> = serde_json::from_str(&content).ok();
218        Err(Error::ResponseError(ResponseContent {
219            status,
220            content,
221            entity,
222        }))
223    }
224}
225
226pub async fn delete_registry_entities(
227    configuration: &configuration::Configuration,
228    ids: &str,
229) -> Result<models::DomainExternalRegistryListResponse, Error<DeleteRegistryEntitiesError>> {
230    // add a prefix to parameters to efficiently prevent name collisions
231    let p_query_ids = ids;
232
233    let uri_str = format!(
234        "{}/container-security/entities/registries/v1",
235        configuration.base_path
236    );
237    let mut req_builder = configuration
238        .client
239        .request(reqwest::Method::DELETE, &uri_str);
240
241    req_builder = req_builder.query(&[("ids", &p_query_ids.to_string())]);
242    if let Some(ref user_agent) = configuration.user_agent {
243        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
244    }
245    if let Some(ref token) = configuration.oauth_access_token {
246        req_builder = req_builder.bearer_auth(token.to_owned());
247    };
248
249    let req = req_builder.build()?;
250    let resp = configuration.client.execute(req).await?;
251
252    let status = resp.status();
253    let content_type = resp
254        .headers()
255        .get("content-type")
256        .and_then(|v| v.to_str().ok())
257        .unwrap_or("application/octet-stream");
258    let content_type = super::ContentType::from(content_type);
259
260    if !status.is_client_error() && !status.is_server_error() {
261        let content = resp.text().await?;
262        match content_type {
263            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
264            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DomainExternalRegistryListResponse`"))),
265            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::DomainExternalRegistryListResponse`")))),
266        }
267    } else {
268        let content = resp.text().await?;
269        let entity: Option<DeleteRegistryEntitiesError> = serde_json::from_str(&content).ok();
270        Err(Error::ResponseError(ResponseContent {
271            status,
272            content,
273            entity,
274        }))
275    }
276}
277
278pub async fn download_export_file(
279    configuration: &configuration::Configuration,
280    id: &str,
281) -> Result<Vec<i32>, Error<DownloadExportFileError>> {
282    // add a prefix to parameters to efficiently prevent name collisions
283    let p_query_id = id;
284
285    let uri_str = format!(
286        "{}/container-security/entities/exports/files/v1",
287        configuration.base_path
288    );
289    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
290
291    req_builder = req_builder.query(&[("id", &p_query_id.to_string())]);
292    if let Some(ref user_agent) = configuration.user_agent {
293        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
294    }
295    if let Some(ref token) = configuration.oauth_access_token {
296        req_builder = req_builder.bearer_auth(token.to_owned());
297    };
298
299    let req = req_builder.build()?;
300    let resp = configuration.client.execute(req).await?;
301
302    let status = resp.status();
303    let content_type = resp
304        .headers()
305        .get("content-type")
306        .and_then(|v| v.to_str().ok())
307        .unwrap_or("application/octet-stream");
308    let content_type = super::ContentType::from(content_type);
309
310    if !status.is_client_error() && !status.is_server_error() {
311        let content = resp.text().await?;
312        match content_type {
313            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
314            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;i32&gt;`"))),
315            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&lt;i32&gt;`")))),
316        }
317    } else {
318        let content = resp.text().await?;
319        let entity: Option<DownloadExportFileError> = serde_json::from_str(&content).ok();
320        Err(Error::ResponseError(ResponseContent {
321            status,
322            content,
323            entity,
324        }))
325    }
326}
327
328pub async fn get_report_by_reference(
329    configuration: &configuration::Configuration,
330    registry: Option<&str>,
331    repository: Option<&str>,
332    tag: Option<&str>,
333    image_id: Option<&str>,
334    digest: Option<&str>,
335    report_format: Option<&str>,
336) -> Result<models::CoreEntitiesResponse, Error<GetReportByReferenceError>> {
337    // add a prefix to parameters to efficiently prevent name collisions
338    let p_query_registry = registry;
339    let p_query_repository = repository;
340    let p_query_tag = tag;
341    let p_query_image_id = image_id;
342    let p_query_digest = digest;
343    let p_query_report_format = report_format;
344
345    let uri_str = format!(
346        "{}/image-assessment/entities/reports/v2",
347        configuration.base_path
348    );
349    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
350
351    if let Some(ref param_value) = p_query_registry {
352        req_builder = req_builder.query(&[("registry", &param_value.to_string())]);
353    }
354    if let Some(ref param_value) = p_query_repository {
355        req_builder = req_builder.query(&[("repository", &param_value.to_string())]);
356    }
357    if let Some(ref param_value) = p_query_tag {
358        req_builder = req_builder.query(&[("tag", &param_value.to_string())]);
359    }
360    if let Some(ref param_value) = p_query_image_id {
361        req_builder = req_builder.query(&[("image_id", &param_value.to_string())]);
362    }
363    if let Some(ref param_value) = p_query_digest {
364        req_builder = req_builder.query(&[("digest", &param_value.to_string())]);
365    }
366    if let Some(ref param_value) = p_query_report_format {
367        req_builder = req_builder.query(&[("report_format", &param_value.to_string())]);
368    }
369    if let Some(ref user_agent) = configuration.user_agent {
370        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
371    }
372    if let Some(ref token) = configuration.oauth_access_token {
373        req_builder = req_builder.bearer_auth(token.to_owned());
374    };
375
376    let req = req_builder.build()?;
377    let resp = configuration.client.execute(req).await?;
378
379    let status = resp.status();
380    let content_type = resp
381        .headers()
382        .get("content-type")
383        .and_then(|v| v.to_str().ok())
384        .unwrap_or("application/octet-stream");
385    let content_type = super::ContentType::from(content_type);
386
387    if !status.is_client_error() && !status.is_server_error() {
388        let content = resp.text().await?;
389        match content_type {
390            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
391            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CoreEntitiesResponse`"))),
392            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::CoreEntitiesResponse`")))),
393        }
394    } else {
395        let content = resp.text().await?;
396        let entity: Option<GetReportByReferenceError> = serde_json::from_str(&content).ok();
397        Err(Error::ResponseError(ResponseContent {
398            status,
399            content,
400            entity,
401        }))
402    }
403}
404
405pub async fn get_report_by_scan_id(
406    configuration: &configuration::Configuration,
407    uuid: &str,
408    report_format: Option<&str>,
409) -> Result<models::CoreEntitiesResponse, Error<GetReportByScanIdError>> {
410    // add a prefix to parameters to efficiently prevent name collisions
411    let p_path_uuid = uuid;
412    let p_query_report_format = report_format;
413
414    let uri_str = format!(
415        "{}/image-assessment/entities/reports/v2/{uuid}",
416        configuration.base_path,
417        uuid = crate::apis::urlencode(p_path_uuid)
418    );
419    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
420
421    if let Some(ref param_value) = p_query_report_format {
422        req_builder = req_builder.query(&[("report_format", &param_value.to_string())]);
423    }
424    if let Some(ref user_agent) = configuration.user_agent {
425        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
426    }
427    if let Some(ref token) = configuration.oauth_access_token {
428        req_builder = req_builder.bearer_auth(token.to_owned());
429    };
430
431    let req = req_builder.build()?;
432    let resp = configuration.client.execute(req).await?;
433
434    let status = resp.status();
435    let content_type = resp
436        .headers()
437        .get("content-type")
438        .and_then(|v| v.to_str().ok())
439        .unwrap_or("application/octet-stream");
440    let content_type = super::ContentType::from(content_type);
441
442    if !status.is_client_error() && !status.is_server_error() {
443        let content = resp.text().await?;
444        match content_type {
445            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
446            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CoreEntitiesResponse`"))),
447            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::CoreEntitiesResponse`")))),
448        }
449    } else {
450        let content = resp.text().await?;
451        let entity: Option<GetReportByScanIdError> = serde_json::from_str(&content).ok();
452        Err(Error::ResponseError(ResponseContent {
453            status,
454            content,
455            entity,
456        }))
457    }
458}
459
460pub async fn head_image_scan_inventory(
461    configuration: &configuration::Configuration,
462) -> Result<(), Error<HeadImageScanInventoryError>> {
463    let uri_str = format!(
464        "{}/image-assessment/entities/image-inventory/v1",
465        configuration.base_path
466    );
467    let mut req_builder = configuration
468        .client
469        .request(reqwest::Method::HEAD, &uri_str);
470
471    if let Some(ref user_agent) = configuration.user_agent {
472        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
473    }
474    if let Some(ref token) = configuration.oauth_access_token {
475        req_builder = req_builder.bearer_auth(token.to_owned());
476    };
477
478    let req = req_builder.build()?;
479    let resp = configuration.client.execute(req).await?;
480
481    let status = resp.status();
482
483    if !status.is_client_error() && !status.is_server_error() {
484        Ok(())
485    } else {
486        let content = resp.text().await?;
487        let entity: Option<HeadImageScanInventoryError> = serde_json::from_str(&content).ok();
488        Err(Error::ResponseError(ResponseContent {
489            status,
490            content,
491            entity,
492        }))
493    }
494}
495
496pub async fn launch_export_job(
497    configuration: &configuration::Configuration,
498    body: models::ExportsLaunchExportRequest,
499) -> Result<models::ExportsLaunchExportResponse, Error<LaunchExportJobError>> {
500    // add a prefix to parameters to efficiently prevent name collisions
501    let p_body_body = body;
502
503    let uri_str = format!(
504        "{}/container-security/entities/exports/v1",
505        configuration.base_path
506    );
507    let mut req_builder = configuration
508        .client
509        .request(reqwest::Method::POST, &uri_str);
510
511    if let Some(ref user_agent) = configuration.user_agent {
512        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
513    }
514    if let Some(ref token) = configuration.oauth_access_token {
515        req_builder = req_builder.bearer_auth(token.to_owned());
516    };
517    req_builder = req_builder.json(&p_body_body);
518
519    let req = req_builder.build()?;
520    let resp = configuration.client.execute(req).await?;
521
522    let status = resp.status();
523    let content_type = resp
524        .headers()
525        .get("content-type")
526        .and_then(|v| v.to_str().ok())
527        .unwrap_or("application/octet-stream");
528    let content_type = super::ContentType::from(content_type);
529
530    if !status.is_client_error() && !status.is_server_error() {
531        let content = resp.text().await?;
532        match content_type {
533            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
534            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ExportsLaunchExportResponse`"))),
535            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::ExportsLaunchExportResponse`")))),
536        }
537    } else {
538        let content = resp.text().await?;
539        let entity: Option<LaunchExportJobError> = serde_json::from_str(&content).ok();
540        Err(Error::ResponseError(ResponseContent {
541            status,
542            content,
543            entity,
544        }))
545    }
546}
547
548pub async fn policy_checks(
549    configuration: &configuration::Configuration,
550    repository: &str,
551    tag: &str,
552    registry: Option<&str>,
553) -> Result<models::ApiPolicyEntitiesResponse, Error<PolicyChecksError>> {
554    // add a prefix to parameters to efficiently prevent name collisions
555    let p_query_repository = repository;
556    let p_query_tag = tag;
557    let p_query_registry = registry;
558
559    let uri_str = format!(
560        "{}/image-assessment/entities/policy-checks/v2",
561        configuration.base_path
562    );
563    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
564
565    if let Some(ref param_value) = p_query_registry {
566        req_builder = req_builder.query(&[("registry", &param_value.to_string())]);
567    }
568    req_builder = req_builder.query(&[("repository", &p_query_repository.to_string())]);
569    req_builder = req_builder.query(&[("tag", &p_query_tag.to_string())]);
570    if let Some(ref user_agent) = configuration.user_agent {
571        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
572    }
573    if let Some(ref token) = configuration.oauth_access_token {
574        req_builder = req_builder.bearer_auth(token.to_owned());
575    };
576
577    let req = req_builder.build()?;
578    let resp = configuration.client.execute(req).await?;
579
580    let status = resp.status();
581    let content_type = resp
582        .headers()
583        .get("content-type")
584        .and_then(|v| v.to_str().ok())
585        .unwrap_or("application/octet-stream");
586    let content_type = super::ContentType::from(content_type);
587
588    if !status.is_client_error() && !status.is_server_error() {
589        let content = resp.text().await?;
590        match content_type {
591            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
592            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ApiPolicyEntitiesResponse`"))),
593            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::ApiPolicyEntitiesResponse`")))),
594        }
595    } else {
596        let content = resp.text().await?;
597        let entity: Option<PolicyChecksError> = serde_json::from_str(&content).ok();
598        Err(Error::ResponseError(ResponseContent {
599            status,
600            content,
601            entity,
602        }))
603    }
604}
605
606pub async fn post_image_scan_inventory(
607    configuration: &configuration::Configuration,
608    body: models::ModelsInventoryScanRequestType,
609) -> Result<(), Error<PostImageScanInventoryError>> {
610    // add a prefix to parameters to efficiently prevent name collisions
611    let p_body_body = body;
612
613    let uri_str = format!(
614        "{}/image-assessment/entities/image-inventory/v1",
615        configuration.base_path
616    );
617    let mut req_builder = configuration
618        .client
619        .request(reqwest::Method::POST, &uri_str);
620
621    if let Some(ref user_agent) = configuration.user_agent {
622        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
623    }
624    if let Some(ref token) = configuration.oauth_access_token {
625        req_builder = req_builder.bearer_auth(token.to_owned());
626    };
627    req_builder = req_builder.json(&p_body_body);
628
629    let req = req_builder.build()?;
630    let resp = configuration.client.execute(req).await?;
631
632    let status = resp.status();
633
634    if !status.is_client_error() && !status.is_server_error() {
635        Ok(())
636    } else {
637        let content = resp.text().await?;
638        let entity: Option<PostImageScanInventoryError> = serde_json::from_str(&content).ok();
639        Err(Error::ResponseError(ResponseContent {
640            status,
641            content,
642            entity,
643        }))
644    }
645}
646
647pub async fn query_export_jobs(
648    configuration: &configuration::Configuration,
649    filter: Option<&str>,
650) -> Result<models::MsaspecQueryResponse, Error<QueryExportJobsError>> {
651    // add a prefix to parameters to efficiently prevent name collisions
652    let p_query_filter = filter;
653
654    let uri_str = format!(
655        "{}/container-security/queries/exports/v1",
656        configuration.base_path
657    );
658    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
659
660    if let Some(ref param_value) = p_query_filter {
661        req_builder = req_builder.query(&[("filter", &param_value.to_string())]);
662    }
663    if let Some(ref user_agent) = configuration.user_agent {
664        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
665    }
666    if let Some(ref token) = configuration.oauth_access_token {
667        req_builder = req_builder.bearer_auth(token.to_owned());
668    };
669
670    let req = req_builder.build()?;
671    let resp = configuration.client.execute(req).await?;
672
673    let status = resp.status();
674    let content_type = resp
675        .headers()
676        .get("content-type")
677        .and_then(|v| v.to_str().ok())
678        .unwrap_or("application/octet-stream");
679    let content_type = super::ContentType::from(content_type);
680
681    if !status.is_client_error() && !status.is_server_error() {
682        let content = resp.text().await?;
683        match content_type {
684            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
685            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::MsaspecQueryResponse`"))),
686            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::MsaspecQueryResponse`")))),
687        }
688    } else {
689        let content = resp.text().await?;
690        let entity: Option<QueryExportJobsError> = serde_json::from_str(&content).ok();
691        Err(Error::ResponseError(ResponseContent {
692            status,
693            content,
694            entity,
695        }))
696    }
697}
698
699pub async fn read_export_jobs(
700    configuration: &configuration::Configuration,
701    ids: Vec<String>,
702) -> Result<models::ExportsExportsResponse, Error<ReadExportJobsError>> {
703    // add a prefix to parameters to efficiently prevent name collisions
704    let p_query_ids = ids;
705
706    let uri_str = format!(
707        "{}/container-security/entities/exports/v1",
708        configuration.base_path
709    );
710    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
711
712    req_builder = match "csv" {
713        "multi" => req_builder.query(
714            &p_query_ids
715                .into_iter()
716                .map(|p| ("ids".to_owned(), p.to_string()))
717                .collect::<Vec<(std::string::String, std::string::String)>>(),
718        ),
719        _ => req_builder.query(&[(
720            "ids",
721            &p_query_ids
722                .into_iter()
723                .map(|p| p.to_string())
724                .collect::<Vec<String>>()
725                .join(",")
726                .to_string(),
727        )]),
728    };
729    if let Some(ref user_agent) = configuration.user_agent {
730        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
731    }
732    if let Some(ref token) = configuration.oauth_access_token {
733        req_builder = req_builder.bearer_auth(token.to_owned());
734    };
735
736    let req = req_builder.build()?;
737    let resp = configuration.client.execute(req).await?;
738
739    let status = resp.status();
740    let content_type = resp
741        .headers()
742        .get("content-type")
743        .and_then(|v| v.to_str().ok())
744        .unwrap_or("application/octet-stream");
745    let content_type = super::ContentType::from(content_type);
746
747    if !status.is_client_error() && !status.is_server_error() {
748        let content = resp.text().await?;
749        match content_type {
750            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
751            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ExportsExportsResponse`"))),
752            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::ExportsExportsResponse`")))),
753        }
754    } else {
755        let content = resp.text().await?;
756        let entity: Option<ReadExportJobsError> = serde_json::from_str(&content).ok();
757        Err(Error::ResponseError(ResponseContent {
758            status,
759            content,
760            entity,
761        }))
762    }
763}
764
765pub async fn read_registry_entities(
766    configuration: &configuration::Configuration,
767    limit: Option<i32>,
768    offset: Option<i32>,
769    sort: Option<&str>,
770) -> Result<models::DomainExternalQueryResponse, Error<ReadRegistryEntitiesError>> {
771    // add a prefix to parameters to efficiently prevent name collisions
772    let p_query_limit = limit;
773    let p_query_offset = offset;
774    let p_query_sort = sort;
775
776    let uri_str = format!(
777        "{}/container-security/queries/registries/v1",
778        configuration.base_path
779    );
780    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
781
782    if let Some(ref param_value) = p_query_limit {
783        req_builder = req_builder.query(&[("limit", &param_value.to_string())]);
784    }
785    if let Some(ref param_value) = p_query_offset {
786        req_builder = req_builder.query(&[("offset", &param_value.to_string())]);
787    }
788    if let Some(ref param_value) = p_query_sort {
789        req_builder = req_builder.query(&[("sort", &param_value.to_string())]);
790    }
791    if let Some(ref user_agent) = configuration.user_agent {
792        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
793    }
794    if let Some(ref token) = configuration.oauth_access_token {
795        req_builder = req_builder.bearer_auth(token.to_owned());
796    };
797
798    let req = req_builder.build()?;
799    let resp = configuration.client.execute(req).await?;
800
801    let status = resp.status();
802    let content_type = resp
803        .headers()
804        .get("content-type")
805        .and_then(|v| v.to_str().ok())
806        .unwrap_or("application/octet-stream");
807    let content_type = super::ContentType::from(content_type);
808
809    if !status.is_client_error() && !status.is_server_error() {
810        let content = resp.text().await?;
811        match content_type {
812            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
813            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DomainExternalQueryResponse`"))),
814            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::DomainExternalQueryResponse`")))),
815        }
816    } else {
817        let content = resp.text().await?;
818        let entity: Option<ReadRegistryEntitiesError> = serde_json::from_str(&content).ok();
819        Err(Error::ResponseError(ResponseContent {
820            status,
821            content,
822            entity,
823        }))
824    }
825}
826
827pub async fn read_registry_entities_by_uuid(
828    configuration: &configuration::Configuration,
829    ids: &str,
830) -> Result<models::DomainExternalRegistryListResponse, Error<ReadRegistryEntitiesByUuidError>> {
831    // add a prefix to parameters to efficiently prevent name collisions
832    let p_query_ids = ids;
833
834    let uri_str = format!(
835        "{}/container-security/entities/registries/v1",
836        configuration.base_path
837    );
838    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
839
840    req_builder = req_builder.query(&[("ids", &p_query_ids.to_string())]);
841    if let Some(ref user_agent) = configuration.user_agent {
842        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
843    }
844    if let Some(ref token) = configuration.oauth_access_token {
845        req_builder = req_builder.bearer_auth(token.to_owned());
846    };
847
848    let req = req_builder.build()?;
849    let resp = configuration.client.execute(req).await?;
850
851    let status = resp.status();
852    let content_type = resp
853        .headers()
854        .get("content-type")
855        .and_then(|v| v.to_str().ok())
856        .unwrap_or("application/octet-stream");
857    let content_type = super::ContentType::from(content_type);
858
859    if !status.is_client_error() && !status.is_server_error() {
860        let content = resp.text().await?;
861        match content_type {
862            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
863            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DomainExternalRegistryListResponse`"))),
864            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::DomainExternalRegistryListResponse`")))),
865        }
866    } else {
867        let content = resp.text().await?;
868        let entity: Option<ReadRegistryEntitiesByUuidError> = serde_json::from_str(&content).ok();
869        Err(Error::ResponseError(ResponseContent {
870            status,
871            content,
872            entity,
873        }))
874    }
875}
876
877pub async fn update_registry_entities(
878    configuration: &configuration::Configuration,
879    id: &str,
880    body: models::RegistryassessmentExternalRegistryPatchPayload,
881) -> Result<models::DomainExternalRegistryResponse, Error<UpdateRegistryEntitiesError>> {
882    // add a prefix to parameters to efficiently prevent name collisions
883    let p_query_id = id;
884    let p_body_body = body;
885
886    let uri_str = format!(
887        "{}/container-security/entities/registries/v1",
888        configuration.base_path
889    );
890    let mut req_builder = configuration
891        .client
892        .request(reqwest::Method::PATCH, &uri_str);
893
894    req_builder = req_builder.query(&[("id", &p_query_id.to_string())]);
895    if let Some(ref user_agent) = configuration.user_agent {
896        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
897    }
898    if let Some(ref token) = configuration.oauth_access_token {
899        req_builder = req_builder.bearer_auth(token.to_owned());
900    };
901    req_builder = req_builder.json(&p_body_body);
902
903    let req = req_builder.build()?;
904    let resp = configuration.client.execute(req).await?;
905
906    let status = resp.status();
907    let content_type = resp
908        .headers()
909        .get("content-type")
910        .and_then(|v| v.to_str().ok())
911        .unwrap_or("application/octet-stream");
912    let content_type = super::ContentType::from(content_type);
913
914    if !status.is_client_error() && !status.is_server_error() {
915        let content = resp.text().await?;
916        match content_type {
917            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
918            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DomainExternalRegistryResponse`"))),
919            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::DomainExternalRegistryResponse`")))),
920        }
921    } else {
922        let content = resp.text().await?;
923        let entity: Option<UpdateRegistryEntitiesError> = serde_json::from_str(&content).ok();
924        Err(Error::ResponseError(ResponseContent {
925            status,
926            content,
927            entity,
928        }))
929    }
930}