@GET
 @Path("/")
 @Produces(APPLICATION_JSON)
 @ApiOperation(value = "Get triggers with optional filtering")
 @ApiResponses(
     value = {
       @ApiResponse(code = 200, message = "Success"),
       @ApiResponse(code = 500, message = "Internal server error")
     })
 public Response findTriggers(
     @ApiParam(
             required = false,
             value =
                 "filter out triggers for unspecified triggerIds, "
                     + "comma separated list of trigger IDs")
         @QueryParam("triggerIds")
         final String triggerIds,
     @ApiParam(
             required = false,
             value =
                 "filter out triggers for unspecified tags, comma separated list of "
                     + "tags, each tag of format 'name|value'. Specify '*' for value to match all values.")
         @QueryParam("tags")
         final String tags,
     @ApiParam(required = false, value = "return only thin triggers. Currently Ignored")
         @QueryParam("thin")
         final Boolean thin,
     @Context final UriInfo uri) {
   Pager pager = RequestUtil.extractPaging(uri);
   try {
     TriggersCriteria criteria = buildCriteria(triggerIds, tags, thin);
     Page<Trigger> triggerPage = definitions.getTriggers(tenantId, criteria, pager);
     if (log.isDebugEnabled()) {
       log.debug("Triggers: " + triggerPage);
     }
     if (isEmpty(triggerPage)) {
       return ResponseUtil.ok(triggerPage);
     }
     return ResponseUtil.paginatedOk(triggerPage, uri);
   } catch (Exception e) {
     log.debug(e.getMessage(), e);
     return ResponseUtil.internalError(e.getMessage());
   }
 }
Ejemplo n.º 2
0
 @GET
 @Path("/")
 @Produces(APPLICATION_JSON)
 @ApiOperation(
     value = "Get events with optional filtering.",
     response = Event.class,
     responseContainer = "List")
 @ApiResponses(
     value = {
       @ApiResponse(code = 200, message = "Successfully fetched list of events."),
       @ApiResponse(code = 400, message = "Bad Request/Invalid Parameters."),
       @ApiResponse(code = 500, message = "Internal server error.", response = ApiError.class)
     })
 public Response findEvents(
     @ApiParam(
             required = false,
             value = "Filter out events created before this time, millisecond since epoch.")
         @QueryParam("startTime")
         final Long startTime,
     @ApiParam(
             required = false,
             value = "Filter out events created after this time, millisecond since epoch.")
         @QueryParam("endTime")
         final Long endTime,
     @ApiParam(
             required = false,
             value =
                 "Filter out events for unspecified eventIds, "
                     + "comma separated list of event IDs.")
         @QueryParam("eventIds")
         final String eventIds,
     @ApiParam(
             required = false,
             value =
                 "Filter out events for unspecified triggers, "
                     + "comma separated list of trigger IDs.")
         @QueryParam("triggerIds")
         final String triggerIds,
     @ApiParam(
             required = false,
             value =
                 "Filter out events for unspecified categories, "
                     + "comma separated list of category values.")
         @QueryParam("categories")
         final String categories,
     @ApiParam(
             required = false,
             value =
                 "Filter out events for unspecified tags, comma separated list of tags, "
                     + "each tag of format 'name|value'. Specify '*' for value to match all values.")
         @QueryParam("tags")
         final String tags,
     @ApiParam(required = false, value = "Return only thin events, do not include: evalSets.")
         @QueryParam("thin")
         final Boolean thin,
     @Context final UriInfo uri) {
   Pager pager = RequestUtil.extractPaging(uri);
   try {
     EventsCriteria criteria =
         buildCriteria(startTime, endTime, eventIds, triggerIds, categories, tags, thin);
     Page<Event> eventPage = alertsService.getEvents(tenantId, criteria, pager);
     if (log.isDebugEnabled()) {
       log.debug("Events: " + eventPage);
     }
     if (isEmpty(eventPage)) {
       return ResponseUtil.ok(eventPage);
     }
     return ResponseUtil.paginatedOk(eventPage, uri);
   } catch (Exception e) {
     log.debug(e.getMessage(), e);
     if (e.getCause() != null && e.getCause() instanceof IllegalArgumentException) {
       return ResponseUtil.badRequest("Bad arguments: " + e.getMessage());
     }
     return ResponseUtil.internalError(e);
   }
 }