You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by GitBox <gi...@apache.org> on 2020/03/05 17:10:09 UTC

[GitHub] [incubator-pinot] akshayrai 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

akshayrai 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_r388436966
 
 

 ##########
 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 is already a separate api to create just the detection.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org