/*
* 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 [`azure_download_certificate`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum AzureDownloadCertificateError {
Status400(models::RegistrationAzureDownloadCertificateResponseV1),
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::RegistrationAzureDownloadCertificateResponseV1),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`azure_refresh_certificate`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum AzureRefreshCertificateError {
Status400(models::RegistrationAzureDownloadCertificateResponseV1),
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::RegistrationAzureDownloadCertificateResponseV1),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`connect_cspmgcp_account`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ConnectCspmgcpAccountError {
Status400(models::RegistrationGcpAccountResponseExtV2),
Status403(models::MsaReplyMetaOnly),
Status409(models::RegistrationGcpAccountResponseExtV2),
Status429(models::MsaReplyMetaOnly),
Status500(models::RegistrationGcpAccountResponseExtV2),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`create_cspm_aws_account`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateCspmAwsAccountError {
Status400(models::MsaspecResponseFields),
Status403(models::MsaspecResponseFields),
Status409(models::MsaspecResponseFields),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaspecResponseFields),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`create_cspm_azure_account`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateCspmAzureAccountError {
Status400(models::RegistrationAzureAccountResponseV1),
Status403(models::MsaReplyMetaOnly),
Status409(models::RegistrationAzureAccountResponseV1),
Status429(models::MsaReplyMetaOnly),
Status500(models::RegistrationAzureAccountResponseV1),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`create_cspm_azure_management_group`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateCspmAzureManagementGroupError {
Status400(models::RegistrationAzureAccountResponseV1),
Status403(models::MsaspecResponseFields),
Status429(models::MsaReplyMetaOnly),
Status500(models::RegistrationAzureAccountResponseV1),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`create_cspmgcp_account`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateCspmgcpAccountError {
Status400(models::RegistrationGcpAccountResponseV1),
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::RegistrationGcpAccountResponseV1),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`delete_cspm_aws_account`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteCspmAwsAccountError {
Status400(models::MsaspecResponseFields),
Status403(models::MsaspecResponseFields),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaspecResponseFields),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`delete_cspm_azure_account`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteCspmAzureAccountError {
Status400(models::MsaBaseEntitiesResponse),
Status403(models::MsaReplyMetaOnly),
Status404(models::MsaBaseEntitiesResponse),
Status429(models::MsaReplyMetaOnly),
Status500(models::RegistrationAzureAccountResponseV1),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`delete_cspm_azure_management_group`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteCspmAzureManagementGroupError {
Status400(models::MsaspecResponseFields),
Status403(models::MsaspecResponseFields),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaspecResponseFields),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`delete_cspmgcp_account`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteCspmgcpAccountError {
Status400(models::MsaBaseEntitiesResponse),
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaBaseEntitiesResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_behavior_detections`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetBehaviorDetectionsError {
Status400(models::RegistrationExternalIoaEventResponse),
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::RegistrationExternalIoaEventResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_cloud_event_ids`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCloudEventIdsError {
Status400(models::MsaspecResponseFields),
Status403(models::MsaspecResponseFields),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaspecResponseFields),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_configuration_detection_entities`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetConfigurationDetectionEntitiesError {
Status400(models::MsaReplyMetaOnly),
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaReplyMetaOnly),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_configuration_detection_ids_v2`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetConfigurationDetectionIdsV2Error {
Status400(models::MsaspecMetaInfo),
Status403(models::MsaspecMetaInfo),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaspecMetaInfo),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_configuration_detections`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetConfigurationDetectionsError {
Status400(models::RegistrationExternalIomEventResponse),
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaReplyMetaOnly),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_cspm_aws_account`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCspmAwsAccountError {
Status400(models::MsaspecResponseFields),
Status403(models::MsaspecResponseFields),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaspecResponseFields),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_cspm_aws_console_setup_urls`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCspmAwsConsoleSetupUrlsError {
Status400(models::MsaspecResponseFields),
Status403(models::MsaspecResponseFields),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaspecResponseFields),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_cspm_azure_account`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCspmAzureAccountError {
Status400(models::RegistrationAzureAccountResponseV1),
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::RegistrationAzureAccountResponseV1),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_cspm_azure_management_group`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCspmAzureManagementGroupError {
Status400(models::RegistrationAzureManagementGroupResponseV1),
Status403(models::MsaspecResponseFields),
Status429(models::MsaReplyMetaOnly),
Status500(models::RegistrationAzureManagementGroupResponseV1),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_cspm_azure_user_scripts_attachment`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCspmAzureUserScriptsAttachmentError {
Status400(models::RegistrationAzureProvisionGetUserScriptResponseV1),
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::RegistrationAzureProvisionGetUserScriptResponseV1),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_cspm_policies_details`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCspmPoliciesDetailsError {
Status400(models::RegistrationPolicyResponseV1),
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::RegistrationPolicyResponseV1),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_cspm_policy`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCspmPolicyError {
Status400(models::RegistrationPolicyResponseV1),
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::RegistrationPolicyResponseV1),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_cspm_policy_settings`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCspmPolicySettingsError {
Status400(models::RegistrationPolicySettingsResponseV1),
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::RegistrationPolicySettingsResponseV1),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_cspm_scan_schedule`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCspmScanScheduleError {
Status400(models::RegistrationScanScheduleResponseV1),
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::RegistrationScanScheduleResponseV1),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_cspmcgp_account`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCspmcgpAccountError {
Status400(models::RegistrationGcpAccountResponseV1),
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::RegistrationGcpAccountResponseV1),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_cspmgcp_service_accounts_ext`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCspmgcpServiceAccountsExtError {
Status400(models::RegistrationGcpServiceAccountResponseExtV1),
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::RegistrationGcpServiceAccountResponseExtV1),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_cspmgcp_user_scripts_attachment`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCspmgcpUserScriptsAttachmentError {
Status400(models::RegistrationGcpProvisionGetUserScriptResponseV1),
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::RegistrationGcpProvisionGetUserScriptResponseV1),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_cspmgcp_validate_accounts_ext`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCspmgcpValidateAccountsExtError {
Status400(models::RegistrationGcpAccountValidationResponseV1),
Status403(models::MsaspecResponseFields),
Status404(models::RegistrationGcpAccountValidationResponseV1),
Status429(models::MsaReplyMetaOnly),
Status500(models::RegistrationGcpAccountValidationResponseV1),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`patch_cspm_aws_account`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PatchCspmAwsAccountError {
Status400(models::MsaspecResponseFields),
Status403(models::MsaspecResponseFields),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaspecResponseFields),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`update_cspm_azure_account`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateCspmAzureAccountError {
Status400(models::RegistrationAzureAccountResponseV1),
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::RegistrationAzureAccountResponseV1),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`update_cspm_azure_account_client_id`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateCspmAzureAccountClientIdError {
Status400(models::RegistrationAzureTenantConfigurationResponseV1),
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::RegistrationAzureTenantConfigurationResponseV1),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`update_cspm_azure_tenant_default_subscription_id`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateCspmAzureTenantDefaultSubscriptionIdError {
Status400(models::RegistrationAzureTenantDefaultSubscriptionIdResponseV1),
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::RegistrationAzureTenantDefaultSubscriptionIdResponseV1),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`update_cspm_policy_settings`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateCspmPolicySettingsError {
Status400(models::RegistrationPolicySettingsResponseV1),
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::RegistrationPolicySettingsResponseV1),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`update_cspm_scan_schedule`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateCspmScanScheduleError {
Status400(models::RegistrationScanScheduleResponseV1),
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::RegistrationScanScheduleResponseV1),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`update_cspmgcp_account`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateCspmgcpAccountError {
Status400(models::RegistrationGcpAccountResponseV1),
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::RegistrationGcpAccountResponseV1),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`update_cspmgcp_service_accounts_ext`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateCspmgcpServiceAccountsExtError {
Status400(models::RegistrationGcpServiceAccountResponseExtV1),
Status403(models::MsaspecResponseFields),
Status429(models::MsaReplyMetaOnly),
Status500(models::RegistrationGcpServiceAccountResponseExtV1),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`validate_cspmgcp_service_account_ext`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ValidateCspmgcpServiceAccountExtError {
Status400(models::RegistrationGcpServiceAccountValidationResponseV1),
Status403(models::MsaspecResponseFields),
Status404(models::RegistrationGcpServiceAccountValidationResponseV1),
Status429(models::MsaReplyMetaOnly),
Status500(models::RegistrationGcpServiceAccountValidationResponseV1),
UnknownValue(serde_json::Value),
}
pub async fn azure_download_certificate(
configuration: &configuration::Configuration,
tenant_id: Vec<String>,
) -> Result<
models::RegistrationAzureDownloadCertificateResponseV1,
Error<AzureDownloadCertificateError>,
> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_tenant_id = tenant_id;
let uri_str = format!(
"{}/cloud-connect-cspm-azure/entities/download-certificate/v1",
configuration.base_path
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = match "multi" {
"multi" => req_builder.query(
&p_query_tenant_id
.into_iter()
.map(|p| ("tenant_id".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => req_builder.query(&[(
"tenant_id",
&p_query_tenant_id
.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::RegistrationAzureDownloadCertificateResponseV1`",
)));
}
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::RegistrationAzureDownloadCertificateResponseV1`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<AzureDownloadCertificateError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn azure_refresh_certificate(
configuration: &configuration::Configuration,
tenant_id: Vec<String>,
years_valid: Option<&str>,
) -> Result<
models::RegistrationAzureDownloadCertificateResponseV1,
Error<AzureRefreshCertificateError>,
> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_tenant_id = tenant_id;
let p_query_years_valid = years_valid;
let uri_str = format!(
"{}/cloud-connect-cspm-azure/entities/refresh-certificate/v1",
configuration.base_path
);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
req_builder = match "multi" {
"multi" => req_builder.query(
&p_query_tenant_id
.into_iter()
.map(|p| ("tenant_id".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => req_builder.query(&[(
"tenant_id",
&p_query_tenant_id
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
if let Some(ref param_value) = p_query_years_valid {
req_builder = req_builder.query(&[("years_valid", ¶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::RegistrationAzureDownloadCertificateResponseV1`",
)));
}
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::RegistrationAzureDownloadCertificateResponseV1`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<AzureRefreshCertificateError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn connect_cspmgcp_account(
configuration: &configuration::Configuration,
body: models::RegistrationGcpAccountExtRequestV2,
) -> Result<models::RegistrationGcpAccountResponseExtV2, Error<ConnectCspmgcpAccountError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_body = body;
let uri_str = format!(
"{}/cloud-connect-cspm-gcp/entities/account/v2",
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::RegistrationGcpAccountResponseExtV2`",
)));
}
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::RegistrationGcpAccountResponseExtV2`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<ConnectCspmgcpAccountError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn create_cspm_aws_account(
configuration: &configuration::Configuration,
body: models::RegistrationAwsAccountCreateRequestExtV2,
) -> Result<models::RegistrationAwsAccountResponseV2, Error<CreateCspmAwsAccountError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_body = body;
let uri_str = format!(
"{}/cloud-connect-cspm-aws/entities/account/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::RegistrationAwsAccountResponseV2`",
)));
}
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::RegistrationAwsAccountResponseV2`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<CreateCspmAwsAccountError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn create_cspm_azure_account(
configuration: &configuration::Configuration,
body: models::RegistrationAzureAccountCreateRequestExternalV1,
) -> Result<models::RegistrationAzureAccountResponseV1, Error<CreateCspmAzureAccountError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_body = body;
let uri_str = format!(
"{}/cloud-connect-cspm-azure/entities/account/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::RegistrationAzureAccountResponseV1`",
)));
}
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::RegistrationAzureAccountResponseV1`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<CreateCspmAzureAccountError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn create_cspm_azure_management_group(
configuration: &configuration::Configuration,
body: models::RegistrationAzureManagementGroupCreateRequestExternalV1,
) -> Result<models::RegistrationAzureAccountResponseV1, Error<CreateCspmAzureManagementGroupError>>
{
// add a prefix to parameters to efficiently prevent name collisions
let p_body_body = body;
let uri_str = format!(
"{}/cloud-connect-cspm-azure/entities/management-group/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::RegistrationAzureAccountResponseV1`",
)));
}
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::RegistrationAzureAccountResponseV1`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<CreateCspmAzureManagementGroupError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn create_cspmgcp_account(
configuration: &configuration::Configuration,
body: models::RegistrationGcpAccountCreateRequestExtV1,
) -> Result<models::RegistrationGcpAccountResponseV1, Error<CreateCspmgcpAccountError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_body = body;
let uri_str = format!(
"{}/cloud-connect-cspm-gcp/entities/account/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::RegistrationGcpAccountResponseV1`",
)));
}
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::RegistrationGcpAccountResponseV1`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<CreateCspmgcpAccountError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn delete_cspm_aws_account(
configuration: &configuration::Configuration,
ids: Option<Vec<String>>,
organization_ids: Option<Vec<String>>,
) -> Result<models::MsaspecResponseFields, Error<DeleteCspmAwsAccountError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_ids = ids;
let p_query_organization_ids = organization_ids;
let uri_str = format!(
"{}/cloud-connect-cspm-aws/entities/account/v1",
configuration.base_path
);
let mut req_builder = configuration
.client
.request(reqwest::Method::DELETE, &uri_str);
if let Some(ref param_value) = p_query_ids {
req_builder = match "multi" {
"multi" => req_builder.query(
¶m_value
.into_iter()
.map(|p| ("ids".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => req_builder.query(&[(
"ids",
¶m_value
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref param_value) = p_query_organization_ids {
req_builder = match "multi" {
"multi" => req_builder.query(
¶m_value
.into_iter()
.map(|p| ("organization-ids".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => req_builder.query(&[(
"organization-ids",
¶m_value
.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::MsaspecResponseFields`",
)));
}
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::MsaspecResponseFields`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<DeleteCspmAwsAccountError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn delete_cspm_azure_account(
configuration: &configuration::Configuration,
ids: Option<Vec<String>>,
tenant_ids: Option<Vec<String>>,
retain_tenant: Option<&str>,
) -> Result<models::MsaBaseEntitiesResponse, Error<DeleteCspmAzureAccountError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_ids = ids;
let p_query_tenant_ids = tenant_ids;
let p_query_retain_tenant = retain_tenant;
let uri_str = format!(
"{}/cloud-connect-cspm-azure/entities/account/v1",
configuration.base_path
);
let mut req_builder = configuration
.client
.request(reqwest::Method::DELETE, &uri_str);
if let Some(ref param_value) = p_query_ids {
req_builder = match "multi" {
"multi" => req_builder.query(
¶m_value
.into_iter()
.map(|p| ("ids".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => req_builder.query(&[(
"ids",
¶m_value
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref param_value) = p_query_tenant_ids {
req_builder = match "multi" {
"multi" => req_builder.query(
¶m_value
.into_iter()
.map(|p| ("tenant_ids".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => req_builder.query(&[(
"tenant_ids",
¶m_value
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref param_value) = p_query_retain_tenant {
req_builder = req_builder.query(&[("retain_tenant", ¶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::MsaBaseEntitiesResponse`",
)));
}
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::MsaBaseEntitiesResponse`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<DeleteCspmAzureAccountError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn delete_cspm_azure_management_group(
configuration: &configuration::Configuration,
tenant_ids: Option<Vec<String>>,
) -> Result<models::MsaspecResponseFields, Error<DeleteCspmAzureManagementGroupError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_tenant_ids = tenant_ids;
let uri_str = format!(
"{}/cloud-connect-cspm-azure/entities/management-group/v1",
configuration.base_path
);
let mut req_builder = configuration
.client
.request(reqwest::Method::DELETE, &uri_str);
if let Some(ref param_value) = p_query_tenant_ids {
req_builder = match "multi" {
"multi" => req_builder.query(
¶m_value
.into_iter()
.map(|p| ("tenant_ids".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => req_builder.query(&[(
"tenant_ids",
¶m_value
.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::MsaspecResponseFields`",
)));
}
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::MsaspecResponseFields`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<DeleteCspmAzureManagementGroupError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn delete_cspmgcp_account(
configuration: &configuration::Configuration,
ids: Option<Vec<String>>,
) -> Result<models::MsaBaseEntitiesResponse, Error<DeleteCspmgcpAccountError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_ids = ids;
let uri_str = format!(
"{}/cloud-connect-cspm-gcp/entities/account/v1",
configuration.base_path
);
let mut req_builder = configuration
.client
.request(reqwest::Method::DELETE, &uri_str);
if let Some(ref param_value) = p_query_ids {
req_builder = match "multi" {
"multi" => req_builder.query(
¶m_value
.into_iter()
.map(|p| ("ids".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => req_builder.query(&[(
"ids",
¶m_value
.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::MsaBaseEntitiesResponse`",
)));
}
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::MsaBaseEntitiesResponse`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<DeleteCspmgcpAccountError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_behavior_detections(
configuration: &configuration::Configuration,
cloud_provider: Option<&str>,
service: Option<&str>,
account_id: Option<&str>,
aws_account_id: Option<&str>,
azure_subscription_id: Option<&str>,
azure_tenant_id: Option<&str>,
state: Option<&str>,
date_time_since: Option<&str>,
since: Option<&str>,
severity: Option<&str>,
next_token: Option<&str>,
limit: Option<i32>,
resource_id: Option<Vec<String>>,
resource_uuid: Option<Vec<String>>,
) -> Result<models::RegistrationExternalIoaEventResponse, Error<GetBehaviorDetectionsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_cloud_provider = cloud_provider;
let p_query_service = service;
let p_query_account_id = account_id;
let p_query_aws_account_id = aws_account_id;
let p_query_azure_subscription_id = azure_subscription_id;
let p_query_azure_tenant_id = azure_tenant_id;
let p_query_state = state;
let p_query_date_time_since = date_time_since;
let p_query_since = since;
let p_query_severity = severity;
let p_query_next_token = next_token;
let p_query_limit = limit;
let p_query_resource_id = resource_id;
let p_query_resource_uuid = resource_uuid;
let uri_str = format!("{}/detects/entities/ioa/v1", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_cloud_provider {
req_builder = req_builder.query(&[("cloud_provider", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_service {
req_builder = req_builder.query(&[("service", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_account_id {
req_builder = req_builder.query(&[("account_id", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_aws_account_id {
req_builder = req_builder.query(&[("aws_account_id", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_azure_subscription_id {
req_builder = req_builder.query(&[("azure_subscription_id", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_azure_tenant_id {
req_builder = req_builder.query(&[("azure_tenant_id", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_state {
req_builder = req_builder.query(&[("state", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_date_time_since {
req_builder = req_builder.query(&[("date_time_since", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_since {
req_builder = req_builder.query(&[("since", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_severity {
req_builder = req_builder.query(&[("severity", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_next_token {
req_builder = req_builder.query(&[("next_token", ¶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_resource_id {
req_builder = match "multi" {
"multi" => req_builder.query(
¶m_value
.into_iter()
.map(|p| ("resource_id".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => req_builder.query(&[(
"resource_id",
¶m_value
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref param_value) = p_query_resource_uuid {
req_builder = match "multi" {
"multi" => req_builder.query(
¶m_value
.into_iter()
.map(|p| ("resource_uuid".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => req_builder.query(&[(
"resource_uuid",
¶m_value
.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::RegistrationExternalIoaEventResponse`",
)));
}
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::RegistrationExternalIoaEventResponse`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<GetBehaviorDetectionsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_cloud_event_ids(
configuration: &configuration::Configuration,
x_cs_useruuid: &str,
id: &str,
) -> Result<models::CdrioamanagerGetCloudEventIdsResponse, Error<GetCloudEventIdsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_header_x_cs_useruuid = x_cs_useruuid;
let p_query_id = id;
let uri_str = format!(
"{}/detects/queries/cloud-events/v1",
configuration.base_path
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("id", &p_query_id.to_string())]);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
req_builder = req_builder.header("X-CS-USERUUID", p_header_x_cs_useruuid.to_string());
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::CdrioamanagerGetCloudEventIdsResponse`",
)));
}
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::CdrioamanagerGetCloudEventIdsResponse`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<GetCloudEventIdsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_configuration_detection_entities(
configuration: &configuration::Configuration,
ids: Vec<String>,
) -> Result<
models::RegistrationExternalIomEventResponseV2,
Error<GetConfigurationDetectionEntitiesError>,
> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_ids = ids;
let uri_str = format!("{}/detects/entities/iom/v2", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = match "multi" {
"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::RegistrationExternalIomEventResponseV2`",
)));
}
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::RegistrationExternalIomEventResponseV2`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<GetConfigurationDetectionEntitiesError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_configuration_detection_ids_v2(
configuration: &configuration::Configuration,
filter: Option<&str>,
sort: Option<&str>,
limit: Option<i32>,
offset: Option<i32>,
next_token: Option<&str>,
) -> Result<models::RegistrationIomEventIdsResponseV2, Error<GetConfigurationDetectionIdsV2Error>> {
// 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 p_query_next_token = next_token;
let uri_str = format!("{}/detects/queries/iom/v2", 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 param_value) = p_query_next_token {
req_builder = req_builder.query(&[("next_token", ¶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::RegistrationIomEventIdsResponseV2`",
)));
}
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::RegistrationIomEventIdsResponseV2`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<GetConfigurationDetectionIdsV2Error> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_configuration_detections(
configuration: &configuration::Configuration,
cloud_provider: Option<&str>,
account_id: Option<&str>,
azure_subscription_id: Option<&str>,
azure_tenant_id: Option<&str>,
status: Option<&str>,
region: Option<&str>,
severity: Option<&str>,
service: Option<&str>,
next_token: Option<&str>,
limit: Option<i32>,
) -> Result<models::RegistrationExternalIomEventResponse, Error<GetConfigurationDetectionsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_cloud_provider = cloud_provider;
let p_query_account_id = account_id;
let p_query_azure_subscription_id = azure_subscription_id;
let p_query_azure_tenant_id = azure_tenant_id;
let p_query_status = status;
let p_query_region = region;
let p_query_severity = severity;
let p_query_service = service;
let p_query_next_token = next_token;
let p_query_limit = limit;
let uri_str = format!("{}/detects/entities/iom/v1", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_cloud_provider {
req_builder = req_builder.query(&[("cloud_provider", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_account_id {
req_builder = req_builder.query(&[("account_id", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_azure_subscription_id {
req_builder = req_builder.query(&[("azure_subscription_id", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_azure_tenant_id {
req_builder = req_builder.query(&[("azure_tenant_id", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_status {
req_builder = req_builder.query(&[("status", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_region {
req_builder = req_builder.query(&[("region", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_severity {
req_builder = req_builder.query(&[("severity", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_service {
req_builder = req_builder.query(&[("service", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_next_token {
req_builder = req_builder.query(&[("next_token", ¶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 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::RegistrationExternalIomEventResponse`",
)));
}
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::RegistrationExternalIomEventResponse`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<GetConfigurationDetectionsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_cspm_aws_account(
configuration: &configuration::Configuration,
scan_type: Option<&str>,
ids: Option<Vec<String>>,
iam_role_arns: Option<Vec<String>>,
organization_ids: Option<Vec<String>>,
status: Option<&str>,
limit: Option<i32>,
cspm_lite: Option<&str>,
migrated: Option<&str>,
offset: Option<i32>,
group_by: Option<&str>,
) -> Result<models::RegistrationAwsAccountResponseV2, Error<GetCspmAwsAccountError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_scan_type = scan_type;
let p_query_ids = ids;
let p_query_iam_role_arns = iam_role_arns;
let p_query_organization_ids = organization_ids;
let p_query_status = status;
let p_query_limit = limit;
let p_query_cspm_lite = cspm_lite;
let p_query_migrated = migrated;
let p_query_offset = offset;
let p_query_group_by = group_by;
let uri_str = format!(
"{}/cloud-connect-cspm-aws/entities/account/v1",
configuration.base_path
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_scan_type {
req_builder = req_builder.query(&[("scan-type", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_ids {
req_builder = match "multi" {
"multi" => req_builder.query(
¶m_value
.into_iter()
.map(|p| ("ids".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => req_builder.query(&[(
"ids",
¶m_value
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref param_value) = p_query_iam_role_arns {
req_builder = match "multi" {
"multi" => req_builder.query(
¶m_value
.into_iter()
.map(|p| ("iam_role_arns".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => req_builder.query(&[(
"iam_role_arns",
¶m_value
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref param_value) = p_query_organization_ids {
req_builder = match "multi" {
"multi" => req_builder.query(
¶m_value
.into_iter()
.map(|p| ("organization-ids".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => req_builder.query(&[(
"organization-ids",
¶m_value
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref param_value) = p_query_status {
req_builder = req_builder.query(&[("status", ¶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_cspm_lite {
req_builder = req_builder.query(&[("cspm_lite", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_migrated {
req_builder = req_builder.query(&[("migrated", ¶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_group_by {
req_builder = req_builder.query(&[("group_by", ¶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::RegistrationAwsAccountResponseV2`",
)));
}
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::RegistrationAwsAccountResponseV2`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<GetCspmAwsAccountError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_cspm_aws_console_setup_urls(
configuration: &configuration::Configuration,
ids: Option<Vec<String>>,
use_existing_cloudtrail: Option<&str>,
region: Option<&str>,
tags: Option<&str>,
template: Option<&str>,
) -> Result<models::RegistrationAwsConsoleUrlResponseV2, Error<GetCspmAwsConsoleSetupUrlsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_ids = ids;
let p_query_use_existing_cloudtrail = use_existing_cloudtrail;
let p_query_region = region;
let p_query_tags = tags;
let p_query_template = template;
let uri_str = format!(
"{}/cloud-connect-cspm-aws/entities/console-setup-urls/v1",
configuration.base_path
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_ids {
req_builder = match "multi" {
"multi" => req_builder.query(
¶m_value
.into_iter()
.map(|p| ("ids".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => req_builder.query(&[(
"ids",
¶m_value
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref param_value) = p_query_use_existing_cloudtrail {
req_builder = req_builder.query(&[("use_existing_cloudtrail", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_region {
req_builder = req_builder.query(&[("region", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_tags {
req_builder = req_builder.query(&[("tags", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_template {
req_builder = req_builder.query(&[("template", ¶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::RegistrationAwsConsoleUrlResponseV2`",
)));
}
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::RegistrationAwsConsoleUrlResponseV2`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<GetCspmAwsConsoleSetupUrlsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_cspm_azure_account(
configuration: &configuration::Configuration,
ids: Option<Vec<String>>,
tenant_ids: Option<Vec<String>>,
scan_type: Option<&str>,
status: Option<&str>,
cspm_lite: Option<&str>,
limit: Option<i32>,
offset: Option<i32>,
) -> Result<models::RegistrationAzureAccountResponseV1, Error<GetCspmAzureAccountError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_ids = ids;
let p_query_tenant_ids = tenant_ids;
let p_query_scan_type = scan_type;
let p_query_status = status;
let p_query_cspm_lite = cspm_lite;
let p_query_limit = limit;
let p_query_offset = offset;
let uri_str = format!(
"{}/cloud-connect-cspm-azure/entities/account/v1",
configuration.base_path
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_ids {
req_builder = match "multi" {
"multi" => req_builder.query(
¶m_value
.into_iter()
.map(|p| ("ids".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => req_builder.query(&[(
"ids",
¶m_value
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref param_value) = p_query_tenant_ids {
req_builder = match "multi" {
"multi" => req_builder.query(
¶m_value
.into_iter()
.map(|p| ("tenant_ids".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => req_builder.query(&[(
"tenant_ids",
¶m_value
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref param_value) = p_query_scan_type {
req_builder = req_builder.query(&[("scan-type", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_status {
req_builder = req_builder.query(&[("status", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_cspm_lite {
req_builder = req_builder.query(&[("cspm_lite", ¶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::RegistrationAzureAccountResponseV1`",
)));
}
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::RegistrationAzureAccountResponseV1`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<GetCspmAzureAccountError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_cspm_azure_management_group(
configuration: &configuration::Configuration,
tenant_ids: Option<Vec<String>>,
limit: Option<i32>,
offset: Option<i32>,
) -> Result<
models::RegistrationAzureManagementGroupResponseV1,
Error<GetCspmAzureManagementGroupError>,
> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_tenant_ids = tenant_ids;
let p_query_limit = limit;
let p_query_offset = offset;
let uri_str = format!(
"{}/cloud-connect-cspm-azure/entities/management-group/v1",
configuration.base_path
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_tenant_ids {
req_builder = match "multi" {
"multi" => req_builder.query(
¶m_value
.into_iter()
.map(|p| ("tenant_ids".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => req_builder.query(&[(
"tenant_ids",
¶m_value
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.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::RegistrationAzureManagementGroupResponseV1`",
)));
}
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::RegistrationAzureManagementGroupResponseV1`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<GetCspmAzureManagementGroupError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_cspm_azure_user_scripts_attachment(
configuration: &configuration::Configuration,
tenant_id: Option<&str>,
subscription_ids: Option<Vec<String>>,
account_type: Option<&str>,
template: Option<&str>,
azure_management_group: Option<bool>,
) -> Result<
models::RegistrationAzureProvisionGetUserScriptResponseV1,
Error<GetCspmAzureUserScriptsAttachmentError>,
> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_tenant_id = tenant_id;
let p_query_subscription_ids = subscription_ids;
let p_query_account_type = account_type;
let p_query_template = template;
let p_query_azure_management_group = azure_management_group;
let uri_str = format!(
"{}/cloud-connect-cspm-azure/entities/user-scripts-download/v1",
configuration.base_path
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_tenant_id {
req_builder = req_builder.query(&[("tenant-id", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_subscription_ids {
req_builder = match "multi" {
"multi" => req_builder.query(
¶m_value
.into_iter()
.map(|p| ("subscription_ids".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => req_builder.query(&[(
"subscription_ids",
¶m_value
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref param_value) = p_query_account_type {
req_builder = req_builder.query(&[("account_type", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_template {
req_builder = req_builder.query(&[("template", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_azure_management_group {
req_builder = req_builder.query(&[("azure_management_group", ¶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::RegistrationAzureProvisionGetUserScriptResponseV1`",
)));
}
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::RegistrationAzureProvisionGetUserScriptResponseV1`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<GetCspmAzureUserScriptsAttachmentError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_cspm_policies_details(
configuration: &configuration::Configuration,
ids: Vec<i32>,
) -> Result<models::RegistrationPolicyResponseV1, Error<GetCspmPoliciesDetailsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_ids = ids;
let uri_str = format!(
"{}/settings/entities/policy-details/v2",
configuration.base_path
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = match "multi" {
"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::RegistrationPolicyResponseV1`",
)));
}
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::RegistrationPolicyResponseV1`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<GetCspmPoliciesDetailsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_cspm_policy(
configuration: &configuration::Configuration,
ids: i32,
) -> Result<models::RegistrationPolicyResponseV1, Error<GetCspmPolicyError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_ids = ids;
let uri_str = format!(
"{}/settings/entities/policy-details/v1",
configuration.base_path
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("ids", &p_query_ids.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::RegistrationPolicyResponseV1`",
)));
}
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::RegistrationPolicyResponseV1`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<GetCspmPolicyError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_cspm_policy_settings(
configuration: &configuration::Configuration,
service: Option<&str>,
policy_id: Option<&str>,
cloud_platform: Option<&str>,
) -> Result<models::RegistrationPolicySettingsResponseV1, Error<GetCspmPolicySettingsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_service = service;
let p_query_policy_id = policy_id;
let p_query_cloud_platform = cloud_platform;
let uri_str = format!("{}/settings/entities/policy/v1", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_service {
req_builder = req_builder.query(&[("service", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_policy_id {
req_builder = req_builder.query(&[("policy-id", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_cloud_platform {
req_builder = req_builder.query(&[("cloud-platform", ¶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::RegistrationPolicySettingsResponseV1`",
)));
}
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::RegistrationPolicySettingsResponseV1`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<GetCspmPolicySettingsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_cspm_scan_schedule(
configuration: &configuration::Configuration,
cloud_platform: Option<Vec<String>>,
) -> Result<models::RegistrationScanScheduleResponseV1, Error<GetCspmScanScheduleError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_cloud_platform = cloud_platform;
let uri_str = format!("{}/settings/scan-schedule/v1", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_cloud_platform {
req_builder = match "multi" {
"multi" => req_builder.query(
¶m_value
.into_iter()
.map(|p| ("cloud-platform".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => req_builder.query(&[(
"cloud-platform",
¶m_value
.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::RegistrationScanScheduleResponseV1`",
)));
}
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::RegistrationScanScheduleResponseV1`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<GetCspmScanScheduleError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_cspmcgp_account(
configuration: &configuration::Configuration,
parent_type: Option<&str>,
ids: Option<Vec<String>>,
scan_type: Option<&str>,
status: Option<&str>,
limit: Option<i32>,
offset: Option<i32>,
sort: Option<&str>,
) -> Result<models::RegistrationGcpAccountResponseV1, Error<GetCspmcgpAccountError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_parent_type = parent_type;
let p_query_ids = ids;
let p_query_scan_type = scan_type;
let p_query_status = status;
let p_query_limit = limit;
let p_query_offset = offset;
let p_query_sort = sort;
let uri_str = format!(
"{}/cloud-connect-cspm-gcp/entities/account/v1",
configuration.base_path
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_parent_type {
req_builder = req_builder.query(&[("parent_type", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_ids {
req_builder = match "multi" {
"multi" => req_builder.query(
¶m_value
.into_iter()
.map(|p| ("ids".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => req_builder.query(&[(
"ids",
¶m_value
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref param_value) = p_query_scan_type {
req_builder = req_builder.query(&[("scan-type", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_status {
req_builder = req_builder.query(&[("status", ¶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::RegistrationGcpAccountResponseV1`",
)));
}
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::RegistrationGcpAccountResponseV1`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<GetCspmcgpAccountError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_cspmgcp_service_accounts_ext(
configuration: &configuration::Configuration,
id: Option<&str>,
) -> Result<
models::RegistrationGcpServiceAccountResponseExtV1,
Error<GetCspmgcpServiceAccountsExtError>,
> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_id = id;
let uri_str = format!(
"{}/cloud-connect-cspm-gcp/entities/service-accounts/v1",
configuration.base_path
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_id {
req_builder = req_builder.query(&[("id", ¶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::RegistrationGcpServiceAccountResponseExtV1`",
)));
}
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::RegistrationGcpServiceAccountResponseExtV1`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<GetCspmgcpServiceAccountsExtError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_cspmgcp_user_scripts_attachment(
configuration: &configuration::Configuration,
parent_type: Option<&str>,
ids: Option<Vec<String>>,
) -> Result<
models::RegistrationGcpProvisionGetUserScriptResponseV1,
Error<GetCspmgcpUserScriptsAttachmentError>,
> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_parent_type = parent_type;
let p_query_ids = ids;
let uri_str = format!(
"{}/cloud-connect-cspm-gcp/entities/user-scripts-download/v1",
configuration.base_path
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_parent_type {
req_builder = req_builder.query(&[("parent_type", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_ids {
req_builder = match "multi" {
"multi" => req_builder.query(
¶m_value
.into_iter()
.map(|p| ("ids".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => req_builder.query(&[(
"ids",
¶m_value
.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::RegistrationGcpProvisionGetUserScriptResponseV1`",
)));
}
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::RegistrationGcpProvisionGetUserScriptResponseV1`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<GetCspmgcpUserScriptsAttachmentError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_cspmgcp_validate_accounts_ext(
configuration: &configuration::Configuration,
body: models::RegistrationGcpAccountValidationRequestV1,
) -> Result<
models::RegistrationGcpAccountValidationResponseV1,
Error<GetCspmgcpValidateAccountsExtError>,
> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_body = body;
let uri_str = format!(
"{}/cloud-connect-cspm-gcp/entities/account/validate/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::RegistrationGcpAccountValidationResponseV1`",
)));
}
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::RegistrationGcpAccountValidationResponseV1`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<GetCspmgcpValidateAccountsExtError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn patch_cspm_aws_account(
configuration: &configuration::Configuration,
body: models::RegistrationAwsAccountPatchRequest,
) -> Result<models::RegistrationAwsAccountResponseV2, Error<PatchCspmAwsAccountError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_body = body;
let uri_str = format!(
"{}/cloud-connect-cspm-aws/entities/account/v1",
configuration.base_path
);
let mut req_builder = configuration
.client
.request(reqwest::Method::PATCH, &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::RegistrationAwsAccountResponseV2`",
)));
}
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::RegistrationAwsAccountResponseV2`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<PatchCspmAwsAccountError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn update_cspm_azure_account(
configuration: &configuration::Configuration,
body: models::RegistrationAzureAccountPatchRequest,
) -> Result<models::RegistrationAzureAccountResponseV1, Error<UpdateCspmAzureAccountError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_body = body;
let uri_str = format!(
"{}/cloud-connect-cspm-azure/entities/account/v1",
configuration.base_path
);
let mut req_builder = configuration
.client
.request(reqwest::Method::PATCH, &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::RegistrationAzureAccountResponseV1`",
)));
}
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::RegistrationAzureAccountResponseV1`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<UpdateCspmAzureAccountError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn update_cspm_azure_account_client_id(
configuration: &configuration::Configuration,
id: &str,
tenant_id: Option<&str>,
) -> Result<
models::RegistrationAzureTenantConfigurationResponseV1,
Error<UpdateCspmAzureAccountClientIdError>,
> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_id = id;
let p_query_tenant_id = tenant_id;
let uri_str = format!(
"{}/cloud-connect-cspm-azure/entities/client-id/v1",
configuration.base_path
);
let mut req_builder = configuration
.client
.request(reqwest::Method::PATCH, &uri_str);
req_builder = req_builder.query(&[("id", &p_query_id.to_string())]);
if let Some(ref param_value) = p_query_tenant_id {
req_builder = req_builder.query(&[("tenant-id", ¶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::RegistrationAzureTenantConfigurationResponseV1`",
)));
}
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::RegistrationAzureTenantConfigurationResponseV1`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<UpdateCspmAzureAccountClientIdError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn update_cspm_azure_tenant_default_subscription_id(
configuration: &configuration::Configuration,
subscription_id: &str,
tenant_id: Option<&str>,
) -> Result<
models::RegistrationAzureTenantDefaultSubscriptionIdResponseV1,
Error<UpdateCspmAzureTenantDefaultSubscriptionIdError>,
> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_subscription_id = subscription_id;
let p_query_tenant_id = tenant_id;
let uri_str = format!(
"{}/cloud-connect-cspm-azure/entities/default-subscription-id/v1",
configuration.base_path
);
let mut req_builder = configuration
.client
.request(reqwest::Method::PATCH, &uri_str);
if let Some(ref param_value) = p_query_tenant_id {
req_builder = req_builder.query(&[("tenant-id", ¶m_value.to_string())]);
}
req_builder = req_builder.query(&[("subscription_id", &p_query_subscription_id.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::RegistrationAzureTenantDefaultSubscriptionIdResponseV1`",
)));
}
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::RegistrationAzureTenantDefaultSubscriptionIdResponseV1`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<UpdateCspmAzureTenantDefaultSubscriptionIdError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn update_cspm_policy_settings(
configuration: &configuration::Configuration,
body: models::RegistrationPolicyRequestExtV1,
) -> Result<models::RegistrationPolicySettingsResponseV1, Error<UpdateCspmPolicySettingsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_body = body;
let uri_str = format!("{}/settings/entities/policy/v1", configuration.base_path);
let mut req_builder = configuration
.client
.request(reqwest::Method::PATCH, &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::RegistrationPolicySettingsResponseV1`",
)));
}
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::RegistrationPolicySettingsResponseV1`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<UpdateCspmPolicySettingsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn update_cspm_scan_schedule(
configuration: &configuration::Configuration,
body: models::RegistrationScanScheduleUpdateRequestV1,
) -> Result<models::RegistrationScanScheduleResponseV1, Error<UpdateCspmScanScheduleError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_body = body;
let uri_str = format!("{}/settings/scan-schedule/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::RegistrationScanScheduleResponseV1`",
)));
}
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::RegistrationScanScheduleResponseV1`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<UpdateCspmScanScheduleError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn update_cspmgcp_account(
configuration: &configuration::Configuration,
body: models::RegistrationGcpAccountPatchRequestV1,
) -> Result<models::RegistrationGcpAccountResponseV1, Error<UpdateCspmgcpAccountError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_body = body;
let uri_str = format!(
"{}/cloud-connect-cspm-gcp/entities/account/v1",
configuration.base_path
);
let mut req_builder = configuration
.client
.request(reqwest::Method::PATCH, &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::RegistrationGcpAccountResponseV1`",
)));
}
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::RegistrationGcpAccountResponseV1`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<UpdateCspmgcpAccountError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn update_cspmgcp_service_accounts_ext(
configuration: &configuration::Configuration,
body: models::RegistrationGcpServiceAccountPatchRequestV1,
) -> Result<
models::RegistrationGcpServiceAccountResponseExtV1,
Error<UpdateCspmgcpServiceAccountsExtError>,
> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_body = body;
let uri_str = format!(
"{}/cloud-connect-cspm-gcp/entities/service-accounts/v1",
configuration.base_path
);
let mut req_builder = configuration
.client
.request(reqwest::Method::PATCH, &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::RegistrationGcpServiceAccountResponseExtV1`",
)));
}
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::RegistrationGcpServiceAccountResponseExtV1`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<UpdateCspmgcpServiceAccountsExtError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn validate_cspmgcp_service_account_ext(
configuration: &configuration::Configuration,
body: models::RegistrationGcpServiceAccountValidationRequestV1,
) -> Result<
models::RegistrationGcpServiceAccountValidationResponseV1,
Error<ValidateCspmgcpServiceAccountExtError>,
> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_body = body;
let uri_str = format!(
"{}/cloud-connect-cspm-gcp/entities/service-accounts/validate/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::RegistrationGcpServiceAccountValidationResponseV1`",
)));
}
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::RegistrationGcpServiceAccountValidationResponseV1`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<ValidateCspmgcpServiceAccountExtError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}