/*
* 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 [`dismiss_affected_entity_v3`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DismissAffectedEntityV3Error {
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaReplyMetaOnly),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`dismiss_security_check_v3`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DismissSecurityCheckV3Error {
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaReplyMetaOnly),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_activity_monitor_v3`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetActivityMonitorV3Error {
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaReplyMetaOnly),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_alerts_v3`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetAlertsV3Error {
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaReplyMetaOnly),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_device_inventory_v3`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetDeviceInventoryV3Error {
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaReplyMetaOnly),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_integrations_v3`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetIntegrationsV3Error {
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaReplyMetaOnly),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_metrics_v3`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetMetricsV3Error {
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaReplyMetaOnly),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_security_check_affected_v3`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetSecurityCheckAffectedV3Error {
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaReplyMetaOnly),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_security_check_compliance_v3`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetSecurityCheckComplianceV3Error {
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaReplyMetaOnly),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_security_checks_v3`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetSecurityChecksV3Error {
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaReplyMetaOnly),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_supported_saas_v3`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetSupportedSaasV3Error {
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaReplyMetaOnly),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_system_logs_v3`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetSystemLogsV3Error {
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaReplyMetaOnly),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_system_users_v3`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetSystemUsersV3Error {
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaReplyMetaOnly),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_user_inventory_v3`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetUserInventoryV3Error {
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaReplyMetaOnly),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`integration_builder_end_transaction_v3`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum IntegrationBuilderEndTransactionV3Error {
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaReplyMetaOnly),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`integration_builder_get_status_v3`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum IntegrationBuilderGetStatusV3Error {
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaReplyMetaOnly),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`integration_builder_reset_v3`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum IntegrationBuilderResetV3Error {
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaReplyMetaOnly),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`integration_builder_upload_v3`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum IntegrationBuilderUploadV3Error {
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaReplyMetaOnly),
UnknownValue(serde_json::Value),
}
/// Preform dismiss to an affected entity in a security check
pub async fn dismiss_affected_entity_v3(
configuration: &configuration::Configuration,
id: &str,
body: models::DismissAffectedEntityV3Request,
) -> Result<models::DismissAffected, Error<DismissAffectedEntityV3Error>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_id = id;
let p_body_body = body;
let uri_str = format!(
"{}/saas-security/entities/check-dismiss-affected/v3",
configuration.base_path
);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &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());
}
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::DismissAffected`",
)));
}
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::DismissAffected`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<DismissAffectedEntityV3Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Perform dismiss to a security check
pub async fn dismiss_security_check_v3(
configuration: &configuration::Configuration,
id: &str,
body: models::DismissSecurityCheckV3Request,
) -> Result<models::DismissSecurityCheck, Error<DismissSecurityCheckV3Error>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_id = id;
let p_body_body = body;
let uri_str = format!(
"{}/saas-security/entities/check-dismiss/v3",
configuration.base_path
);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &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());
}
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::DismissSecurityCheck`",
)));
}
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::DismissSecurityCheck`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<DismissSecurityCheckV3Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Get a list of all events in monitor
pub async fn get_activity_monitor_v3(
configuration: &configuration::Configuration,
integration_id: Option<&str>,
actor: Option<&str>,
category: Option<&str>,
projection: Option<&str>,
from_date: Option<String>,
to_date: Option<String>,
limit: Option<i32>,
skip: Option<i32>,
) -> Result<models::GetActivityMonitor, Error<GetActivityMonitorV3Error>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_integration_id = integration_id;
let p_query_actor = actor;
let p_query_category = category;
let p_query_projection = projection;
let p_query_from_date = from_date;
let p_query_to_date = to_date;
let p_query_limit = limit;
let p_query_skip = skip;
let uri_str = format!(
"{}/saas-security/entities/monitor/v3",
configuration.base_path
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_integration_id {
req_builder = req_builder.query(&[("integration_id", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_actor {
req_builder = req_builder.query(&[("actor", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_category {
req_builder = req_builder.query(&[("category", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_projection {
req_builder = req_builder.query(&[("projection", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_from_date {
req_builder = req_builder.query(&[("from_date", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_to_date {
req_builder = req_builder.query(&[("to_date", ¶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_skip {
req_builder = req_builder.query(&[("skip", ¶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::GetActivityMonitor`",
)));
}
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::GetActivityMonitor`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<GetActivityMonitorV3Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Get a data on a specific alert or get a list of all alerts
pub async fn get_alerts_v3(
configuration: &configuration::Configuration,
id: Option<&str>,
limit: Option<i32>,
offset: Option<i32>,
last_id: Option<&str>,
r#type: Option<&str>,
integration_id: Option<&str>,
from_date: Option<String>,
to_date: Option<String>,
ascending: Option<bool>,
) -> Result<models::GetAlertsResponse, Error<GetAlertsV3Error>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_id = id;
let p_query_limit = limit;
let p_query_offset = offset;
let p_query_last_id = last_id;
let p_query_type = r#type;
let p_query_integration_id = integration_id;
let p_query_from_date = from_date;
let p_query_to_date = to_date;
let p_query_ascending = ascending;
let uri_str = format!(
"{}/saas-security/entities/alerts/v3",
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 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_last_id {
req_builder = req_builder.query(&[("last_id", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_type {
req_builder = req_builder.query(&[("type", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_integration_id {
req_builder = req_builder.query(&[("integration_id", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_from_date {
req_builder = req_builder.query(&[("from_date", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_to_date {
req_builder = req_builder.query(&[("to_date", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_ascending {
req_builder = req_builder.query(&[("ascending", ¶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::GetAlertsResponse`",
)));
}
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::GetAlertsResponse`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<GetAlertsV3Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Get a list of all devices
pub async fn get_device_inventory_v3(
configuration: &configuration::Configuration,
integration_id: Option<&str>,
limit: Option<i32>,
offset: Option<i32>,
email: Option<&str>,
privileged_only: Option<bool>,
unassociated_devices: Option<bool>,
) -> Result<models::GetDeviceInventory, Error<GetDeviceInventoryV3Error>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_integration_id = integration_id;
let p_query_limit = limit;
let p_query_offset = offset;
let p_query_email = email;
let p_query_privileged_only = privileged_only;
let p_query_unassociated_devices = unassociated_devices;
let uri_str = format!(
"{}/saas-security/entities/devices/v3",
configuration.base_path
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_integration_id {
req_builder = req_builder.query(&[("integration_id", ¶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_email {
req_builder = req_builder.query(&[("email", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_privileged_only {
req_builder = req_builder.query(&[("privileged_only", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_unassociated_devices {
req_builder = req_builder.query(&[("unassociated_devices", ¶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::GetDeviceInventory`",
)));
}
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::GetDeviceInventory`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<GetDeviceInventoryV3Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Get a list of connected integrations in your account
pub async fn get_integrations_v3(
configuration: &configuration::Configuration,
saas_id: Option<&str>,
) -> Result<models::GetIntegrations, Error<GetIntegrationsV3Error>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_saas_id = saas_id;
let uri_str = format!(
"{}/saas-security/entities/integrations/v3",
configuration.base_path
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_saas_id {
req_builder = req_builder.query(&[("saas_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::GetIntegrations`",
)));
}
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::GetIntegrations`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<GetIntegrationsV3Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Get metrics on security checks
pub async fn get_metrics_v3(
configuration: &configuration::Configuration,
status: Option<&str>,
limit: Option<i32>,
offset: Option<i32>,
integration_id: Option<&str>,
impact: Option<&str>,
compliance: Option<bool>,
check_type: Option<&str>,
) -> Result<models::GetMetrics, Error<GetMetricsV3Error>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_status = status;
let p_query_limit = limit;
let p_query_offset = offset;
let p_query_integration_id = integration_id;
let p_query_impact = impact;
let p_query_compliance = compliance;
let p_query_check_type = check_type;
let uri_str = format!(
"{}/saas-security/aggregates/check-metrics/v3",
configuration.base_path
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
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_integration_id {
req_builder = req_builder.query(&[("integration_id", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_impact {
req_builder = req_builder.query(&[("impact", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_compliance {
req_builder = req_builder.query(&[("compliance", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_check_type {
req_builder = req_builder.query(&[("check_type", ¶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::GetMetrics`",
)));
}
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::GetMetrics`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<GetMetricsV3Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Get a list of affected entities
pub async fn get_security_check_affected_v3(
configuration: &configuration::Configuration,
id: &str,
limit: Option<i32>,
offset: Option<i32>,
) -> Result<models::GetAffected, Error<GetSecurityCheckAffectedV3Error>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_id = id;
let p_query_limit = limit;
let p_query_offset = offset;
let uri_str = format!(
"{}/saas-security/entities/check-affected/v3",
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 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::GetAffected`",
)));
}
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::GetAffected`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<GetSecurityCheckAffectedV3Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Get a list of compliance standards attached to a check
pub async fn get_security_check_compliance_v3(
configuration: &configuration::Configuration,
id: &str,
) -> Result<models::GetSecurityCompliance, Error<GetSecurityCheckComplianceV3Error>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_id = id;
let uri_str = format!(
"{}/saas-security/entities/compliance/v3",
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());
}
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::GetSecurityCompliance`",
)));
}
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::GetSecurityCompliance`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<GetSecurityCheckComplianceV3Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Get a specific security check by ID or Get all security checks
pub async fn get_security_checks_v3(
configuration: &configuration::Configuration,
id: Option<&str>,
limit: Option<i32>,
offset: Option<i32>,
status: Option<&str>,
integration_id: Option<&str>,
impact: Option<&str>,
compliance: Option<bool>,
check_type: Option<&str>,
) -> Result<models::GetSecurityChecks, Error<GetSecurityChecksV3Error>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_id = id;
let p_query_limit = limit;
let p_query_offset = offset;
let p_query_status = status;
let p_query_integration_id = integration_id;
let p_query_impact = impact;
let p_query_compliance = compliance;
let p_query_check_type = check_type;
let uri_str = format!(
"{}/saas-security/entities/checks/v3",
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 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_status {
req_builder = req_builder.query(&[("status", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_integration_id {
req_builder = req_builder.query(&[("integration_id", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_impact {
req_builder = req_builder.query(&[("impact", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_compliance {
req_builder = req_builder.query(&[("compliance", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_check_type {
req_builder = req_builder.query(&[("check_type", ¶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::GetSecurityChecks`",
)));
}
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::GetSecurityChecks`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<GetSecurityChecksV3Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Get a list of supported integrations
pub async fn get_supported_saas_v3(
configuration: &configuration::Configuration,
) -> Result<models::GetSupportedSaas, Error<GetSupportedSaasV3Error>> {
let uri_str = format!(
"{}/saas-security/entities/supported-saas/v3",
configuration.base_path
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &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());
};
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::GetSupportedSaas`",
)));
}
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::GetSupportedSaas`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<GetSupportedSaasV3Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Get a list of all system logs
pub async fn get_system_logs_v3(
configuration: &configuration::Configuration,
from_date: Option<String>,
limit: Option<i32>,
offset: Option<i32>,
to_date: Option<String>,
total_count: Option<bool>,
) -> Result<models::GetSystemLogs, Error<GetSystemLogsV3Error>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_from_date = from_date;
let p_query_limit = limit;
let p_query_offset = offset;
let p_query_to_date = to_date;
let p_query_total_count = total_count;
let uri_str = format!(
"{}/saas-security/entities/system-logs/v3",
configuration.base_path
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_from_date {
req_builder = req_builder.query(&[("from_date", ¶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_to_date {
req_builder = req_builder.query(&[("to_date", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_total_count {
req_builder = req_builder.query(&[("total_count", ¶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::GetSystemLogs`",
)));
}
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::GetSystemLogs`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<GetSystemLogsV3Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Get a list of system users
pub async fn get_system_users_v3(
configuration: &configuration::Configuration,
) -> Result<models::GetSystemUsers, Error<GetSystemUsersV3Error>> {
let uri_str = format!(
"{}/saas-security/entities/system-users/v3",
configuration.base_path
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &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());
};
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::GetSystemUsers`",
)));
}
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::GetSystemUsers`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<GetSystemUsersV3Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Get a list of all users
pub async fn get_user_inventory_v3(
configuration: &configuration::Configuration,
integration_id: Option<&str>,
limit: Option<i32>,
offset: Option<i32>,
email: Option<&str>,
privileged_only: Option<bool>,
) -> Result<models::GetUserInventory, Error<GetUserInventoryV3Error>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_integration_id = integration_id;
let p_query_limit = limit;
let p_query_offset = offset;
let p_query_email = email;
let p_query_privileged_only = privileged_only;
let uri_str = format!(
"{}/saas-security/entities/users/v3",
configuration.base_path
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_integration_id {
req_builder = req_builder.query(&[("integration_id", ¶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_email {
req_builder = req_builder.query(&[("email", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_privileged_only {
req_builder = req_builder.query(&[("privileged_only", ¶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::GetUserInventory`",
)));
}
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::GetUserInventory`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<GetUserInventoryV3Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Make a close transaction call after uploading the data
pub async fn integration_builder_end_transaction_v3(
configuration: &configuration::Configuration,
id: &str,
) -> Result<models::GetEndTransaction, Error<IntegrationBuilderEndTransactionV3Error>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_id = id;
let uri_str = format!(
"{}/saas-security/entities/custom-integration-close/v3",
configuration.base_path
);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &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());
}
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::GetEndTransaction`",
)));
}
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::GetEndTransaction`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<IntegrationBuilderEndTransactionV3Error> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Get transaction status for a custom integration
pub async fn integration_builder_get_status_v3(
configuration: &configuration::Configuration,
id: &str,
) -> Result<models::GetTransactionStatus, Error<IntegrationBuilderGetStatusV3Error>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_id = id;
let uri_str = format!(
"{}/saas-security/entities/custom-integration-status/v3",
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());
}
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::GetTransactionStatus`",
)));
}
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::GetTransactionStatus`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<IntegrationBuilderGetStatusV3Error> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Make a reset call to a custom integration
pub async fn integration_builder_reset_v3(
configuration: &configuration::Configuration,
id: &str,
) -> Result<models::GetTransactionStatus, Error<IntegrationBuilderResetV3Error>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_id = id;
let uri_str = format!(
"{}/saas-security/entities/custom-integration-reset/v3",
configuration.base_path
);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &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());
}
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::GetTransactionStatus`",
)));
}
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::GetTransactionStatus`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<IntegrationBuilderResetV3Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Send data to a specific source in a custom integration
pub async fn integration_builder_upload_v3(
configuration: &configuration::Configuration,
id: &str,
source_id: &str,
body: models::UploadDataRequest,
) -> Result<models::UploadDataResponse, Error<IntegrationBuilderUploadV3Error>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_id = id;
let p_query_source_id = source_id;
let p_body_body = body;
let uri_str = format!(
"{}/saas-security/entities/custom-integration-upload/v3",
configuration.base_path
);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
req_builder = req_builder.query(&[("id", &p_query_id.to_string())]);
req_builder = req_builder.query(&[("source_id", &p_query_source_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());
};
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::UploadDataResponse`",
)));
}
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::UploadDataResponse`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<IntegrationBuilderUploadV3Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}