/*
* 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 [`get_intel_actor_entities`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetIntelActorEntitiesError {
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaErrorsOnly),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_intel_indicator_entities`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetIntelIndicatorEntitiesError {
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaErrorsOnly),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_intel_report_entities`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetIntelReportEntitiesError {
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaErrorsOnly),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_intel_report_pdf`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetIntelReportPdfError {
Status400(models::MsaErrorsOnly),
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaErrorsOnly),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_intel_rule_entities`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetIntelRuleEntitiesError {
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaErrorsOnly),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_intel_rule_file`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetIntelRuleFileError {
Status400(models::MsaErrorsOnly),
Status403(models::MsaReplyMetaOnly),
Status404(models::MsaErrorsOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaErrorsOnly),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_latest_intel_rule_file`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetLatestIntelRuleFileError {
Status400(models::MsaErrorsOnly),
Status403(models::MsaReplyMetaOnly),
Status404(models::MsaErrorsOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaErrorsOnly),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_malware_entities`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetMalwareEntitiesError {
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaReplyMetaOnly),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_malware_mitre_report`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetMalwareMitreReportError {
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaReplyMetaOnly),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_mitre_report`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetMitreReportError {
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaReplyMetaOnly),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_vulnerabilities`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetVulnerabilitiesError {
Status403(models::MsaReplyMetaOnly),
Status404(models::MsaErrorsOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaErrorsOnly),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`post_mitre_attacks`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PostMitreAttacksError {
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaReplyMetaOnly),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`query_intel_actor_entities`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QueryIntelActorEntitiesError {
Status400(models::MsaErrorsOnly),
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaErrorsOnly),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`query_intel_actor_ids`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QueryIntelActorIdsError {
Status400(models::MsaErrorsOnly),
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaErrorsOnly),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`query_intel_indicator_entities`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QueryIntelIndicatorEntitiesError {
Status400(models::MsaErrorsOnly),
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaErrorsOnly),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`query_intel_indicator_ids`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QueryIntelIndicatorIdsError {
Status400(models::MsaErrorsOnly),
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaErrorsOnly),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`query_intel_report_entities`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QueryIntelReportEntitiesError {
Status400(),
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaErrorsOnly),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`query_intel_report_ids`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QueryIntelReportIdsError {
Status400(models::MsaErrorsOnly),
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaErrorsOnly),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`query_intel_rule_ids`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QueryIntelRuleIdsError {
Status400(models::MsaErrorsOnly),
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaErrorsOnly),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`query_malware`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QueryMalwareError {
Status400(models::MsaspecResponseFields),
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaspecResponseFields),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`query_malware_entities`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QueryMalwareEntitiesError {
Status400(models::MsaspecResponseFields),
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaspecResponseFields),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`query_mitre_attacks`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QueryMitreAttacksError {
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaReplyMetaOnly),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`query_mitre_attacks_for_malware`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QueryMitreAttacksForMalwareError {
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaReplyMetaOnly),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`query_vulnerabilities`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QueryVulnerabilitiesError {
Status403(models::MsaReplyMetaOnly),
Status404(models::MsaErrorsOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaErrorsOnly),
UnknownValue(serde_json::Value),
}
pub async fn get_intel_actor_entities(
configuration: &configuration::Configuration,
ids: Vec<String>,
fields: Option<Vec<String>>,
) -> Result<models::DomainActorsResponse, Error<GetIntelActorEntitiesError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_ids = ids;
let p_query_fields = fields;
let uri_str = format!("{}/intel/entities/actors/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_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 param_value) = p_query_fields {
req_builder = match "multi" {
"multi" => req_builder.query(
¶m_value
.into_iter()
.map(|p| ("fields".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => req_builder.query(&[(
"fields",
¶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::DomainActorsResponse`",
)));
}
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::DomainActorsResponse`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<GetIntelActorEntitiesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_intel_indicator_entities(
configuration: &configuration::Configuration,
body: models::MsaIdsRequest,
) -> Result<models::DomainPublicIndicatorsV3Response, Error<GetIntelIndicatorEntitiesError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_body = body;
let uri_str = format!(
"{}/intel/entities/indicators/GET/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::DomainPublicIndicatorsV3Response`",
)));
}
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::DomainPublicIndicatorsV3Response`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<GetIntelIndicatorEntitiesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_intel_report_entities(
configuration: &configuration::Configuration,
ids: Vec<String>,
fields: Option<Vec<String>>,
) -> Result<models::DomainNewsResponse, Error<GetIntelReportEntitiesError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_ids = ids;
let p_query_fields = fields;
let uri_str = format!("{}/intel/entities/reports/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_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 param_value) = p_query_fields {
req_builder = match "multi" {
"multi" => req_builder.query(
¶m_value
.into_iter()
.map(|p| ("fields".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => req_builder.query(&[(
"fields",
¶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::DomainNewsResponse`",
)));
}
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::DomainNewsResponse`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<GetIntelReportEntitiesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_intel_report_pdf(
configuration: &configuration::Configuration,
id: Option<&str>,
ids: Option<&str>,
) -> Result<(), Error<GetIntelReportPdfError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_id = id;
let p_query_ids = ids;
let uri_str = format!("{}/intel/entities/report-files/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 param_value) = p_query_ids {
req_builder = req_builder.query(&[("ids", ¶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();
if !status.is_client_error() && !status.is_server_error() {
Ok(())
} else {
let content = resp.text().await?;
let entity: Option<GetIntelReportPdfError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_intel_rule_entities(
configuration: &configuration::Configuration,
ids: Vec<String>,
) -> Result<models::DomainRulesResponse, Error<GetIntelRuleEntitiesError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_ids = ids;
let uri_str = format!("{}/intel/entities/rules/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_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::DomainRulesResponse`",
)));
}
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::DomainRulesResponse`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<GetIntelRuleEntitiesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_intel_rule_file(
configuration: &configuration::Configuration,
id: i32,
accept: Option<&str>,
format: Option<&str>,
) -> Result<(), Error<GetIntelRuleFileError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_id = id;
let p_header_accept = accept;
let p_query_format = format;
let uri_str = format!("{}/intel/entities/rules-files/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 param_value) = p_query_format {
req_builder = req_builder.query(&[("format", ¶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(param_value) = p_header_accept {
req_builder = req_builder.header("Accept", param_value.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();
if !status.is_client_error() && !status.is_server_error() {
Ok(())
} else {
let content = resp.text().await?;
let entity: Option<GetIntelRuleFileError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_latest_intel_rule_file(
configuration: &configuration::Configuration,
r#type: &str,
accept: Option<&str>,
if_none_match: Option<&str>,
if_modified_since: Option<&str>,
format: Option<&str>,
) -> Result<(), Error<GetLatestIntelRuleFileError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_type = r#type;
let p_header_accept = accept;
let p_header_if_none_match = if_none_match;
let p_header_if_modified_since = if_modified_since;
let p_query_format = format;
let uri_str = format!(
"{}/intel/entities/rules-latest-files/v1",
configuration.base_path
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("type", &p_query_type.to_string())]);
if let Some(ref param_value) = p_query_format {
req_builder = req_builder.query(&[("format", ¶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(param_value) = p_header_accept {
req_builder = req_builder.header("Accept", param_value.to_string());
}
if let Some(param_value) = p_header_if_none_match {
req_builder = req_builder.header("If-None-Match", param_value.to_string());
}
if let Some(param_value) = p_header_if_modified_since {
req_builder = req_builder.header("If-Modified-Since", param_value.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();
if !status.is_client_error() && !status.is_server_error() {
Ok(())
} else {
let content = resp.text().await?;
let entity: Option<GetLatestIntelRuleFileError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_malware_entities(
configuration: &configuration::Configuration,
ids: Vec<String>,
) -> Result<models::DomainMalwareResponse, Error<GetMalwareEntitiesError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_ids = ids;
let uri_str = format!("{}/intel/entities/malware/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_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::DomainMalwareResponse`",
)));
}
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::DomainMalwareResponse`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<GetMalwareEntitiesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_malware_mitre_report(
configuration: &configuration::Configuration,
id: &str,
format: &str,
x_cs_useruuid: Option<&str>,
) -> Result<(), Error<GetMalwareMitreReportError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_id = id;
let p_query_format = format;
let p_header_x_cs_useruuid = x_cs_useruuid;
let uri_str = format!(
"{}/intel/entities/malware-mitre-reports/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())]);
req_builder = req_builder.query(&[("format", &p_query_format.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(param_value) = p_header_x_cs_useruuid {
req_builder = req_builder.header("X-CS-USERUUID", param_value.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();
if !status.is_client_error() && !status.is_server_error() {
Ok(())
} else {
let content = resp.text().await?;
let entity: Option<GetMalwareMitreReportError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_mitre_report(
configuration: &configuration::Configuration,
actor_id: &str,
format: &str,
) -> Result<(), Error<GetMitreReportError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_actor_id = actor_id;
let p_query_format = format;
let uri_str = format!(
"{}/intel/entities/mitre-reports/v1",
configuration.base_path
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("actor_id", &p_query_actor_id.to_string())]);
req_builder = req_builder.query(&[("format", &p_query_format.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();
if !status.is_client_error() && !status.is_server_error() {
Ok(())
} else {
let content = resp.text().await?;
let entity: Option<GetMitreReportError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_vulnerabilities(
configuration: &configuration::Configuration,
body: models::MsaIdsRequest,
) -> Result<models::DomainVulnerabilityResponse, Error<GetVulnerabilitiesError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_body = body;
let uri_str = format!(
"{}/intel/entities/vulnerabilities/GET/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::DomainVulnerabilityResponse`",
)));
}
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::DomainVulnerabilityResponse`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<GetVulnerabilitiesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn post_mitre_attacks(
configuration: &configuration::Configuration,
body: models::MsaIdsRequest,
) -> Result<(), Error<PostMitreAttacksError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_body = body;
let uri_str = format!("{}/intel/entities/mitre/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();
if !status.is_client_error() && !status.is_server_error() {
Ok(())
} else {
let content = resp.text().await?;
let entity: Option<PostMitreAttacksError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn query_intel_actor_entities(
configuration: &configuration::Configuration,
offset: Option<i32>,
limit: Option<i32>,
sort: Option<&str>,
filter: Option<&str>,
q: Option<&str>,
fields: Option<Vec<String>>,
) -> Result<models::DomainActorsResponse, Error<QueryIntelActorEntitiesError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_offset = offset;
let p_query_limit = limit;
let p_query_sort = sort;
let p_query_filter = filter;
let p_query_q = q;
let p_query_fields = fields;
let uri_str = format!("{}/intel/combined/actors/v1", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
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_limit {
req_builder = req_builder.query(&[("limit", ¶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_filter {
req_builder = req_builder.query(&[("filter", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_q {
req_builder = req_builder.query(&[("q", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_fields {
req_builder = match "multi" {
"multi" => req_builder.query(
¶m_value
.into_iter()
.map(|p| ("fields".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => req_builder.query(&[(
"fields",
¶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::DomainActorsResponse`",
)));
}
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::DomainActorsResponse`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<QueryIntelActorEntitiesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn query_intel_actor_ids(
configuration: &configuration::Configuration,
offset: Option<i32>,
limit: Option<i32>,
sort: Option<&str>,
filter: Option<&str>,
q: Option<&str>,
) -> Result<models::MsaQueryResponse, Error<QueryIntelActorIdsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_offset = offset;
let p_query_limit = limit;
let p_query_sort = sort;
let p_query_filter = filter;
let p_query_q = q;
let uri_str = format!("{}/intel/queries/actors/v1", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
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_limit {
req_builder = req_builder.query(&[("limit", ¶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_filter {
req_builder = req_builder.query(&[("filter", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_q {
req_builder = req_builder.query(&[("q", ¶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::MsaQueryResponse`",
)));
}
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::MsaQueryResponse`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<QueryIntelActorIdsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn query_intel_indicator_entities(
configuration: &configuration::Configuration,
offset: Option<i32>,
limit: Option<i32>,
sort: Option<&str>,
filter: Option<&str>,
q: Option<&str>,
include_deleted: Option<bool>,
include_relations: Option<bool>,
) -> Result<models::DomainPublicIndicatorsV3Response, Error<QueryIntelIndicatorEntitiesError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_offset = offset;
let p_query_limit = limit;
let p_query_sort = sort;
let p_query_filter = filter;
let p_query_q = q;
let p_query_include_deleted = include_deleted;
let p_query_include_relations = include_relations;
let uri_str = format!("{}/intel/combined/indicators/v1", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
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_limit {
req_builder = req_builder.query(&[("limit", ¶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_filter {
req_builder = req_builder.query(&[("filter", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_q {
req_builder = req_builder.query(&[("q", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_include_deleted {
req_builder = req_builder.query(&[("include_deleted", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_include_relations {
req_builder = req_builder.query(&[("include_relations", ¶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::DomainPublicIndicatorsV3Response`",
)));
}
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::DomainPublicIndicatorsV3Response`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<QueryIntelIndicatorEntitiesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn query_intel_indicator_ids(
configuration: &configuration::Configuration,
offset: Option<i32>,
limit: Option<i32>,
sort: Option<&str>,
filter: Option<&str>,
q: Option<&str>,
include_deleted: Option<bool>,
include_relations: Option<bool>,
) -> Result<models::MsaQueryResponse, Error<QueryIntelIndicatorIdsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_offset = offset;
let p_query_limit = limit;
let p_query_sort = sort;
let p_query_filter = filter;
let p_query_q = q;
let p_query_include_deleted = include_deleted;
let p_query_include_relations = include_relations;
let uri_str = format!("{}/intel/queries/indicators/v1", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
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_limit {
req_builder = req_builder.query(&[("limit", ¶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_filter {
req_builder = req_builder.query(&[("filter", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_q {
req_builder = req_builder.query(&[("q", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_include_deleted {
req_builder = req_builder.query(&[("include_deleted", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_include_relations {
req_builder = req_builder.query(&[("include_relations", ¶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::MsaQueryResponse`",
)));
}
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::MsaQueryResponse`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<QueryIntelIndicatorIdsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn query_intel_report_entities(
configuration: &configuration::Configuration,
offset: Option<i32>,
limit: Option<i32>,
sort: Option<&str>,
filter: Option<&str>,
q: Option<&str>,
fields: Option<Vec<String>>,
) -> Result<models::DomainNewsResponse, Error<QueryIntelReportEntitiesError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_offset = offset;
let p_query_limit = limit;
let p_query_sort = sort;
let p_query_filter = filter;
let p_query_q = q;
let p_query_fields = fields;
let uri_str = format!("{}/intel/combined/reports/v1", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
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_limit {
req_builder = req_builder.query(&[("limit", ¶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_filter {
req_builder = req_builder.query(&[("filter", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_q {
req_builder = req_builder.query(&[("q", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_fields {
req_builder = match "multi" {
"multi" => req_builder.query(
¶m_value
.into_iter()
.map(|p| ("fields".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => req_builder.query(&[(
"fields",
¶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::DomainNewsResponse`",
)));
}
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::DomainNewsResponse`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<QueryIntelReportEntitiesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn query_intel_report_ids(
configuration: &configuration::Configuration,
offset: Option<i32>,
limit: Option<i32>,
sort: Option<&str>,
filter: Option<&str>,
q: Option<&str>,
) -> Result<models::MsaQueryResponse, Error<QueryIntelReportIdsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_offset = offset;
let p_query_limit = limit;
let p_query_sort = sort;
let p_query_filter = filter;
let p_query_q = q;
let uri_str = format!("{}/intel/queries/reports/v1", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
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_limit {
req_builder = req_builder.query(&[("limit", ¶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_filter {
req_builder = req_builder.query(&[("filter", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_q {
req_builder = req_builder.query(&[("q", ¶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::MsaQueryResponse`",
)));
}
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::MsaQueryResponse`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<QueryIntelReportIdsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn query_intel_rule_ids(
configuration: &configuration::Configuration,
r#type: &str,
offset: Option<i32>,
limit: Option<i32>,
sort: Option<&str>,
name: Option<Vec<String>>,
description: Option<Vec<String>>,
tags: Option<Vec<String>>,
min_created_date: Option<i32>,
max_created_date: Option<&str>,
q: Option<&str>,
) -> Result<models::MsaQueryResponse, Error<QueryIntelRuleIdsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_type = r#type;
let p_query_offset = offset;
let p_query_limit = limit;
let p_query_sort = sort;
let p_query_name = name;
let p_query_description = description;
let p_query_tags = tags;
let p_query_min_created_date = min_created_date;
let p_query_max_created_date = max_created_date;
let p_query_q = q;
let uri_str = format!("{}/intel/queries/rules/v1", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
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_limit {
req_builder = req_builder.query(&[("limit", ¶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_name {
req_builder = match "csv" {
"multi" => req_builder.query(
¶m_value
.into_iter()
.map(|p| ("name".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => req_builder.query(&[(
"name",
¶m_value
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
req_builder = req_builder.query(&[("type", &p_query_type.to_string())]);
if let Some(ref param_value) = p_query_description {
req_builder = match "csv" {
"multi" => req_builder.query(
¶m_value
.into_iter()
.map(|p| ("description".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => req_builder.query(&[(
"description",
¶m_value
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref param_value) = p_query_tags {
req_builder = match "csv" {
"multi" => req_builder.query(
¶m_value
.into_iter()
.map(|p| ("tags".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => req_builder.query(&[(
"tags",
¶m_value
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref param_value) = p_query_min_created_date {
req_builder = req_builder.query(&[("min_created_date", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_max_created_date {
req_builder = req_builder.query(&[("max_created_date", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_q {
req_builder = req_builder.query(&[("q", ¶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::MsaQueryResponse`",
)));
}
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::MsaQueryResponse`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<QueryIntelRuleIdsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn query_malware(
configuration: &configuration::Configuration,
offset: Option<i32>,
limit: Option<i32>,
sort: Option<&str>,
filter: Option<&str>,
q: Option<&str>,
) -> Result<models::DomainQueryResponse, Error<QueryMalwareError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_offset = offset;
let p_query_limit = limit;
let p_query_sort = sort;
let p_query_filter = filter;
let p_query_q = q;
let uri_str = format!("{}/intel/queries/malware/v1", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
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_limit {
req_builder = req_builder.query(&[("limit", ¶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_filter {
req_builder = req_builder.query(&[("filter", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_q {
req_builder = req_builder.query(&[("q", ¶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::DomainQueryResponse`",
)));
}
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::DomainQueryResponse`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<QueryMalwareError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn query_malware_entities(
configuration: &configuration::Configuration,
offset: Option<i32>,
limit: Option<i32>,
sort: Option<&str>,
filter: Option<&str>,
q: Option<&str>,
fields: Option<Vec<String>>,
) -> Result<models::DomainMalwareResponse, Error<QueryMalwareEntitiesError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_offset = offset;
let p_query_limit = limit;
let p_query_sort = sort;
let p_query_filter = filter;
let p_query_q = q;
let p_query_fields = fields;
let uri_str = format!("{}/intel/combined/malware/v1", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
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_limit {
req_builder = req_builder.query(&[("limit", ¶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_filter {
req_builder = req_builder.query(&[("filter", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_q {
req_builder = req_builder.query(&[("q", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_fields {
req_builder = match "multi" {
"multi" => req_builder.query(
¶m_value
.into_iter()
.map(|p| ("fields".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => req_builder.query(&[(
"fields",
¶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::DomainMalwareResponse`",
)));
}
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::DomainMalwareResponse`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<QueryMalwareEntitiesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn query_mitre_attacks(
configuration: &configuration::Configuration,
id: Option<&str>,
ids: Option<Vec<String>>,
) -> Result<models::DomainQueryMitreAttacksResponse, Error<QueryMitreAttacksError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_id = id;
let p_query_ids = ids;
let uri_str = format!("{}/intel/queries/mitre/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 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::DomainQueryMitreAttacksResponse`",
)));
}
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::DomainQueryMitreAttacksResponse`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<QueryMitreAttacksError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn query_mitre_attacks_for_malware(
configuration: &configuration::Configuration,
ids: Vec<String>,
) -> Result<models::DomainQueryResponse, Error<QueryMitreAttacksForMalwareError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_ids = ids;
let uri_str = format!("{}/intel/queries/mitre-malware/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_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::DomainQueryResponse`",
)));
}
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::DomainQueryResponse`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<QueryMitreAttacksForMalwareError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn query_vulnerabilities(
configuration: &configuration::Configuration,
offset: Option<&str>,
limit: Option<i32>,
sort: Option<&str>,
filter: Option<&str>,
q: Option<&str>,
) -> Result<models::MsaQueryResponse, Error<QueryVulnerabilitiesError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_offset = offset;
let p_query_limit = limit;
let p_query_sort = sort;
let p_query_filter = filter;
let p_query_q = q;
let uri_str = format!(
"{}/intel/queries/vulnerabilities/v1",
configuration.base_path
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
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_limit {
req_builder = req_builder.query(&[("limit", ¶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_filter {
req_builder = req_builder.query(&[("filter", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_q {
req_builder = req_builder.query(&[("q", ¶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::MsaQueryResponse`",
)));
}
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::MsaQueryResponse`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<QueryVulnerabilitiesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}