Skip to content

Commit a8c1f80

Browse files
authored
feat: add forecast alerts (#1394)
1 parent d307215 commit a8c1f80

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

src/alerts/mod.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,13 +232,15 @@ impl DeploymentInfo {
232232
pub enum AlertType {
233233
Threshold,
234234
Anomaly,
235+
Forecast,
235236
}
236237

237238
impl Display for AlertType {
238239
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
239240
match self {
240241
AlertType::Threshold => write!(f, "threshold"),
241242
AlertType::Anomaly => write!(f, "anomaly"),
243+
AlertType::Forecast => write!(f, "forecast"),
242244
}
243245
}
244246
}
@@ -1358,6 +1360,8 @@ pub enum AlertError {
13581360
InvalidQueryParameter,
13591361
#[error("{0}")]
13601362
ArrowError(#[from] ArrowError),
1363+
#[error("Upgrade to Parseable Enterprise for {0} type alerts")]
1364+
NotPresentInOSS(String),
13611365
}
13621366

13631367
impl actix_web::ResponseError for AlertError {
@@ -1382,6 +1386,7 @@ impl actix_web::ResponseError for AlertError {
13821386
Self::InvalidAlertQuery => StatusCode::BAD_REQUEST,
13831387
Self::InvalidQueryParameter => StatusCode::BAD_REQUEST,
13841388
Self::ArrowError(_) => StatusCode::INTERNAL_SERVER_ERROR,
1389+
Self::NotPresentInOSS(_) => StatusCode::BAD_REQUEST,
13851390
}
13861391
}
13871392

@@ -1462,7 +1467,12 @@ impl AlertManagerTrait for Alerts {
14621467
}
14631468
AlertType::Anomaly => {
14641469
return Err(anyhow::Error::msg(
1465-
"Get Parseable Enterprise for Anomaly alerts",
1470+
AlertError::NotPresentInOSS("anomaly".into()).to_string(),
1471+
));
1472+
}
1473+
AlertType::Forecast => {
1474+
return Err(anyhow::Error::msg(
1475+
AlertError::NotPresentInOSS("forecast".into()).to_string(),
14661476
));
14671477
}
14681478
};

src/handlers/http/alerts.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,10 @@ pub async fn post(
8282
&threshold_alert
8383
}
8484
AlertType::Anomaly => {
85-
return Err(AlertError::CustomError(
86-
"Get Parseable Enterprise for Anomaly alerts".into(),
87-
));
85+
return Err(AlertError::NotPresentInOSS("anomaly".into()));
86+
}
87+
AlertType::Forecast => {
88+
return Err(AlertError::NotPresentInOSS("forecast".into()));
8889
}
8990
};
9091

0 commit comments

Comments
 (0)