use of org.graylog2.contentpacks.model.entities.references.ValueReference in project graylog2-server by Graylog2.
the class SidecarCollectorFacade method decode.
private NativeEntity<Collector> decode(EntityV1 entity, Map<String, ValueReference> parameters) {
final SidecarCollectorEntity collectorEntity = objectMapper.convertValue(entity.data(), SidecarCollectorEntity.class);
final Collector collector = Collector.builder().name(collectorEntity.name().asString(parameters)).serviceType(collectorEntity.serviceType().asString(parameters)).nodeOperatingSystem(collectorEntity.nodeOperatingSystem().asString(parameters)).executablePath(collectorEntity.executablePath().asString(parameters)).executeParameters(collectorEntity.executeParameters().asString(parameters)).validationParameters(collectorEntity.validationParameters().asString(parameters)).defaultTemplate(collectorEntity.defaultTemplate().asString(parameters)).build();
final Collector savedCollector = collectorService.save(collector);
return NativeEntity.create(entity.id(), savedCollector.id(), TYPE_V1, collector.name(), savedCollector);
}
use of org.graylog2.contentpacks.model.entities.references.ValueReference in project graylog2-server by Graylog2.
the class SidecarCollectorFacade method findExisting.
private Optional<NativeEntity<Collector>> findExisting(EntityV1 entity, Map<String, ValueReference> parameters) {
final SidecarCollectorEntity collectorEntity = objectMapper.convertValue(entity.data(), SidecarCollectorEntity.class);
final String name = collectorEntity.name().asString(parameters);
final String os = collectorEntity.nodeOperatingSystem().asString(parameters);
final Optional<Collector> existingCollector = Optional.ofNullable(collectorService.findByNameAndOs(name, os));
return existingCollector.map(collector -> NativeEntity.create(entity.id(), collector.id(), TYPE_V1, collector.name(), collector));
}
use of org.graylog2.contentpacks.model.entities.references.ValueReference in project graylog2-server by Graylog2.
the class ViewFacade method createNativeEntity.
@Override
public NativeEntity<ViewDTO> createNativeEntity(Entity entity, Map<String, ValueReference> parameters, Map<EntityDescriptor, Object> nativeEntities, String username) {
ensureV1(entity);
final User user = Optional.ofNullable(userService.load(username)).orElseThrow(() -> new IllegalStateException("Cannot load user <" + username + "> from db"));
return decode((EntityV1) entity, parameters, nativeEntities, user);
}
use of org.graylog2.contentpacks.model.entities.references.ValueReference in project graylog2-server by Graylog2.
the class InputFacade method createExtractors.
private List<Extractor> createExtractors(final Input input, final List<ExtractorEntity> extractorEntities, final String username, final Map<String, ValueReference> parameters) throws Extractor.ReservedFieldException, org.graylog2.ConfigurationException, ExtractorFactory.NoSuchExtractorException, ValidationException {
final ImmutableList.Builder<Extractor> result = ImmutableList.builder();
for (ExtractorEntity extractorEntity : extractorEntities) {
final List<Converter> converters = createConverters(extractorEntity.converters(), parameters);
final Extractor extractor = addExtractor(input, extractorEntity.title().asString(parameters), extractorEntity.order().asInteger(parameters), extractorEntity.cursorStrategy().asEnum(parameters, Extractor.CursorStrategy.class), extractorEntity.type().asEnum(parameters, Extractor.Type.class), extractorEntity.sourceField().asString(parameters), extractorEntity.targetField().asString(parameters), toValueMap(extractorEntity.configuration(), parameters), converters, extractorEntity.conditionType().asEnum(parameters, Extractor.ConditionType.class), extractorEntity.conditionValue().asString(parameters), username);
result.add(extractor);
}
return result.build();
}
use of org.graylog2.contentpacks.model.entities.references.ValueReference in project graylog2-server by Graylog2.
the class SidecarCollectorConfigurationFacade method resolveEntityV1.
private Graph<Entity> resolveEntityV1(EntityV1 entity, Map<String, ValueReference> parameters, Map<EntityDescriptor, Entity> entities) {
final MutableGraph<Entity> mutableGraph = GraphBuilder.directed().build();
mutableGraph.addNode(entity);
final SidecarCollectorConfigurationEntity configurationEntity = objectMapper.convertValue(entity.data(), SidecarCollectorConfigurationEntity.class);
final EntityDescriptor collectorDescriptor = EntityDescriptor.create(configurationEntity.collectorId().asString(parameters), ModelTypes.SIDECAR_COLLECTOR_V1);
final Entity collectorEntity = entities.get(collectorDescriptor);
if (collectorEntity != null) {
mutableGraph.putEdge(entity, collectorEntity);
}
return ImmutableGraph.copyOf(mutableGraph);
}
Aggregations