/*
* CrowdStrike API Specification
*
* 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.
*
* The version of the OpenAPI document: rolling
*
* Generated by: https://openapi-generator.tech
*/
use super::{ContentType, Error, configuration};
use crate::{apis::ResponseContent, models};
use reqwest;
use serde::de::Error as _;
/// struct for typed errors of method [`aggregate_image_assessment_history`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum AggregateImageAssessmentHistoryError {
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::CoreEntitiesResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`aggregate_image_count`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum AggregateImageCountError {
Status400(models::CoreEntitiesResponse),
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::CoreEntitiesResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`aggregate_image_count_by_base_os`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum AggregateImageCountByBaseOsError {
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::CoreEntitiesResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`aggregate_image_count_by_state`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum AggregateImageCountByStateError {
Status400(models::CoreEntitiesResponse),
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::CoreEntitiesResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`combined_base_images`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CombinedBaseImagesError {
Status400(models::CoreEntitiesResponse),
Status403(models::MsaspecError),
Status429(models::MsaReplyMetaOnly),
Status500(models::CoreEntitiesResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`combined_image_by_vulnerability_count`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CombinedImageByVulnerabilityCountError {
Status400(models::CoreEntitiesResponse),
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::CoreEntitiesResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`combined_image_detail`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CombinedImageDetailError {
Status400(models::CoreEntitiesResponse),
Status403(models::MsaReplyMetaOnly),
Status404(models::CoreEntitiesResponse),
Status429(models::MsaReplyMetaOnly),
Status500(models::CoreEntitiesResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`combined_image_issues_summary`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CombinedImageIssuesSummaryError {
Status400(models::CoreEntitiesResponse),
Status403(models::MsaReplyMetaOnly),
Status404(models::CoreEntitiesResponse),
Status429(models::MsaReplyMetaOnly),
Status500(models::CoreEntitiesResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`combined_image_vulnerability_summary`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CombinedImageVulnerabilitySummaryError {
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::CoreEntitiesResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`create_base_images_entities`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateBaseImagesEntitiesError {
Status400(models::CoreEntitiesResponse),
Status403(models::MsaspecError),
Status429(models::MsaReplyMetaOnly),
Status500(models::CoreEntitiesResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`delete_base_images`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteBaseImagesError {
Status400(models::CoreEntitiesResponse),
Status403(models::MsaspecError),
Status429(models::MsaReplyMetaOnly),
Status500(models::CoreEntitiesResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_combined_images`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCombinedImagesError {
Status403(models::ImagesExtCombinedImagesResponse),
Status404(models::ImagesExtCombinedImagesResponse),
Status429(models::MsaReplyMetaOnly),
Status500(models::ImagesExtCombinedImagesResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`read_combined_images_export`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ReadCombinedImagesExportError {
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::CoreEntitiesResponse),
UnknownValue(serde_json::Value),
}
pub async fn aggregate_image_assessment_history(
configuration: &configuration::Configuration,
filter: Option<&str>,
) -> Result<models::ImagesApiImageAssessmentHistory, Error<AggregateImageAssessmentHistoryError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_filter = filter;
let uri_str = format!(
"{}/container-security/aggregates/images/assessment-history/v1",
configuration.base_path
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_filter {
req_builder = req_builder.query(&[("filter", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => {
return Err(Error::from(serde_json::Error::custom(
"Received `text/plain` content type response that cannot be converted to `models::ImagesApiImageAssessmentHistory`",
)));
}
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::ImagesApiImageAssessmentHistory`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<AggregateImageAssessmentHistoryError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn aggregate_image_count(
configuration: &configuration::Configuration,
filter: Option<&str>,
) -> Result<models::ImagesApiImageCount, Error<AggregateImageCountError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_filter = filter;
let uri_str = format!(
"{}/container-security/aggregates/images/count/v1",
configuration.base_path
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_filter {
req_builder = req_builder.query(&[("filter", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => {
return Err(Error::from(serde_json::Error::custom(
"Received `text/plain` content type response that cannot be converted to `models::ImagesApiImageCount`",
)));
}
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::ImagesApiImageCount`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<AggregateImageCountError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn aggregate_image_count_by_base_os(
configuration: &configuration::Configuration,
filter: Option<&str>,
) -> Result<models::ImagesApiImageCountByBaseOs, Error<AggregateImageCountByBaseOsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_filter = filter;
let uri_str = format!(
"{}/container-security/aggregates/images/count-by-os-distribution/v1",
configuration.base_path
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_filter {
req_builder = req_builder.query(&[("filter", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => {
return Err(Error::from(serde_json::Error::custom(
"Received `text/plain` content type response that cannot be converted to `models::ImagesApiImageCountByBaseOs`",
)));
}
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::ImagesApiImageCountByBaseOs`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<AggregateImageCountByBaseOsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn aggregate_image_count_by_state(
configuration: &configuration::Configuration,
filter: Option<&str>,
) -> Result<models::ImagesApiImageCountByState, Error<AggregateImageCountByStateError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_filter = filter;
let uri_str = format!(
"{}/container-security/aggregates/images/count-by-state/v1",
configuration.base_path
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_filter {
req_builder = req_builder.query(&[("filter", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => {
return Err(Error::from(serde_json::Error::custom(
"Received `text/plain` content type response that cannot be converted to `models::ImagesApiImageCountByState`",
)));
}
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::ImagesApiImageCountByState`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<AggregateImageCountByStateError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn combined_base_images(
configuration: &configuration::Configuration,
filter: Option<&str>,
) -> Result<models::CoreEntitiesResponse, Error<CombinedBaseImagesError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_filter = filter;
let uri_str = format!(
"{}/container-security/combined/base-images/v1",
configuration.base_path
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_filter {
req_builder = req_builder.query(&[("filter", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => {
return Err(Error::from(serde_json::Error::custom(
"Received `text/plain` content type response that cannot be converted to `models::CoreEntitiesResponse`",
)));
}
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`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<CombinedBaseImagesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn combined_image_by_vulnerability_count(
configuration: &configuration::Configuration,
filter: Option<&str>,
limit: Option<i32>,
offset: Option<i32>,
) -> Result<models::ImagesApiImageByVulnerabilityCount, Error<CombinedImageByVulnerabilityCountError>>
{
// add a prefix to parameters to efficiently prevent name collisions
let p_query_filter = filter;
let p_query_limit = limit;
let p_query_offset = offset;
let uri_str = format!(
"{}/container-security/combined/images/by-vulnerability-count/v1",
configuration.base_path
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_filter {
req_builder = req_builder.query(&[("filter", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_limit {
req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_offset {
req_builder = req_builder.query(&[("offset", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => {
return Err(Error::from(serde_json::Error::custom(
"Received `text/plain` content type response that cannot be converted to `models::ImagesApiImageByVulnerabilityCount`",
)));
}
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::ImagesApiImageByVulnerabilityCount`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<CombinedImageByVulnerabilityCountError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn combined_image_detail(
configuration: &configuration::Configuration,
filter: Option<&str>,
with_config: Option<bool>,
sort: Option<&str>,
limit: Option<i32>,
offset: Option<i32>,
) -> Result<models::ImagesApiCustomerAndImage, Error<CombinedImageDetailError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_filter = filter;
let p_query_with_config = with_config;
let p_query_sort = sort;
let p_query_limit = limit;
let p_query_offset = offset;
let uri_str = format!(
"{}/container-security/combined/images/detail/v1",
configuration.base_path
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_filter {
req_builder = req_builder.query(&[("filter", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_with_config {
req_builder = req_builder.query(&[("with_config", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_sort {
req_builder = req_builder.query(&[("sort", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_limit {
req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_offset {
req_builder = req_builder.query(&[("offset", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => {
return Err(Error::from(serde_json::Error::custom(
"Received `text/plain` content type response that cannot be converted to `models::ImagesApiCustomerAndImage`",
)));
}
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::ImagesApiCustomerAndImage`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<CombinedImageDetailError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn combined_image_issues_summary(
configuration: &configuration::Configuration,
cid: &str,
registry: &str,
repository: &str,
tag: &str,
image_digest: Option<&str>,
include_base_image_vuln: Option<bool>,
) -> Result<models::ImagesApiImageIssuesSummary, Error<CombinedImageIssuesSummaryError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_cid = cid;
let p_query_registry = registry;
let p_query_repository = repository;
let p_query_tag = tag;
let p_query_image_digest = image_digest;
let p_query_include_base_image_vuln = include_base_image_vuln;
let uri_str = format!(
"{}/container-security/combined/images/issues-summary/v1",
configuration.base_path
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("cid", &p_query_cid.to_string())]);
req_builder = req_builder.query(&[("registry", &p_query_registry.to_string())]);
req_builder = req_builder.query(&[("repository", &p_query_repository.to_string())]);
req_builder = req_builder.query(&[("tag", &p_query_tag.to_string())]);
if let Some(ref param_value) = p_query_image_digest {
req_builder = req_builder.query(&[("image_digest", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_include_base_image_vuln {
req_builder = req_builder.query(&[("include_base_image_vuln", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => {
return Err(Error::from(serde_json::Error::custom(
"Received `text/plain` content type response that cannot be converted to `models::ImagesApiImageIssuesSummary`",
)));
}
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::ImagesApiImageIssuesSummary`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<CombinedImageIssuesSummaryError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn combined_image_vulnerability_summary(
configuration: &configuration::Configuration,
cid: &str,
registry: &str,
repository: &str,
tag: &str,
image_digest: Option<&str>,
include_base_image_vuln: Option<bool>,
) -> Result<
models::ImagesApiImageVulnerabilitiesSummary,
Error<CombinedImageVulnerabilitySummaryError>,
> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_cid = cid;
let p_query_registry = registry;
let p_query_repository = repository;
let p_query_tag = tag;
let p_query_image_digest = image_digest;
let p_query_include_base_image_vuln = include_base_image_vuln;
let uri_str = format!(
"{}/container-security/combined/images/vulnerabilities-summary/v1",
configuration.base_path
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("cid", &p_query_cid.to_string())]);
req_builder = req_builder.query(&[("registry", &p_query_registry.to_string())]);
req_builder = req_builder.query(&[("repository", &p_query_repository.to_string())]);
req_builder = req_builder.query(&[("tag", &p_query_tag.to_string())]);
if let Some(ref param_value) = p_query_image_digest {
req_builder = req_builder.query(&[("image_digest", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_include_base_image_vuln {
req_builder = req_builder.query(&[("include_base_image_vuln", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => {
return Err(Error::from(serde_json::Error::custom(
"Received `text/plain` content type response that cannot be converted to `models::ImagesApiImageVulnerabilitiesSummary`",
)));
}
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::ImagesApiImageVulnerabilitiesSummary`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<CombinedImageVulnerabilitySummaryError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn create_base_images_entities(
configuration: &configuration::Configuration,
body: models::ModelsCreateBaseImagesRequest,
) -> Result<models::CoreEntitiesResponse, Error<CreateBaseImagesEntitiesError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_body = body;
let uri_str = format!(
"{}/container-security/entities/base-images/v1",
configuration.base_path
);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_body);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => {
return Err(Error::from(serde_json::Error::custom(
"Received `text/plain` content type response that cannot be converted to `models::CoreEntitiesResponse`",
)));
}
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`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<CreateBaseImagesEntitiesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn delete_base_images(
configuration: &configuration::Configuration,
ids: Vec<String>,
) -> Result<models::CoreEntitiesResponse, Error<DeleteBaseImagesError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_ids = ids;
let uri_str = format!(
"{}/container-security/entities/base-images/v1",
configuration.base_path
);
let mut req_builder = configuration
.client
.request(reqwest::Method::DELETE, &uri_str);
req_builder = match "csv" {
"multi" => req_builder.query(
&p_query_ids
.into_iter()
.map(|p| ("ids".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => req_builder.query(&[(
"ids",
&p_query_ids
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => {
return Err(Error::from(serde_json::Error::custom(
"Received `text/plain` content type response that cannot be converted to `models::CoreEntitiesResponse`",
)));
}
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`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<DeleteBaseImagesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_combined_images(
configuration: &configuration::Configuration,
filter: Option<&str>,
sort: Option<&str>,
limit: Option<i32>,
offset: Option<i32>,
) -> Result<models::ImagesExtCombinedImagesResponse, Error<GetCombinedImagesError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_filter = filter;
let p_query_sort = sort;
let p_query_limit = limit;
let p_query_offset = offset;
let uri_str = format!(
"{}/container-security/combined/image-assessment/images/v1",
configuration.base_path
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_filter {
req_builder = req_builder.query(&[("filter", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_sort {
req_builder = req_builder.query(&[("sort", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_limit {
req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_offset {
req_builder = req_builder.query(&[("offset", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => {
return Err(Error::from(serde_json::Error::custom(
"Received `text/plain` content type response that cannot be converted to `models::ImagesExtCombinedImagesResponse`",
)));
}
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::ImagesExtCombinedImagesResponse`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<GetCombinedImagesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn read_combined_images_export(
configuration: &configuration::Configuration,
filter: Option<&str>,
expand_vulnerabilities: Option<bool>,
expand_detections: Option<bool>,
limit: Option<i32>,
offset: Option<i32>,
sort: Option<&str>,
) -> Result<models::ImagesApiCombinedImageExport, Error<ReadCombinedImagesExportError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_filter = filter;
let p_query_expand_vulnerabilities = expand_vulnerabilities;
let p_query_expand_detections = expand_detections;
let p_query_limit = limit;
let p_query_offset = offset;
let p_query_sort = sort;
let uri_str = format!(
"{}/container-security/combined/images/export/v1",
configuration.base_path
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_filter {
req_builder = req_builder.query(&[("filter", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_expand_vulnerabilities {
req_builder = req_builder.query(&[("expand_vulnerabilities", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_expand_detections {
req_builder = req_builder.query(&[("expand_detections", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_limit {
req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_offset {
req_builder = req_builder.query(&[("offset", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_sort {
req_builder = req_builder.query(&[("sort", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => {
return Err(Error::from(serde_json::Error::custom(
"Received `text/plain` content type response that cannot be converted to `models::ImagesApiCombinedImageExport`",
)));
}
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::ImagesApiCombinedImageExport`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<ReadCombinedImagesExportError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}