From de6ddfa35403b36bbe42bb837250d385c439e9d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Istv=C3=A1n=20Zolt=C3=A1n=20Szab=C3=B3?= Date: Tue, 10 Dec 2024 09:51:58 +0100 Subject: [PATCH] Adds ingest API request and response examples (#2996) Co-authored-by: Lisa Cawley (cherry picked from commit 204550525b924151f35a3aac1d6e9f070f3ade9f) --- .../elasticsearch-shared-overlays.yaml | 38 ++++++++++++++++++- .../GetPipelineResponseExample1.yaml | 9 +++++ .../PutPipelineRequestExample1.yaml | 9 +++++ .../PutPipelineRequestExample2.yaml | 11 ++++++ .../SimulatePipelineRequestExample1.yaml | 12 ++++++ .../SimulatePipelineResponseExample1.yaml | 15 ++++++++ 6 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 specification/ingest/get_pipeline/GetPipelineResponseExample1.yaml create mode 100644 specification/ingest/put_pipeline/PutPipelineRequestExample1.yaml create mode 100644 specification/ingest/put_pipeline/PutPipelineRequestExample2.yaml create mode 100644 specification/ingest/simulate/SimulatePipelineRequestExample1.yaml create mode 100644 specification/ingest/simulate/SimulatePipelineResponseExample1.yaml diff --git a/docs/overlays/elasticsearch-shared-overlays.yaml b/docs/overlays/elasticsearch-shared-overlays.yaml index e060806adf..e5b7368da4 100644 --- a/docs/overlays/elasticsearch-shared-overlays.yaml +++ b/docs/overlays/elasticsearch-shared-overlays.yaml @@ -1257,4 +1257,40 @@ actions: application/json: examples: indicesExplainDataLifecycleResponseExample: - $ref: "../../specification/indices/explain_data_lifecycle/IndicesExplainDataLifecycleResponseExample1.yaml" \ No newline at end of file + $ref: "../../specification/indices/explain_data_lifecycle/IndicesExplainDataLifecycleResponseExample1.yaml" + - target: "$.components['responses']['ingest.get_pipeline#200']" + description: "Add example for get pipeline response" + update: + content: + application/json: + examples: + indicesGetDataStreamResponseExample: + $ref: "../../specification/ingest/get_pipeline/GetPipelineResponseExample1.yaml" + - target: "$.paths['/_ingest/pipeline/{id}']['put']" + description: "Add examples for create pipeline" + update: + requestBody: + content: + application/json: + examples: + putPipelineRequestExample1: + $ref: "../../specification/ingest/put_pipeline/PutPipelineRequestExample1.yaml" + putPipelineRequestExample2: + $ref: "../../specification/ingest/put_pipeline/PutPipelineRequestExample2.yaml" + - target: "$.components['requestBodies']['ingest.simulate']" + description: "Add example for simulate pipeline request" + update: + content: + application/json: + examples: + simulatePipelineRequestExample1: + $ref: "../../specification/ingest/simulate/SimulatePipelineRequestExample1.yaml" + - target: "$.components['responses']['ingest.simulate#200']" + description: "Add example for simulate pipeline response" + update: + content: + application/json: + examples: + simulatePipelineResponseExample1: + $ref: "../../specification/ingest/simulate/SimulatePipelineResponseExample1.yaml" + \ No newline at end of file diff --git a/specification/ingest/get_pipeline/GetPipelineResponseExample1.yaml b/specification/ingest/get_pipeline/GetPipelineResponseExample1.yaml new file mode 100644 index 0000000000..36dad4236d --- /dev/null +++ b/specification/ingest/get_pipeline/GetPipelineResponseExample1.yaml @@ -0,0 +1,9 @@ +summary: A successful response for retrieving information about an ingest pipeline. +# description: '' +# type: response +# response_code: 200 +value: + "{\n \"my-pipeline-id\" : {\n \"description\" : \"describe pipeline\",\n\ + \ \"version\" : 123,\n \"processors\" : [\n {\n \"set\" : {\n\ + \ \"field\" : \"foo\",\n \"value\" : \"bar\"\n }\n \ + \ }\n ]\n }\n}" diff --git a/specification/ingest/put_pipeline/PutPipelineRequestExample1.yaml b/specification/ingest/put_pipeline/PutPipelineRequestExample1.yaml new file mode 100644 index 0000000000..3a3870ce01 --- /dev/null +++ b/specification/ingest/put_pipeline/PutPipelineRequestExample1.yaml @@ -0,0 +1,9 @@ +summary: Create an ingest pipeline. +# method_request: PUT _ingest/pipeline/my-pipeline-id +# description: '' +# type: request +value: + "{\n \"description\" : \"My optional pipeline description\",\n \"processors\"\ + \ : [\n {\n \"set\" : {\n \"description\" : \"My optional processor\ + \ description\",\n \"field\": \"my-keyword-field\",\n \"value\": \"\ + foo\"\n }\n }\n ]\n}" diff --git a/specification/ingest/put_pipeline/PutPipelineRequestExample2.yaml b/specification/ingest/put_pipeline/PutPipelineRequestExample2.yaml new file mode 100644 index 0000000000..a36e912842 --- /dev/null +++ b/specification/ingest/put_pipeline/PutPipelineRequestExample2.yaml @@ -0,0 +1,11 @@ +summary: Create an ingest pipeline with metadata. +# method_request: PUT /_ingest/pipeline/my-pipeline-id +description: You can use the `_meta` parameter to add arbitrary metadata to a pipeline. +type: request +value: + "{\n \"description\" : \"My optional pipeline description\",\n \"processors\"\ + \ : [\n {\n \"set\" : {\n \"description\" : \"My optional processor\ + \ description\",\n \"field\": \"my-keyword-field\",\n \"value\": \"\ + foo\"\n }\n }\n ],\n \"_meta\": {\n \"reason\": \"set my-keyword-field\ + \ to foo\",\n \"serialization\": {\n \"class\": \"MyPipeline\",\n \"\ + id\": 10\n }\n }\n}" diff --git a/specification/ingest/simulate/SimulatePipelineRequestExample1.yaml b/specification/ingest/simulate/SimulatePipelineRequestExample1.yaml new file mode 100644 index 0000000000..40d368cd69 --- /dev/null +++ b/specification/ingest/simulate/SimulatePipelineRequestExample1.yaml @@ -0,0 +1,12 @@ +summary: Run an ingest pipeline against a set of provided documents. +# method_request: POST /_ingest/pipeline/_simulate +description: You can specify the used pipeline either in the request body or as a path parameter. +# type: request +value: + "{\n \"pipeline\" :\n {\n \"description\": \"_description\",\n \"processors\"\ + : [\n {\n \"set\" : {\n \"field\" : \"field2\",\n \ + \ \"value\" : \"_value\"\n }\n }\n ]\n },\n \"docs\": [\n {\n\ + \ \"_index\": \"index\",\n \"_id\": \"id\",\n \"_source\": {\n \ + \ \"foo\": \"bar\"\n }\n },\n {\n \"_index\": \"index\",\n\ + \ \"_id\": \"id\",\n \"_source\": {\n \"foo\": \"rab\"\n }\n\ + \ }\n ]\n}" diff --git a/specification/ingest/simulate/SimulatePipelineResponseExample1.yaml b/specification/ingest/simulate/SimulatePipelineResponseExample1.yaml new file mode 100644 index 0000000000..5a8077a5bd --- /dev/null +++ b/specification/ingest/simulate/SimulatePipelineResponseExample1.yaml @@ -0,0 +1,15 @@ +summary: A successful response for running an ingest pipeline against a set of provided documents. +# description: '' +# type: response +# response_code: 200 +value: + "{\n \"docs\": [\n {\n \"doc\": {\n \"_id\": \"id\"\ + ,\n \"_index\": \"index\",\n \"_version\": \"-3\",\n \ + \ \"_source\": {\n \"field2\": \"_value\",\n \"\ + foo\": \"bar\"\n },\n \"_ingest\": {\n \"timestamp\"\ + : \"2017-05-04T22:30:03.187Z\"\n }\n }\n },\n {\n \ + \ \"doc\": {\n \"_id\": \"id\",\n \"_index\": \"index\"\ + ,\n \"_version\": \"-3\",\n \"_source\": {\n \ + \ \"field2\": \"_value\",\n \"foo\": \"rab\"\n },\n \ + \ \"_ingest\": {\n \"timestamp\": \"2017-05-04T22:30:03.188Z\"\ + \n }\n }\n }\n ]\n}"