use of org.graylog2.contentpacks.model.entities.NativeEntity in project graylog2-server by Graylog2.
the class PipelineRuleFacade method decode.
private NativeEntity<RuleDao> decode(EntityV1 entity, Map<String, ValueReference> parameters) {
final PipelineRuleEntity ruleEntity = objectMapper.convertValue(entity.data(), PipelineRuleEntity.class);
final String title = ruleEntity.title().asString(parameters);
final String source = ruleEntity.source().asString(parameters);
final DateTime now = Tools.nowUTC();
final ValueReference description = ruleEntity.description();
final RuleDao ruleDao = RuleDao.builder().title(title).description(description == null ? null : description.asString(parameters)).source(source).createdAt(now).modifiedAt(now).build();
final RuleDao savedRuleDao = ruleService.save(ruleDao);
return NativeEntity.create(entity.id(), savedRuleDao.id(), TYPE_V1, savedRuleDao.title(), savedRuleDao);
}
use of org.graylog2.contentpacks.model.entities.NativeEntity 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.NativeEntity 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.NativeEntity 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.NativeEntity in project graylog2-server by Graylog2.
the class GrokPatternFacade method findExisting.
private Optional<NativeEntity<GrokPattern>> findExisting(EntityV1 entity) {
final GrokPatternEntity grokPatternEntity = objectMapper.convertValue(entity.data(), GrokPatternEntity.class);
final String name = grokPatternEntity.name();
final String pattern = grokPatternEntity.pattern();
final Optional<GrokPattern> grokPattern = grokPatternService.loadByName(name);
grokPattern.ifPresent(existingPattern -> compareGrokPatterns(name, pattern, existingPattern.pattern()));
return grokPattern.map(gp -> NativeEntity.create(entity.id(), gp.id(), TYPE_V1, gp.name(), gp));
}
Aggregations