Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/alerts/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,13 +232,15 @@ impl DeploymentInfo {
pub enum AlertType {
Threshold,
Anomaly,
Forecast,
}

impl Display for AlertType {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
AlertType::Threshold => write!(f, "threshold"),
AlertType::Anomaly => write!(f, "anomaly"),
AlertType::Forecast => write!(f, "forecast"),
}
}
}
Expand Down Expand Up @@ -1358,6 +1360,8 @@ pub enum AlertError {
InvalidQueryParameter,
#[error("{0}")]
ArrowError(#[from] ArrowError),
#[error("Upgrade to Parseable Enterprise for {0} type alerts")]
NotPresentInOSS(String),
}

impl actix_web::ResponseError for AlertError {
Expand All @@ -1382,6 +1386,7 @@ impl actix_web::ResponseError for AlertError {
Self::InvalidAlertQuery => StatusCode::BAD_REQUEST,
Self::InvalidQueryParameter => StatusCode::BAD_REQUEST,
Self::ArrowError(_) => StatusCode::INTERNAL_SERVER_ERROR,
Self::NotPresentInOSS(_) => StatusCode::BAD_REQUEST,
}
}

Expand Down Expand Up @@ -1462,7 +1467,12 @@ impl AlertManagerTrait for Alerts {
}
AlertType::Anomaly => {
return Err(anyhow::Error::msg(
"Get Parseable Enterprise for Anomaly alerts",
AlertError::NotPresentInOSS("anomaly".into()).to_string(),
));
}
AlertType::Forecast => {
return Err(anyhow::Error::msg(
AlertError::NotPresentInOSS("forecast".into()).to_string(),
));
}
};
Expand Down
7 changes: 4 additions & 3 deletions src/handlers/http/alerts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,10 @@ pub async fn post(
&threshold_alert
}
AlertType::Anomaly => {
return Err(AlertError::CustomError(
"Get Parseable Enterprise for Anomaly alerts".into(),
));
return Err(AlertError::NotPresentInOSS("anomaly".into()));
}
AlertType::Forecast => {
return Err(AlertError::NotPresentInOSS("forecast".into()));
}
};

Expand Down
Loading