use of org.graylog2.audit.jersey.NoAuditEvent in project graylog2-server by Graylog2.
the class LookupTableResource method validateAdapter.
@POST
@Path("adapters/validate")
@NoAuditEvent("Validation only")
@ApiOperation(value = "Validate the data adapter config")
@RequiresPermissions(RestPermissions.LOOKUP_TABLES_READ)
public ValidationResult validateAdapter(@Valid @ApiParam DataAdapterApi toValidate) {
final ValidationResult validation = new ValidationResult();
final Optional<DataAdapterDto> dtoOptional = dbDataAdapterService.get(toValidate.name());
if (dtoOptional.isPresent()) {
// an adapter exist with the given name, check that the IDs are the same, this might be an update
final DataAdapterDto adapterDto = dtoOptional.get();
// noinspection ConstantConditions
if (!adapterDto.id().equals(toValidate.id())) {
// an adapter exists with a different id, so the name is already in use, fail validation
validation.addError("name", "The data adapter name is already in use.");
}
}
final Optional<Multimap<String, String>> configValidations = toValidate.config().validate(lookupDataAdapterValidationContext);
configValidations.ifPresent(validation::addAll);
return validation;
}
use of org.graylog2.audit.jersey.NoAuditEvent in project graylog2-server by Graylog2.
the class MetricsResource method multipleMetrics.
@POST
@Timed
@Path("/multiple")
@ApiOperation("Get the values of multiple metrics at once")
@ApiResponses(value = { @ApiResponse(code = 400, message = "Malformed body") })
@NoAuditEvent("only used to retrieve multiple metrics")
public MetricsSummaryResponse multipleMetrics(@ApiParam(name = "Requested metrics", required = true) @Valid @NotNull MetricsReadRequest request) {
final Map<String, Metric> metrics = metricRegistry.getMetrics();
final List<Map<String, Object>> metricsList = Lists.newArrayList();
for (String name : request.metrics()) {
if (!isPermitted(RestPermissions.METRICS_READ, name)) {
continue;
}
final Metric metric = metrics.get(name);
if (metric != null) {
metricsList.add(MetricUtils.map(name, metric));
}
}
return MetricsSummaryResponse.create(metricsList);
}
use of org.graylog2.audit.jersey.NoAuditEvent in project graylog2-server by Graylog2.
the class EventNotificationsResource method test.
@POST
@Timed
@Path("/test")
@RequiresPermissions(RestPermissions.EVENT_NOTIFICATIONS_CREATE)
@ApiOperation(value = "Send a test alert for a given event notification")
@ApiResponses(value = { @ApiResponse(code = 400, message = "Event notification is invalid."), @ApiResponse(code = 500, message = "Error while testing event notification") })
@NoAuditEvent("only used to test event notifications")
public Response test(@ApiParam(name = "JSON Body") NotificationDto dto) {
checkPermission(RestPermissions.EVENT_NOTIFICATIONS_CREATE);
final ValidationResult validationResult = dto.validate();
if (validationResult.failed()) {
return Response.status(Response.Status.BAD_REQUEST).entity(validationResult).build();
}
resourceHandler.test(dto, getSubject().getPrincipal().toString());
return Response.ok().build();
}
use of org.graylog2.audit.jersey.NoAuditEvent in project graylog2-server by Graylog2.
the class EventNotificationsResource method test.
@POST
@Timed
@Path("/{notificationId}/test")
@ApiOperation(value = "Send a test alert for a given event notification")
@ApiResponses(value = { @ApiResponse(code = 404, message = "Event notification not found."), @ApiResponse(code = 500, message = "Error while testing event notification") })
@NoAuditEvent("only used to test event notifications")
public Response test(@ApiParam(name = "notificationId", value = "The event notification id to send a test alert for.", required = true) @PathParam("notificationId") @NotBlank String notificationId) {
checkPermission(RestPermissions.EVENT_NOTIFICATIONS_EDIT, notificationId);
final NotificationDto notificationDto = dbNotificationService.get(notificationId).orElseThrow(() -> new NotFoundException("Notification " + notificationId + " doesn't exist"));
resourceHandler.test(notificationDto, getSubject().getPrincipal().toString());
return Response.ok().build();
}
Aggregations