コード例 #1
0
 @DELETE
 @Path("/{eventId}")
 @ApiOperation(value = "Delete an existing Event.")
 @ApiResponses(
     value = {
       @ApiResponse(code = 200, message = "Success, Event deleted."),
       @ApiResponse(code = 500, message = "Internal server error.", response = ApiError.class),
       @ApiResponse(code = 404, message = "Event not found.", response = ApiError.class)
     })
 public Response deleteEvent(
     @ApiParam(required = true, value = "Event id to be deleted.") @PathParam("eventId")
         final String eventId) {
   try {
     EventsCriteria criteria = new EventsCriteria();
     criteria.setEventId(eventId);
     int numDeleted = alertsService.deleteEvents(tenantId, criteria);
     if (1 == numDeleted) {
       if (log.isDebugEnabled()) {
         log.debug("EventId: " + eventId);
       }
       return ResponseUtil.ok();
     } else {
       return ResponseUtil.notFound("Event " + eventId + " doesn't exist for delete");
     }
   } catch (Exception e) {
     log.debug(e.getMessage(), e);
     return ResponseUtil.internalError(e);
   }
 }
コード例 #2
0
 @PUT
 @Path("/delete")
 @Produces(APPLICATION_JSON)
 @ApiOperation(
     value = "Delete events with optional filtering.",
     notes = "Return number of events deleted.",
     response = Integer.class)
 @ApiResponses(
     value = {
       @ApiResponse(code = 200, message = "Success."),
       @ApiResponse(code = 400, message = "Bad Request/Invalid Parameters."),
       @ApiResponse(code = 500, message = "Internal server error.", response = ApiError.class)
     })
 public Response deleteEvents(
     @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) {
   try {
     EventsCriteria criteria =
         buildCriteria(startTime, endTime, eventIds, triggerIds, categories, tags, null);
     int numDeleted = alertsService.deleteEvents(tenantId, criteria);
     if (log.isDebugEnabled()) {
       log.debug("Events deleted: " + numDeleted);
     }
     return ResponseUtil.ok(numDeleted);
   } 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);
   }
 }