ingest: Made the response format of the get pipeline api match with the response format of the index template api

Closes #19585
This commit is contained in:
Martijn van Groningen 2016-07-29 15:41:43 +02:00
parent 30b497622b
commit a91bb29585
5 changed files with 45 additions and 36 deletions

View File

@ -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;
}
}

View File

@ -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

View File

@ -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:

View File

@ -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:

View File

@ -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" : {}
}