xiaohui-sun commented on a change in pull request #5113: [TE] added a couple of
validations to check if detection is subscribed & valid; cleaned up other
validations
URL: https://github.com/apache/incubator-pinot/pull/5113#discussion_r388412999
##########
File path:
thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/yaml/YamlResource.java
##########
@@ -262,6 +263,23 @@ private Response processBadAuthorizationResponse(String
type, String operation,
return
Response.status(Response.Status.UNAUTHORIZED).entity(responseMessage).build();
}
+ /**
+ * Perform some basic validations on the create alert payload
+ */
+ public void validateCreateAlertYaml(Map<String, String> config) throws
IOException {
+ Preconditions.checkArgument(config.containsKey(PROP_DETECTION), "Detection
pipeline yaml is missing");
+ Preconditions.checkArgument(config.containsKey(PROP_SUBSCRIPTION),
"Subscription group yaml is missing.");
+
+ // check if subscription group has subscribed to the detection
+ Map<String, Object> detectionConfigMap = new
HashMap<>(ConfigUtils.getMap(this.yaml.load(config.get(PROP_DETECTION))));
+ String detectionName = MapUtils.getString(detectionConfigMap,
PROP_DETECTION_NAME);
+ Map<String, Object> subscriptionConfigMap = new
HashMap<>(ConfigUtils.getMap(this.yaml.load(config.get(PROP_SUBSCRIPTION))));
+ List<String> detectionNames =
ConfigUtils.getList(subscriptionConfigMap.get(PROP_DETECTION_NAMES));
+ Preconditions.checkArgument(detectionNames.contains(detectionName),
+ "You have not subscribed to the alert. Please copy-paste the
detectionName under the "
Review comment:
There are some use cases (e.g, DHM) that they only want to create alert w/o
subscription groups.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]