/*
* 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 [`aggregates_rule_versions_post_v1`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum AggregatesRuleVersionsPostV1Error {
Status400(models::ApiAggregatesResponseV1),
Status401(models::ApiAggregatesResponseV1),
Status403(models::ApiAggregatesResponseV1),
Status404(models::ApiAggregatesResponseV1),
Status429(models::MsaReplyMetaOnly),
Status500(models::ApiAggregatesResponseV1),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`combined_rules_get_v1`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CombinedRulesGetV1Error {
Status400(models::ApiGetEntitiesRulesResponseV1),
Status401(models::ApiGetEntitiesRulesResponseV1),
Status403(models::ApiGetEntitiesRulesResponseV1),
Status404(models::ApiGetEntitiesRulesResponseV1),
Status429(models::MsaReplyMetaOnly),
Status500(models::ApiGetEntitiesRulesResponseV1),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`combined_rules_get_v2`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CombinedRulesGetV2Error {
Status400(models::ApiGetEntitiesRulesResponseV1),
Status401(models::ApiGetEntitiesRulesResponseV1),
Status403(models::ApiGetEntitiesRulesResponseV1),
Status404(models::ApiGetEntitiesRulesResponseV1),
Status429(models::MsaReplyMetaOnly),
Status500(models::ApiGetEntitiesRulesResponseV1),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`entities_latest_rules_get_v1`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum EntitiesLatestRulesGetV1Error {
Status400(models::ApiGetEntitiesRulesResponseV1),
Status401(models::ApiGetEntitiesRulesResponseV1),
Status403(models::ApiGetEntitiesRulesResponseV1),
Status404(models::ApiGetEntitiesRulesResponseV1),
Status429(models::MsaReplyMetaOnly),
Status500(models::ApiGetEntitiesRulesResponseV1),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`entities_rule_versions_delete_v1`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum EntitiesRuleVersionsDeleteV1Error {
Status400(models::MsaspecQueryResponse),
Status401(models::MsaspecQueryResponse),
Status403(models::MsaspecQueryResponse),
Status404(models::MsaspecQueryResponse),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaspecQueryResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`entities_rule_versions_export_post_v1`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum EntitiesRuleVersionsExportPostV1Error {
Status400(models::ApiJobLinkResponseV1),
Status401(models::ApiJobLinkResponseV1),
Status403(models::ApiJobLinkResponseV1),
Status404(models::ApiJobLinkResponseV1),
Status429(models::MsaReplyMetaOnly),
Status500(models::ApiJobLinkResponseV1),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`entities_rule_versions_import_post_v1`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum EntitiesRuleVersionsImportPostV1Error {
Status400(models::ApiGetEntitiesRuleVersionsResponseV1),
Status401(models::ApiGetEntitiesRuleVersionsResponseV1),
Status403(models::ApiGetEntitiesRuleVersionsResponseV1),
Status404(models::ApiGetEntitiesRuleVersionsResponseV1),
Status429(models::MsaReplyMetaOnly),
Status500(models::ApiGetEntitiesRuleVersionsResponseV1),
Status503(models::ApiGetEntitiesRuleVersionsResponseV1),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`entities_rule_versions_publish_patch_v1`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum EntitiesRuleVersionsPublishPatchV1Error {
Status400(models::ApiGetEntitiesRuleVersionsResponseV1),
Status401(models::ApiGetEntitiesRuleVersionsResponseV1),
Status403(models::ApiGetEntitiesRuleVersionsResponseV1),
Status404(models::ApiGetEntitiesRuleVersionsResponseV1),
Status422(models::ApiGetEntitiesRuleVersionsResponseV1),
Status429(models::MsaReplyMetaOnly),
Status500(models::ApiGetEntitiesRuleVersionsResponseV1),
Status503(models::ApiGetEntitiesRulesResponseV1),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`entities_rules_delete_v1`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum EntitiesRulesDeleteV1Error {
Status400(models::MsaspecQueryResponse),
Status401(models::MsaspecQueryResponse),
Status403(models::MsaspecQueryResponse),
Status404(models::MsaspecQueryResponse),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaspecQueryResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`entities_rules_get_v1`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum EntitiesRulesGetV1Error {
Status400(models::ApiGetEntitiesRulesResponseV1),
Status401(models::ApiGetEntitiesRulesResponseV1),
Status403(models::ApiGetEntitiesRulesResponseV1),
Status404(models::ApiGetEntitiesRulesResponseV1),
Status429(models::MsaReplyMetaOnly),
Status500(models::ApiGetEntitiesRulesResponseV1),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`entities_rules_get_v2`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum EntitiesRulesGetV2Error {
Status400(models::ApiGetEntitiesRulesResponseV1),
Status401(models::ApiGetEntitiesRulesResponseV1),
Status403(models::ApiGetEntitiesRulesResponseV1),
Status404(models::ApiGetEntitiesRulesResponseV1),
Status429(models::MsaReplyMetaOnly),
Status500(models::ApiGetEntitiesRulesResponseV1),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`entities_rules_patch_v1`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum EntitiesRulesPatchV1Error {
Status400(models::ApiGetEntitiesRulesResponseV1),
Status401(models::ApiGetEntitiesRulesResponseV1),
Status403(models::ApiGetEntitiesRulesResponseV1),
Status404(models::ApiGetEntitiesRulesResponseV1),
Status422(models::ApiGetEntitiesRulesResponseV1),
Status429(models::MsaReplyMetaOnly),
Status500(models::ApiGetEntitiesRulesResponseV1),
Status503(models::ApiGetEntitiesRulesResponseV1),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`entities_rules_post_v1`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum EntitiesRulesPostV1Error {
Status400(models::ApiGetEntitiesRulesResponseV1),
Status401(models::ApiGetEntitiesRulesResponseV1),
Status403(models::ApiGetEntitiesRulesResponseV1),
Status404(models::ApiGetEntitiesRulesResponseV1),
Status429(models::MsaReplyMetaOnly),
Status500(models::ApiGetEntitiesRulesResponseV1),
Status503(models::ApiGetEntitiesRulesResponseV1),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`queries_rules_get_v1`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QueriesRulesGetV1Error {
Status400(models::MsaspecQueryResponse),
Status401(models::MsaspecQueryResponse),
Status403(models::MsaspecQueryResponse),
Status404(models::MsaspecQueryResponse),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaspecQueryResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`queries_rules_get_v2`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum QueriesRulesGetV2Error {
Status400(models::MsaspecQueryResponse),
Status401(models::MsaspecQueryResponse),
Status403(models::MsaspecQueryResponse),
Status404(models::MsaspecQueryResponse),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaspecQueryResponse),
UnknownValue(serde_json::Value),
}
pub async fn aggregates_rule_versions_post_v1(
configuration: &configuration::Configuration,
ids: Vec<String>,
body: Vec<serde_json::Value>,
filter: Option<&str>,
) -> Result<models::ApiAggregatesResponseV1, Error<AggregatesRuleVersionsPostV1Error>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_ids = ids;
let p_body_body = body;
let p_query_filter = filter;
let uri_str = format!(
"{}/correlation-rules/aggregates/rule-versions/v1",
configuration.base_path
);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
req_builder = match "multi" {
"multi" => req_builder.query(
&p_query_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_filter {
req_builder = req_builder.query(&[("filter", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
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::ApiAggregatesResponseV1`",
)));
}
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::ApiAggregatesResponseV1`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<AggregatesRuleVersionsPostV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn combined_rules_get_v1(
configuration: &configuration::Configuration,
filter: Option<&str>,
q: Option<&str>,
sort: Option<&str>,
offset: Option<i32>,
limit: Option<i32>,
) -> Result<models::ApiGetEntitiesRulesResponseV1, Error<CombinedRulesGetV1Error>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_filter = filter;
let p_query_q = q;
let p_query_sort = sort;
let p_query_offset = offset;
let p_query_limit = limit;
let uri_str = format!(
"{}/correlation-rules/combined/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_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_sort {
req_builder = req_builder.query(&[("sort", ¶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_limit {
req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => {
return Err(Error::from(serde_json::Error::custom(
"Received `text/plain` content type response that cannot be converted to `models::ApiGetEntitiesRulesResponseV1`",
)));
}
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::ApiGetEntitiesRulesResponseV1`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<CombinedRulesGetV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn combined_rules_get_v2(
configuration: &configuration::Configuration,
filter: Option<&str>,
q: Option<&str>,
sort: Option<&str>,
offset: Option<i32>,
limit: Option<i32>,
) -> Result<models::ApiGetEntitiesRulesResponseV1, Error<CombinedRulesGetV2Error>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_filter = filter;
let p_query_q = q;
let p_query_sort = sort;
let p_query_offset = offset;
let p_query_limit = limit;
let uri_str = format!(
"{}/correlation-rules/combined/rules/v2",
configuration.base_path
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_filter {
req_builder = req_builder.query(&[("filter", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_q {
req_builder = req_builder.query(&[("q", ¶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_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 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::ApiGetEntitiesRulesResponseV1`",
)));
}
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::ApiGetEntitiesRulesResponseV1`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<CombinedRulesGetV2Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn entities_latest_rules_get_v1(
configuration: &configuration::Configuration,
rule_ids: Vec<String>,
) -> Result<models::ApiGetEntitiesRulesResponseV1, Error<EntitiesLatestRulesGetV1Error>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_rule_ids = rule_ids;
let uri_str = format!(
"{}/correlation-rules/entities/latest-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_rule_ids
.into_iter()
.map(|p| ("rule_ids".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => req_builder.query(&[(
"rule_ids",
&p_query_rule_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::ApiGetEntitiesRulesResponseV1`",
)));
}
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::ApiGetEntitiesRulesResponseV1`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<EntitiesLatestRulesGetV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn entities_rule_versions_delete_v1(
configuration: &configuration::Configuration,
ids: Vec<String>,
) -> Result<models::MsaspecQueryResponse, Error<EntitiesRuleVersionsDeleteV1Error>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_ids = ids;
let uri_str = format!(
"{}/correlation-rules/entities/rule-versions/v1",
configuration.base_path
);
let mut req_builder = configuration
.client
.request(reqwest::Method::DELETE, &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::MsaspecQueryResponse`",
)));
}
ContentType::Unsupported(unknown_type) => {
return Err(Error::from(serde_json::Error::custom(format!(
"Received `{unknown_type}` content type response that cannot be converted to `models::MsaspecQueryResponse`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<EntitiesRuleVersionsDeleteV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn entities_rule_versions_export_post_v1(
configuration: &configuration::Configuration,
body: models::ApiRuleVersionReportRequest,
) -> Result<models::ApiJobLinkResponseV1, Error<EntitiesRuleVersionsExportPostV1Error>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_body = body;
let uri_str = format!(
"{}/correlation-rules/entities/rule-versions/export/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::ApiJobLinkResponseV1`",
)));
}
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::ApiJobLinkResponseV1`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<EntitiesRuleVersionsExportPostV1Error> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn entities_rule_versions_import_post_v1(
configuration: &configuration::Configuration,
) -> Result<
models::ApiGetEntitiesRuleVersionsResponseV1,
Error<EntitiesRuleVersionsImportPostV1Error>,
> {
let uri_str = format!(
"{}/correlation-rules/entities/rule-versions/import/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());
};
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::ApiGetEntitiesRuleVersionsResponseV1`",
)));
}
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::ApiGetEntitiesRuleVersionsResponseV1`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<EntitiesRuleVersionsImportPostV1Error> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn entities_rule_versions_publish_patch_v1(
configuration: &configuration::Configuration,
body: models::ApiRuleVersionPublishRequestV1,
) -> Result<
models::ApiGetEntitiesRuleVersionsResponseV1,
Error<EntitiesRuleVersionsPublishPatchV1Error>,
> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_body = body;
let uri_str = format!(
"{}/correlation-rules/entities/rule-versions/publish/v1",
configuration.base_path
);
let mut req_builder = configuration
.client
.request(reqwest::Method::PATCH, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_body);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => {
return Err(Error::from(serde_json::Error::custom(
"Received `text/plain` content type response that cannot be converted to `models::ApiGetEntitiesRuleVersionsResponseV1`",
)));
}
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::ApiGetEntitiesRuleVersionsResponseV1`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<EntitiesRuleVersionsPublishPatchV1Error> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn entities_rules_delete_v1(
configuration: &configuration::Configuration,
ids: Vec<String>,
) -> Result<models::MsaspecQueryResponse, Error<EntitiesRulesDeleteV1Error>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_ids = ids;
let uri_str = format!(
"{}/correlation-rules/entities/rules/v1",
configuration.base_path
);
let mut req_builder = configuration
.client
.request(reqwest::Method::DELETE, &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::MsaspecQueryResponse`",
)));
}
ContentType::Unsupported(unknown_type) => {
return Err(Error::from(serde_json::Error::custom(format!(
"Received `{unknown_type}` content type response that cannot be converted to `models::MsaspecQueryResponse`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<EntitiesRulesDeleteV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn entities_rules_get_v1(
configuration: &configuration::Configuration,
ids: Vec<String>,
) -> Result<models::ApiGetEntitiesRulesResponseV1, Error<EntitiesRulesGetV1Error>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_ids = ids;
let uri_str = format!(
"{}/correlation-rules/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::ApiGetEntitiesRulesResponseV1`",
)));
}
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::ApiGetEntitiesRulesResponseV1`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<EntitiesRulesGetV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn entities_rules_get_v2(
configuration: &configuration::Configuration,
ids: Vec<String>,
) -> Result<models::ApiGetEntitiesRulesResponseV1, Error<EntitiesRulesGetV2Error>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_ids = ids;
let uri_str = format!(
"{}/correlation-rules/entities/rules/v2",
configuration.base_path
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = match "multi" {
"multi" => req_builder.query(
&p_query_ids
.into_iter()
.map(|p| ("ids".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => req_builder.query(&[(
"ids",
&p_query_ids
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => {
return Err(Error::from(serde_json::Error::custom(
"Received `text/plain` content type response that cannot be converted to `models::ApiGetEntitiesRulesResponseV1`",
)));
}
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::ApiGetEntitiesRulesResponseV1`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<EntitiesRulesGetV2Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn entities_rules_patch_v1(
configuration: &configuration::Configuration,
body: Vec<models::ApiRulePatchRequestV1>,
) -> Result<models::ApiGetEntitiesRulesResponseV1, Error<EntitiesRulesPatchV1Error>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_body = body;
let uri_str = format!(
"{}/correlation-rules/entities/rules/v1",
configuration.base_path
);
let mut req_builder = configuration
.client
.request(reqwest::Method::PATCH, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_body);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => {
return Err(Error::from(serde_json::Error::custom(
"Received `text/plain` content type response that cannot be converted to `models::ApiGetEntitiesRulesResponseV1`",
)));
}
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::ApiGetEntitiesRulesResponseV1`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<EntitiesRulesPatchV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn entities_rules_post_v1(
configuration: &configuration::Configuration,
body: models::ApiRuleCreateRequestV1,
) -> Result<models::ApiGetEntitiesRulesResponseV1, Error<EntitiesRulesPostV1Error>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_body = body;
let uri_str = format!(
"{}/correlation-rules/entities/rules/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::ApiGetEntitiesRulesResponseV1`",
)));
}
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::ApiGetEntitiesRulesResponseV1`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<EntitiesRulesPostV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn queries_rules_get_v1(
configuration: &configuration::Configuration,
filter: Option<&str>,
q: Option<&str>,
sort: Option<&str>,
offset: Option<i32>,
limit: Option<i32>,
) -> Result<models::MsaspecQueryResponse, Error<QueriesRulesGetV1Error>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_filter = filter;
let p_query_q = q;
let p_query_sort = sort;
let p_query_offset = offset;
let p_query_limit = limit;
let uri_str = format!(
"{}/correlation-rules/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_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_sort {
req_builder = req_builder.query(&[("sort", ¶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_limit {
req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => {
return Err(Error::from(serde_json::Error::custom(
"Received `text/plain` content type response that cannot be converted to `models::MsaspecQueryResponse`",
)));
}
ContentType::Unsupported(unknown_type) => {
return Err(Error::from(serde_json::Error::custom(format!(
"Received `{unknown_type}` content type response that cannot be converted to `models::MsaspecQueryResponse`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<QueriesRulesGetV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn queries_rules_get_v2(
configuration: &configuration::Configuration,
filter: Option<&str>,
q: Option<&str>,
sort: Option<&str>,
offset: Option<i32>,
limit: Option<i32>,
) -> Result<models::MsaspecQueryResponse, Error<QueriesRulesGetV2Error>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_filter = filter;
let p_query_q = q;
let p_query_sort = sort;
let p_query_offset = offset;
let p_query_limit = limit;
let uri_str = format!(
"{}/correlation-rules/queries/rules/v2",
configuration.base_path
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_filter {
req_builder = req_builder.query(&[("filter", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_q {
req_builder = req_builder.query(&[("q", ¶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_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 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::MsaspecQueryResponse`",
)));
}
ContentType::Unsupported(unknown_type) => {
return Err(Error::from(serde_json::Error::custom(format!(
"Received `{unknown_type}` content type response that cannot be converted to `models::MsaspecQueryResponse`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<QueriesRulesGetV2Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}