adding alert subscriber mapping provider end point
@@ -10,9 +10,12 @@ import com.linkedin.thirdeye.datalayer.dto.AlertConfigDTO;
import com.linkedin.thirdeye.datalayer.dto.MergedAnomalyResultDTO;
import com.linkedin.thirdeye.detector.email.filter.AlertFilterFactory;
+import java.util.ArrayList;
import java.util.Arrays;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
@@ -62,6 +65,24 @@ public class EmailResource {
return Response.ok().build();
}
+ @GET
+ @Path("functions")
+ public Map<Long, List<AlertConfigDTO>> getAlertToSubscriberMapping() {
+ Map<Long, List<AlertConfigDTO>> mapping = new HashMap<>();
+ List<AlertConfigDTO> subscriberGroups = alertDAO.findAll();
+ for(AlertConfigDTO alertConfigDTO : subscriberGroups) {
+ if (null != alertConfigDTO.getEmailConfig()) {
+ for (Long alertFunctionId : alertConfigDTO.getEmailConfig().getFunctionIds()) {
+ if (!mapping.containsKey(alertFunctionId)) {
+ mapping.put(alertFunctionId, new ArrayList<AlertConfigDTO>());
+ }
+ mapping.get(alertFunctionId).add(alertConfigDTO);
+ }
+ }
+ }
+ return mapping;
+ }
+
/**
* End point to send anomalies by datasets
* @param startTime start time to generate anomalies
