Search in sources :

Example 6 with EntityDescriptorIds

use of org.graylog2.contentpacks.EntityDescriptorIds in project graylog2-server by Graylog2.

the class OutputFacade method exportNativeEntity.

@VisibleForTesting
Entity exportNativeEntity(Output output, EntityDescriptorIds entityDescriptorIds) {
    final OutputEntity outputEntity = OutputEntity.create(ValueReference.of(output.getTitle()), ValueReference.of(output.getType()), toReferenceMap(output.getConfiguration()));
    final JsonNode data = objectMapper.convertValue(outputEntity, JsonNode.class);
    final Set<Constraint> constraints = versionConstraints(output);
    return EntityV1.builder().id(ModelId.of(entityDescriptorIds.getOrThrow(output.getId(), ModelTypes.OUTPUT_V1))).type(ModelTypes.OUTPUT_V1).constraints(ImmutableSet.copyOf(constraints)).data(data).build();
}
Also used : Constraint(org.graylog2.contentpacks.model.constraints.Constraint) PluginVersionConstraint(org.graylog2.contentpacks.model.constraints.PluginVersionConstraint) OutputEntity(org.graylog2.contentpacks.model.entities.OutputEntity) JsonNode(com.fasterxml.jackson.databind.JsonNode) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 7 with EntityDescriptorIds

use of org.graylog2.contentpacks.EntityDescriptorIds in project graylog2-server by Graylog2.

the class PipelineRuleFacade method exportNativeEntity.

@VisibleForTesting
Entity exportNativeEntity(RuleDao ruleDao, EntityDescriptorIds entityDescriptorIds) {
    final PipelineRuleEntity ruleEntity = PipelineRuleEntity.create(ValueReference.of(ruleDao.title()), ValueReference.of(ruleDao.description()), ValueReference.of(ruleDao.source()));
    final JsonNode data = objectMapper.convertValue(ruleEntity, JsonNode.class);
    return EntityV1.builder().id(ModelId.of(entityDescriptorIds.getOrThrow(ruleDao.id(), ModelTypes.PIPELINE_RULE_V1))).type(ModelTypes.PIPELINE_RULE_V1).data(data).build();
}
Also used : PipelineRuleEntity(org.graylog2.contentpacks.model.entities.PipelineRuleEntity) JsonNode(com.fasterxml.jackson.databind.JsonNode) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 8 with EntityDescriptorIds

use of org.graylog2.contentpacks.EntityDescriptorIds in project graylog2-server by Graylog2.

the class SidecarCollectorFacade method exportEntity.

@Override
public Optional<Entity> exportEntity(EntityDescriptor entityDescriptor, EntityDescriptorIds entityDescriptorIds) {
    final ModelId modelId = entityDescriptor.id();
    final Collector collector = collectorService.find(modelId.id());
    if (isNull(collector)) {
        LOG.debug("Couldn't find collector {}", entityDescriptor);
        return Optional.empty();
    }
    return Optional.of(exportNativeEntity(collector, entityDescriptorIds));
}
Also used : Collector(org.graylog.plugins.sidecar.rest.models.Collector) ModelId(org.graylog2.contentpacks.model.ModelId)

Example 9 with EntityDescriptorIds

use of org.graylog2.contentpacks.EntityDescriptorIds in project graylog2-server by Graylog2.

the class SidecarCollectorFacade method exportNativeEntity.

@VisibleForTesting
Entity exportNativeEntity(Collector collector, EntityDescriptorIds entityDescriptorIds) {
    final SidecarCollectorEntity collectorEntity = SidecarCollectorEntity.create(ValueReference.of(collector.name()), ValueReference.of(collector.serviceType()), ValueReference.of(collector.nodeOperatingSystem()), ValueReference.of(collector.executablePath()), ValueReference.of(collector.executeParameters()), ValueReference.of(collector.validationParameters()), ValueReference.of(collector.defaultTemplate()));
    final JsonNode data = objectMapper.convertValue(collectorEntity, JsonNode.class);
    return EntityV1.builder().id(ModelId.of(entityDescriptorIds.getOrThrow(collector.id(), ModelTypes.SIDECAR_COLLECTOR_V1))).type(TYPE_V1).data(data).build();
}
Also used : SidecarCollectorEntity(org.graylog2.contentpacks.model.entities.SidecarCollectorEntity) JsonNode(com.fasterxml.jackson.databind.JsonNode) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 10 with EntityDescriptorIds

use of org.graylog2.contentpacks.EntityDescriptorIds in project graylog2-server by Graylog2.

the class GrokPatternFacade method exportNativeEntity.

@VisibleForTesting
Entity exportNativeEntity(GrokPattern grokPattern, EntityDescriptorIds entityDescriptorIds) {
    final GrokPatternEntity grokPatternEntity = GrokPatternEntity.create(grokPattern.name(), grokPattern.pattern());
    final JsonNode data = objectMapper.convertValue(grokPatternEntity, JsonNode.class);
    return EntityV1.builder().id(ModelId.of(entityDescriptorIds.getOrThrow(grokPattern.id(), ModelTypes.GROK_PATTERN_V1))).type(ModelTypes.GROK_PATTERN_V1).data(data).build();
}
Also used : JsonNode(com.fasterxml.jackson.databind.JsonNode) GrokPatternEntity(org.graylog2.contentpacks.model.entities.GrokPatternEntity) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

EntityDescriptorIds (org.graylog2.contentpacks.EntityDescriptorIds)36 Entity (org.graylog2.contentpacks.model.entities.Entity)35 EntityDescriptor (org.graylog2.contentpacks.model.entities.EntityDescriptor)35 EntityV1 (org.graylog2.contentpacks.model.entities.EntityV1)34 Test (org.junit.Test)33 NativeEntity (org.graylog2.contentpacks.model.entities.NativeEntity)32 MongoDBFixtures (org.graylog.testing.mongodb.MongoDBFixtures)23 JsonNode (com.fasterxml.jackson.databind.JsonNode)14 NativeEntityDescriptor (org.graylog2.contentpacks.model.entities.NativeEntityDescriptor)12 VisibleForTesting (com.google.common.annotations.VisibleForTesting)11 ModelId (org.graylog2.contentpacks.model.ModelId)11 LookupTableEntity (org.graylog2.contentpacks.model.entities.LookupTableEntity)8 PipelineEntity (org.graylog2.contentpacks.model.entities.PipelineEntity)8 GrokPatternEntity (org.graylog2.contentpacks.model.entities.GrokPatternEntity)7 LookupCacheEntity (org.graylog2.contentpacks.model.entities.LookupCacheEntity)7 LookupDataAdapterEntity (org.graylog2.contentpacks.model.entities.LookupDataAdapterEntity)7 Constraint (org.graylog2.contentpacks.model.constraints.Constraint)4 PluginVersionConstraint (org.graylog2.contentpacks.model.constraints.PluginVersionConstraint)4 ConverterEntity (org.graylog2.contentpacks.model.entities.ConverterEntity)4 ExtractorEntity (org.graylog2.contentpacks.model.entities.ExtractorEntity)4