use of org.graylog.plugins.sidecar.rest.models.Configuration in project graylog2-server by Graylog2.
the class ConfigurationServiceTest method testAddMissingNewline.
@Test
public void testAddMissingNewline() throws Exception {
configuration = buildTestConfig("template\n without\n newline");
this.configurationService.save(configuration);
Configuration result = this.configurationService.renderConfigurationForCollector(sidecar, configuration);
Configuration configWithNewline = buildTestConfig(configuration.template() + "\n");
assertEquals(configWithNewline, result);
}
use of org.graylog.plugins.sidecar.rest.models.Configuration in project graylog2-server by Graylog2.
the class SidecarCollectorConfigurationFacade method exportEntity.
@Override
public Optional<Entity> exportEntity(EntityDescriptor entityDescriptor, EntityDescriptorIds entityDescriptorIds) {
final ModelId modelId = entityDescriptor.id();
final Configuration configuration = configurationService.find(modelId.id());
if (isNull(configuration)) {
LOG.debug("Couldn't find collector configuration {}", entityDescriptor);
return Optional.empty();
}
return Optional.of(exportNativeEntity(configuration, entityDescriptorIds));
}
use of org.graylog.plugins.sidecar.rest.models.Configuration in project graylog2-server by Graylog2.
the class SidecarCollectorConfigurationFacade method resolveNativeEntity.
@Override
public Graph<EntityDescriptor> resolveNativeEntity(EntityDescriptor entityDescriptor) {
final MutableGraph<EntityDescriptor> mutableGraph = GraphBuilder.directed().build();
mutableGraph.addNode(entityDescriptor);
final ModelId modelId = entityDescriptor.id();
final Configuration configuration = configurationService.find(modelId.id());
if (isNull(configuration)) {
LOG.debug("Could not find configuration {}", entityDescriptor);
} else {
final EntityDescriptor collectorEntityDescriptor = EntityDescriptor.create(configuration.collectorId(), ModelTypes.SIDECAR_COLLECTOR_V1);
mutableGraph.putEdge(entityDescriptor, collectorEntityDescriptor);
}
return ImmutableGraph.copyOf(mutableGraph);
}
use of org.graylog.plugins.sidecar.rest.models.Configuration in project graylog2-server by Graylog2.
the class ConfigurationVariableResource method getConfigurationVariablesConfigurations.
@GET
@Path("/{id}/configurations")
@RequiresPermissions(SidecarRestPermissions.CONFIGURATIONS_READ)
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Show configurations using this variable")
public List<Configuration> getConfigurationVariablesConfigurations(@ApiParam(name = "id", required = true) @PathParam("id") String id) {
final ConfigurationVariable configurationVariable = findVariableOrFail(id);
final List<Configuration> configurations = this.configurationService.findByConfigurationVariable(configurationVariable);
return configurations;
}
use of org.graylog.plugins.sidecar.rest.models.Configuration in project graylog2-server by Graylog2.
the class ConfigurationVariableResource method deleteConfigurationVariable.
@DELETE
@Path("/{id}")
@RequiresPermissions(SidecarRestPermissions.CONFIGURATIONS_UPDATE)
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Delete a configuration variable")
@AuditEvent(type = SidecarAuditEventTypes.CONFIGURATION_VARIABLE_DELETE)
public Response deleteConfigurationVariable(@ApiParam(name = "id", required = true) @PathParam("id") String id) {
final ConfigurationVariable configurationVariable = findVariableOrFail(id);
final List<Configuration> configurations = this.configurationService.findByConfigurationVariable(configurationVariable);
if (!configurations.isEmpty()) {
final ValidationResult validationResult = new ValidationResult();
validationResult.addError("name", "Variable is still used in the following configurations: " + configurations.stream().map(c -> c.name()).collect(Collectors.joining(", ")));
return Response.status(Response.Status.BAD_REQUEST).entity(validationResult).build();
}
int deleted = configurationVariableService.delete(id);
if (deleted == 0) {
return Response.notModified().build();
}
etagService.invalidateAll();
return Response.accepted().build();
}
Aggregations