@DELETE @Path("{queryId}/{token}") @Produces(MediaType.APPLICATION_JSON) public Response cancelQuery(@PathParam("queryId") QueryId queryId, @PathParam("token") long token) { Query query = queries.get(queryId); if (query == null) { return Response.status(Status.NOT_FOUND).build(); } query.cancel(); return Response.noContent().build(); }
@PUT @RequiresPermissions(value = {RestPermissions.LDAPGROUPS_EDIT, RestPermissions.LDAP_EDIT}, logical = OR) @ApiOperation(value = "Update the LDAP group to Graylog role mapping", notes = "Corresponds directly to the output of GET /system/ldap/settings/groups") @Path("/settings/groups") @Consumes(MediaType.APPLICATION_JSON) @AuditEvent(type = AuditEventTypes.LDAP_GROUP_MAPPING_UPDATE) public Response updateGroupMappingSettings(@ApiParam(name = "JSON body", required = true, value = "A hash in which the keys are the LDAP group names and values is the Graylog role name.") @NotNull Map<String, String> groupMapping) throws ValidationException { final LdapSettings ldapSettings = firstNonNull(ldapSettingsService.load(), ldapSettingsFactory.createEmpty()); ldapSettings.setGroupMapping(groupMapping); ldapSettingsService.save(ldapSettings); return Response.noContent().build(); }
@POST @Path("/{dataSourceName}") @Consumes(MediaType.APPLICATION_JSON) @ResourceFilters(DatasourceResourceFilter.class) public Response enableDataSource( @PathParam("dataSourceName") final String dataSourceName ) { if (!databaseSegmentManager.enableDataSource(dataSourceName)) { return Response.noContent().build(); } return Response.ok().build(); }
@DELETE @Path("/v1/proxy") @Produces(APPLICATION_JSON) public void cancelQuery( @QueryParam("uri") String uri, @QueryParam("hmac") String hash, @Context HttpServletRequest servletRequest, @Suspended AsyncResponse asyncResponse) { if (!hmac.hashString(uri, UTF_8).equals(HashCode.fromString(hash))) { throw badRequest(FORBIDDEN, "Failed to validate HMAC of URI"); } Request.Builder request = prepareDelete().setUri(URI.create(uri)); performRequest(servletRequest, asyncResponse, request, response -> responseWithHeaders(noContent(), response)); }
@DELETE @Path("/{dataSourceName}/segments/{segmentId}") @ResourceFilters(DatasourceResourceFilter.class) public Response deleteDatasourceSegment( @PathParam("dataSourceName") String dataSourceName, @PathParam("segmentId") String segmentId ) { if (databaseSegmentManager.removeSegment(dataSourceName, segmentId)) { return Response.ok().build(); } return Response.noContent().build(); }
@POST @Path("test") public Response test(@QueryParam("deviceId") long deviceId, Attribute entity) throws SQLException { Context.getPermissionsManager().checkAdmin(getUserId()); Context.getPermissionsManager().checkDevice(getUserId(), deviceId); Position last = Context.getIdentityManager().getLastPosition(deviceId); if (last != null) { Object result = new ComputedAttributesHandler().computeAttribute(entity, last); if (result != null) { switch (entity.getType()) { case "number": Number numberValue = (Number) result; return Response.ok(numberValue).build(); case "boolean": Boolean booleanValue = (Boolean) result; return Response.ok(booleanValue).build(); default: return Response.ok(result.toString()).build(); } } else { return Response.noContent().build(); } } else { throw new IllegalArgumentException("Device has no last position"); } }
@POST @Path("/{dataSourceName}/segments/{segmentId}") @Consumes(MediaType.APPLICATION_JSON) @ResourceFilters(DatasourceResourceFilter.class) public Response enableDatasourceSegment( @PathParam("dataSourceName") String dataSourceName, @PathParam("segmentId") String segmentId ) { if (!databaseSegmentManager.enableSegment(segmentId)) { return Response.noContent().build(); } return Response.ok().build(); }
@POST @Path("test") public Response testMessage() throws MessageException, InterruptedException { for (Typed method : Context.getNotificatorManager().getAllNotificatorTypes()) { Context.getNotificatorManager() .getNotificator(method.getType()).sendSync(getUserId(), new Event("test", 0), null); } return Response.noContent().build(); }
@GET @Path( "/saveFile/{path}/{name}/{override}" ) public Response saveFile( @PathParam( "path" ) String path, @PathParam( "name" ) String name, @PathParam( "override" ) String override ) { boolean overwrite = override != null && override.toLowerCase().equals( "true" ); if ( repositoryBrowserController.saveFile( path, name, "", overwrite ) ) { return Response.ok().build(); } return Response.noContent().build(); }
@Path("{id}/accumulators") @PUT public Response updateAccumulators(DeviceAccumulators entity) throws SQLException { if (!Context.getPermissionsManager().getUserAdmin(getUserId())) { Context.getPermissionsManager().checkManager(getUserId()); Context.getPermissionsManager().checkPermission(Device.class, getUserId(), entity.getDeviceId()); } Context.getDeviceManager().resetDeviceAccumulators(entity); LogAction.resetDeviceAccumulators(getUserId(), entity.getDeviceId()); return Response.noContent().build(); }
@GET @Path( "/checkForSecurityOrDupeIssues/{path}/{name}/{fileName}/{override}" ) public Response checkForSecurityOrDupeIssues( @PathParam( "path" ) String path, @PathParam( "name" ) String name, @PathParam( "fileName" ) String fileName, @PathParam( "override" ) String override ) { boolean overwrite = override != null && override.toLowerCase().equals( "true" ); if ( repositoryBrowserController.checkForSecurityOrDupeIssues( path, name, fileName, overwrite ) ) { return Response.ok().build(); } return Response.noContent().build(); }
@Path("/{jpaQuery}") public Response executeUpdateJPAQuery(@Context HttpHeaders headers, @Context UriInfo info, String parameters) { String jpaQuery = info.getPathParameters().getFirst("jpaQuery"); return Response.noContent().build(); return Response.noContent().build(); return Response.ok(result, mediaType).build();
@GET @Path( "/checkForSecurityOrDupeIssues/{path}/{name}/{override}" ) public Response checkForSecurityOrDupeIssues( @PathParam( "path" ) String path, @PathParam( "name" ) String name, @PathParam( "override" ) String override ) { boolean overwrite = override != null && override.toLowerCase().equals( "true" ); if ( repositoryBrowserController.checkForSecurityOrDupeIssues( path, name, "", overwrite ) ) { return Response.ok().build(); } return Response.noContent().build(); }
@Path("/{jpaQuery}") public Response executeDeleteJPAQuery(@Context HttpHeaders headers, @Context UriInfo info, String parameters) { String jpaQuery = info.getPathParameters().getFirst("jpaQuery"); return Response.noContent().build(); return Response.noContent().build(); return Response.ok(result, mediaType).build();