use of org.graylog.plugins.pipelineprocessor.db.PipelineDao in project graylog2-server by Graylog2.
the class PipelineFacadeTest method createNativeEntity.
@Test
public void createNativeEntity() throws NotFoundException {
final Entity entity = EntityV1.builder().id(ModelId.of("1")).type(ModelTypes.PIPELINE_V1).data(objectMapper.convertValue(PipelineEntity.create(ValueReference.of("Title"), ValueReference.of("Description"), ValueReference.of("pipeline \"Title\"\nstage 0 match either\nrule \"debug\"\nrule \"no-op\"\nend"), Collections.singleton(ValueReference.of("5adf23894b900a0f00000001"))), JsonNode.class)).build();
final EntityDescriptor streamDescriptor = EntityDescriptor.create("5adf23894b900a0f00000001", ModelTypes.STREAM_V1);
final Stream stream = mock(Stream.class);
when(stream.getId()).thenReturn("5adf23894b900a0f00000001");
final Map<EntityDescriptor, Object> nativeEntities = Collections.singletonMap(streamDescriptor, stream);
final NativeEntity<PipelineDao> nativeEntity = facade.createNativeEntity(entity, Collections.emptyMap(), nativeEntities, "username");
assertThat(nativeEntity.descriptor().type()).isEqualTo(ModelTypes.PIPELINE_V1);
assertThat(nativeEntity.entity().title()).isEqualTo("Title");
assertThat(nativeEntity.entity().description()).isEqualTo("Description");
assertThat(nativeEntity.entity().source()).startsWith("pipeline \"Title\"");
assertThat(connectionsService.load("5adf23894b900a0f00000001").pipelineIds()).containsOnly(nativeEntity.entity().id());
}
use of org.graylog.plugins.pipelineprocessor.db.PipelineDao in project graylog2-server by Graylog2.
the class PipelineFacadeTest method createNativeEntityWithDefaultStream.
@Test
public void createNativeEntityWithDefaultStream() throws NotFoundException {
final Entity entity = EntityV1.builder().id(ModelId.of("1")).type(ModelTypes.PIPELINE_V1).data(objectMapper.convertValue(PipelineEntity.create(ValueReference.of("Title"), ValueReference.of("Description"), ValueReference.of("pipeline \"Title\"\nstage 0 match either\nrule \"debug\"\nrule \"no-op\"\nend"), Collections.singleton(ValueReference.of(Stream.DEFAULT_STREAM_ID))), JsonNode.class)).build();
final FakeStream fakeDefaultStream = new FakeStream("All message Fake") {
@Override
protected ObjectId getObjectId() {
return new ObjectId(Stream.DEFAULT_STREAM_ID);
}
};
when(streamService.load(Stream.DEFAULT_STREAM_ID)).thenReturn(fakeDefaultStream);
final Map<EntityDescriptor, Object> nativeEntities = Collections.emptyMap();
final NativeEntity<PipelineDao> nativeEntity = facade.createNativeEntity(entity, Collections.emptyMap(), nativeEntities, "username");
assertThat(connectionsService.load(fakeDefaultStream.getId()).pipelineIds()).containsOnly(nativeEntity.entity().id());
}
use of org.graylog.plugins.pipelineprocessor.db.PipelineDao in project graylog2-server by Graylog2.
the class MongoDbPipelineService method loadByName.
@Override
public PipelineDao loadByName(String name) throws NotFoundException {
final DBQuery.Query query = DBQuery.is("title", name);
final PipelineDao pipeline = dbCollection.findOne(query);
if (pipeline == null) {
throw new NotFoundException("No pipeline with name " + name);
}
return pipeline;
}
use of org.graylog.plugins.pipelineprocessor.db.PipelineDao in project graylog2-server by Graylog2.
the class MongoDbPipelineService method save.
@Override
public PipelineDao save(PipelineDao pipeline) {
final WriteResult<PipelineDao, String> save = dbCollection.save(pipeline);
final PipelineDao savedPipeline = save.getSavedObject();
clusterBus.post(PipelinesChangedEvent.updatedPipelineId(savedPipeline.id()));
return savedPipeline;
}
use of org.graylog.plugins.pipelineprocessor.db.PipelineDao in project graylog2-server by Graylog2.
the class PipelineResource method getAll.
@ApiOperation(value = "Get all processing pipelines")
@GET
public Collection<PipelineSource> getAll() {
final Collection<PipelineDao> daos = pipelineService.loadAll();
final ArrayList<PipelineSource> results = Lists.newArrayList();
for (PipelineDao dao : daos) {
if (isPermitted(PipelineRestPermissions.PIPELINE_READ, dao.id())) {
results.add(PipelineSource.fromDao(pipelineRuleParser, dao));
}
}
return results;
}
Aggregations