use of io.hops.hopsworks.alerting.config.dto.Route in project hopsworks by logicalclocks.
the class AdminRouteResource method get.
@GET
@Path("{receiver}")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Get all routes.", response = RouteDTO.class)
@JWTRequired(acceptedTokens = { Audience.API }, allowedUserRoles = { "HOPS_ADMIN" })
public Response get(@PathParam("receiver") String receiver, @QueryParam("match") List<String> match, @QueryParam("matchRe") List<String> matchRe, @Context UriInfo uriInfo, @Context SecurityContext sc) throws AlertException {
ResourceRequest resourceRequest = new ResourceRequest(ResourceRequest.Name.ROUTES);
Route route = new Route(receiver).withMatch(routeBuilder.toMap(match)).withMatchRe(routeBuilder.toMap(matchRe));
RouteDTO dto = routeBuilder.build(uriInfo, resourceRequest, route, null);
return Response.ok().entity(dto).build();
}
use of io.hops.hopsworks.alerting.config.dto.Route in project hopsworks by logicalclocks.
the class TestAlertManagerConfigController method testAddRouteDuplicate.
@Test
public void testAddRouteDuplicate() throws AlertManagerResponseException, AlertManagerServerException {
Mockito.when(client.reload()).thenReturn(Response.ok().build());
Map<String, String> matches = new HashMap<>();
matches.put("project", "project1");
Route route = new Route("slack_general").withMatch(matches);
Assert.assertThrows(AlertManagerDuplicateEntryException.class, () -> {
alertManagerConfigController.addRoute(route);
});
}
use of io.hops.hopsworks.alerting.config.dto.Route in project hopsworks by logicalclocks.
the class TestAlertManagerConfigController method testAddRouteValidate.
@Test
public void testAddRouteValidate() throws AlertManagerResponseException, AlertManagerServerException {
Mockito.when(client.reload()).thenReturn(Response.ok().build());
Map<String, String> matches = new HashMap<>();
Route route = new Route();
Assert.assertThrows(IllegalArgumentException.class, () -> {
alertManagerConfigController.addRoute(route);
});
Route route1 = new Route("team-X-mails").withMatch(matches);
Assert.assertThrows(IllegalArgumentException.class, () -> {
alertManagerConfigController.addRoute(route1);
});
}
use of io.hops.hopsworks.alerting.config.dto.Route in project hopsworks by logicalclocks.
the class ConfigUtil method getRoute.
public static Route getRoute(AlertType alertType) {
Map<String, String> match = new HashMap<>();
match.put(Constants.ALERT_TYPE_LABEL, alertType.getValue());
List<String> groupBy = new ArrayList<>();
groupBy.add(Constants.LABEL_PROJECT);
groupBy.add(Constants.LABEL_JOB);
groupBy.add(Constants.LABEL_FEATURE_GROUP);
groupBy.add(Constants.LABEL_STATUS);
return new Route(alertType.getReceiverName()).withContinue(true).withMatch(match).withGroupBy(groupBy);
}
use of io.hops.hopsworks.alerting.config.dto.Route in project hopsworks by logicalclocks.
the class ConfigUtil method getRoute.
public static Route getRoute(FeatureGroupAlert alert) {
if (alert.getAlertType().isGlobal()) {
return getRoute(alert.getAlertType());
}
Map<String, String> match = getMatch(alert);
List<String> groupBy = new ArrayList<>();
groupBy.add(Constants.LABEL_PROJECT);
groupBy.add(Constants.LABEL_FEATURE_GROUP);
groupBy.add(Constants.LABEL_STATUS);
return new Route(alert.getReceiver().getName()).withContinue(true).withMatch(match).withGroupBy(groupBy);
}
Aggregations