use of org.opensearch.action.ingest.GetPipelineRequest in project OpenSearch by opensearch-project.
the class IngestRequestConverters method getPipeline.
static Request getPipeline(GetPipelineRequest getPipelineRequest) {
String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_ingest/pipeline").addCommaSeparatedPathParts(getPipelineRequest.getIds()).build();
Request request = new Request(HttpGet.METHOD_NAME, endpoint);
RequestConverters.Params parameters = new RequestConverters.Params();
parameters.withMasterTimeout(getPipelineRequest.masterNodeTimeout());
request.addParameters(parameters.asMap());
return request;
}
use of org.opensearch.action.ingest.GetPipelineRequest in project OpenSearch by opensearch-project.
the class IngestRequestConvertersTests method testGetPipeline.
public void testGetPipeline() {
String pipelineId = "some_pipeline_id";
Map<String, String> expectedParams = new HashMap<>();
GetPipelineRequest request = new GetPipelineRequest("some_pipeline_id");
RequestConvertersTests.setRandomMasterTimeout(request, expectedParams);
Request expectedRequest = IngestRequestConverters.getPipeline(request);
StringJoiner endpoint = new StringJoiner("/", "/", "");
endpoint.add("_ingest/pipeline");
endpoint.add(pipelineId);
Assert.assertEquals(endpoint.toString(), expectedRequest.getEndpoint());
Assert.assertEquals(HttpGet.METHOD_NAME, expectedRequest.getMethod());
Assert.assertEquals(expectedParams, expectedRequest.getParameters());
}
use of org.opensearch.action.ingest.GetPipelineRequest in project OpenSearch by opensearch-project.
the class IngestClientIT method testGetNonexistentPipeline.
public void testGetNonexistentPipeline() throws IOException {
String id = "nonexistent_pipeline_id";
GetPipelineRequest request = new GetPipelineRequest(id);
GetPipelineResponse response = execute(request, highLevelClient().ingest()::getPipeline, highLevelClient().ingest()::getPipelineAsync);
assertFalse(response.isFound());
}
use of org.opensearch.action.ingest.GetPipelineRequest in project OpenSearch by opensearch-project.
the class IngestClientIT method test.
public void test() throws Exception {
BytesReference source = BytesReference.bytes(jsonBuilder().startObject().field("description", "my_pipeline").startArray("processors").startObject().startObject("test").endObject().endObject().endArray().endObject());
PutPipelineRequest putPipelineRequest = new PutPipelineRequest("_id", source, XContentType.JSON);
client().admin().cluster().putPipeline(putPipelineRequest).get();
GetPipelineRequest getPipelineRequest = new GetPipelineRequest("_id");
GetPipelineResponse getResponse = client().admin().cluster().getPipeline(getPipelineRequest).get();
assertThat(getResponse.isFound(), is(true));
assertThat(getResponse.pipelines().size(), equalTo(1));
assertThat(getResponse.pipelines().get(0).getId(), equalTo("_id"));
client().prepareIndex("test").setId("1").setPipeline("_id").setSource("field", "value", "fail", false).get();
Map<String, Object> doc = client().prepareGet("test", "1").get().getSourceAsMap();
assertThat(doc.get("field"), equalTo("value"));
assertThat(doc.get("processed"), equalTo(true));
client().prepareBulk().add(client().prepareIndex("test").setId("2").setSource("field", "value2", "fail", false).setPipeline("_id")).get();
doc = client().prepareGet("test", "2").get().getSourceAsMap();
assertThat(doc.get("field"), equalTo("value2"));
assertThat(doc.get("processed"), equalTo(true));
DeletePipelineRequest deletePipelineRequest = new DeletePipelineRequest("_id");
AcknowledgedResponse response = client().admin().cluster().deletePipeline(deletePipelineRequest).get();
assertThat(response.isAcknowledged(), is(true));
getResponse = client().admin().cluster().prepareGetPipeline("_id").get();
assertThat(getResponse.isFound(), is(false));
assertThat(getResponse.pipelines().size(), equalTo(0));
}
use of org.opensearch.action.ingest.GetPipelineRequest in project OpenSearch by opensearch-project.
the class IngestClientIT method testGetPipeline.
public void testGetPipeline() throws IOException {
String id = "some_pipeline_id";
XContentBuilder pipelineBuilder = buildRandomXContentPipeline();
{
PutPipelineRequest request = new PutPipelineRequest(id, BytesReference.bytes(pipelineBuilder), pipelineBuilder.contentType());
createPipeline(request);
}
GetPipelineRequest request = new GetPipelineRequest(id);
GetPipelineResponse response = execute(request, highLevelClient().ingest()::getPipeline, highLevelClient().ingest()::getPipelineAsync);
assertTrue(response.isFound());
assertEquals(response.pipelines().get(0).getId(), id);
PipelineConfiguration expectedConfig = new PipelineConfiguration(id, BytesReference.bytes(pipelineBuilder), pipelineBuilder.contentType());
assertEquals(expectedConfig.getConfigAsMap(), response.pipelines().get(0).getConfigAsMap());
}
Aggregations