From a91bb2958591a44efe9cbb7577184dcbe88f82aa Mon Sep 17 00:00:00 2001 From: Martijn van Groningen Date: Fri, 29 Jul 2016 15:41:43 +0200 Subject: [PATCH] ingest: Made the response format of the get pipeline api match with the response format of the index template api Closes #19585 --- .../action/ingest/GetPipelineResponse.java | 4 +-- docs/reference/ingest/ingest-node.asciidoc | 23 ++++++------ .../rest-api-spec/test/ingest/20_crud.yaml | 16 ++++----- .../ingest_mustache/10_ingest_disabled.yaml | 3 +- .../rest-api-spec/test/ingest/10_basic.yaml | 35 ++++++++++++++----- 5 files changed, 45 insertions(+), 36 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/action/ingest/GetPipelineResponse.java b/core/src/main/java/org/elasticsearch/action/ingest/GetPipelineResponse.java index 9f0b229d322..f603a354f4b 100644 --- a/core/src/main/java/org/elasticsearch/action/ingest/GetPipelineResponse.java +++ b/core/src/main/java/org/elasticsearch/action/ingest/GetPipelineResponse.java @@ -76,11 +76,9 @@ public class GetPipelineResponse extends ActionResponse implements StatusToXCont @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { - builder.startArray("pipelines"); for (PipelineConfiguration pipeline : pipelines) { - pipeline.toXContent(builder, params); + builder.field(pipeline.getId(), pipeline.getConfigAsMap()); } - builder.endArray(); return builder; } } diff --git a/docs/reference/ingest/ingest-node.asciidoc b/docs/reference/ingest/ingest-node.asciidoc index 25c42f17870..efb108573dd 100644 --- a/docs/reference/ingest/ingest-node.asciidoc +++ b/docs/reference/ingest/ingest-node.asciidoc @@ -71,20 +71,17 @@ Example response: [source,js] -------------------------------------------------- { - "pipelines": [ { - "id": "my-pipeline-id", - "config": { - "description": "describe pipeline", - "processors": [ - { - "set" : { - "field": "foo", - "value": "bar" - } + "my-pipeline-id" : { + "description" : "describe pipeline", + "processors" : [ + { + "set" : { + "field" : "foo", + "value" : "bar" } - ] - } - } ] + } + ] + } } -------------------------------------------------- // TESTRESPONSE diff --git a/modules/ingest-common/src/test/resources/rest-api-spec/test/ingest/20_crud.yaml b/modules/ingest-common/src/test/resources/rest-api-spec/test/ingest/20_crud.yaml index 2fb6ac230ff..b12a65f8fb6 100644 --- a/modules/ingest-common/src/test/resources/rest-api-spec/test/ingest/20_crud.yaml +++ b/modules/ingest-common/src/test/resources/rest-api-spec/test/ingest/20_crud.yaml @@ -35,13 +35,11 @@ teardown: - do: ingest.get_pipeline: id: "my_pipeline" - - match: { pipelines.0.id: "my_pipeline" } - - match: { pipelines.0.config.description: "_description" } + - match: { my_pipeline.description: "_description" } - do: ingest.get_pipeline: {} - - match: { pipelines.0.id: "my_pipeline" } - - match: { pipelines.0.config.description: "_description" } + - match: { my_pipeline.description: "_description" } - do: ingest.delete_pipeline: @@ -54,7 +52,7 @@ teardown: id: "my_pipeline" --- -"Test Get All Pipelines (unordered)": +"Test Get All Pipelines": - do: ingest.put_pipeline: id: "first_pipeline" @@ -79,11 +77,10 @@ teardown: "processors": [] } - # Order is not guaranteed by the response, so we check for length instead; above tests that we get appropriate values - do: ingest.get_pipeline: {} - - length: { pipelines: 2 } - + - match: { first_pipeline.description: "first" } + - match: { second_pipeline.description: "second" } --- "Test invalid config": @@ -155,8 +152,7 @@ teardown: - do: ingest.get_pipeline: id: "my_pipeline" - - match: { pipelines.0.id: "my_pipeline" } - - match: { pipelines.0.config.description: "_description" } + - match: { my_pipeline.description: "_description" } - do: ingest.delete_pipeline: diff --git a/qa/smoke-test-ingest-disabled/src/test/resources/rest-api-spec/test/ingest_mustache/10_ingest_disabled.yaml b/qa/smoke-test-ingest-disabled/src/test/resources/rest-api-spec/test/ingest_mustache/10_ingest_disabled.yaml index 01d674053ae..5a3f64151f4 100644 --- a/qa/smoke-test-ingest-disabled/src/test/resources/rest-api-spec/test/ingest_mustache/10_ingest_disabled.yaml +++ b/qa/smoke-test-ingest-disabled/src/test/resources/rest-api-spec/test/ingest_mustache/10_ingest_disabled.yaml @@ -20,8 +20,7 @@ - do: ingest.get_pipeline: id: "my_pipeline" - - match: { pipelines.0.id: "my_pipeline" } - - match: { pipelines.0.config.description: "_description" } + - match: { my_pipeline.description: "_description" } - do: ingest.delete_pipeline: diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/ingest/10_basic.yaml b/rest-api-spec/src/main/resources/rest-api-spec/test/ingest/10_basic.yaml index 74396249e81..6e822bf1da0 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/ingest/10_basic.yaml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/ingest/10_basic.yaml @@ -14,8 +14,7 @@ - do: ingest.get_pipeline: id: "my_pipeline" - - match: { pipelines.0.id: "my_pipeline" } - - match: { pipelines.0.config.description: "_description" } + - match: { my_pipeline.description: "_description" } - do: ingest.delete_pipeline: @@ -27,6 +26,30 @@ ingest.get_pipeline: id: "my_pipeline" +--- +"Test Get All Pipelines": + - do: + ingest.put_pipeline: + id: "first_pipeline" + body: > + { + "description": "first", + "processors": [] + } + - do: + ingest.put_pipeline: + id: "second_pipeline" + body: > + { + "description": "second", + "processors": [] + } + + - do: + ingest.get_pipeline: {} + - match: { first_pipeline.description: "first" } + - match: { second_pipeline.description: "second" } + --- "Test invalid config": - do: @@ -36,10 +59,6 @@ body: > { "description": "_description", - "processors": [ - { - "set" : { - } - } - ] + "processors": [], + "invalid_field" : {} }