Skip to content

Commit 470590b

Browse files
szabostevelcawl
andauthored
Adds index API requests and responses - part 1 (#2979)
Co-authored-by: lcawl <[email protected]>
1 parent 0e35843 commit 470590b

17 files changed

+261
-4
lines changed

docs/overlays/elasticsearch-openapi-overlays.yaml

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,4 +226,41 @@ actions:
226226
application/json:
227227
examples:
228228
removePolicyResponseExample1:
229-
$ref: "../../specification/ilm/remove_policy/RemovePolicyResponseExample1.json"
229+
$ref: "../../specification/ilm/remove_policy/RemovePolicyResponseExample1.json"
230+
- target: "$.components['requestBodies']['indices.clone']"
231+
description: "Add examples for clone index request"
232+
update:
233+
content:
234+
application/json:
235+
examples:
236+
indicesCloneRequestExample1:
237+
$ref: "../../specification/indices/clone/indicesCloneRequestExample1.yaml"
238+
- target: "$.paths['/{index}/_close']['post']"
239+
description: "Add examples for close index response"
240+
update:
241+
responses:
242+
200:
243+
content:
244+
application/json:
245+
examples:
246+
indicesCloseResponseExample1:
247+
$ref: "../../specification/indices/close/indicesCloseResponseExample1.yaml"
248+
- target: "$.components['responses']['indices.data_streams_stats#200']"
249+
description: "Add example for data stream stats response"
250+
update:
251+
content:
252+
application/json:
253+
examples:
254+
indicesDataStreamStatsResponseExample1:
255+
$ref: "../../specification/indices/data_streams_stats/indicesDataStreamStatsResponseExample1.yaml"
256+
- target: "$.paths['/{index}/_open']['post']"
257+
description: "Add examples for open index response"
258+
update:
259+
responses:
260+
200:
261+
content:
262+
application/json:
263+
examples:
264+
indicesOpenResponseExample1:
265+
$ref: "../../specification/indices/open/indicesOpenResponseExample1.yaml"
266+

docs/overlays/elasticsearch-shared-overlays.yaml

Lines changed: 88 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ actions:
302302
content:
303303
application/json:
304304
examples:
305-
asyncSearchSubmitResponseExample1:
305+
asyncSearchSubmitRequestExample1:
306306
$ref: "../../specification/async_search/submit/AsyncSearchSubmitRequestExample1.json"
307307
- target: "$.components['responses']['async_search.submit#200']"
308308
description: "Add example for asynch search submit response"
@@ -338,7 +338,7 @@ actions:
338338
examples:
339339
previewTransformRequestExample1:
340340
$ref: "../../specification/transform/preview_transform/PreviewTransformRequestExample1.json"
341-
- target: "$.components['reponses']['transform.preview_transform#200']"
341+
- target: "$.components['responses']['transform.preview_transform#200']"
342342
description: "Add examples for preview transform operation"
343343
update:
344344
content:
@@ -406,4 +406,89 @@ actions:
406406
application/json:
407407
examples:
408408
graphExploreRequestExample1:
409-
$ref: "../../specification/graph/explore/graphExploreRequestExample1.json"
409+
$ref: "../../specification/graph/explore/graphExploreRequestExample1.json"
410+
- target: "$.paths['/{index}/_block/{block}']['put']"
411+
description: "Add examples for add index block operation"
412+
update:
413+
responses:
414+
200:
415+
content:
416+
application/json:
417+
examples:
418+
indicesAddBlockResponseExample1:
419+
$ref: "../../specification/indices/add_block/IndicesAddBlockResponseExample1.yaml"
420+
- target: "$.components['requestBodies']['indices.analyze']"
421+
description: "Add example for analyze API request"
422+
update:
423+
content:
424+
application/json:
425+
examples:
426+
indicesAnalyzeRequestExample1:
427+
$ref: "../../specification/indices/analyze/indicesAnalyzeRequestExample1.yaml"
428+
- target: "$.paths['/{index}']['put']"
429+
description: "Add examples for create index request"
430+
update:
431+
requestBody:
432+
content:
433+
application/json:
434+
examples:
435+
indicesCreateRequestExample1:
436+
$ref: "../../specification/indices/create/indicesCreateRequestExample1.yaml"
437+
indicesCreateRequestExample2:
438+
$ref: "../../specification/indices/create/indicesCreateRequestExample2.yaml"
439+
- target: "$.paths['/_data_stream/{name}/_lifecycle']['delete']"
440+
description: "Add example for delete data stream lifecycle response"
441+
update:
442+
responses:
443+
200:
444+
content:
445+
application/json:
446+
examples:
447+
indicesDeleteDataLifecycleResponseExample1:
448+
$ref: "../../specification/indices/delete_data_lifecycle/IndicesDeleteDataLifecycleResponseExample1.yaml"
449+
- target: "$.paths['/_data_stream/{name}/_lifecycle']['get']"
450+
description: "Add example for get data stream lifecycle response"
451+
update:
452+
responses:
453+
200:
454+
content:
455+
application/json:
456+
examples:
457+
indicesGetDataLifecycleResponseExample1:
458+
$ref: "../../specification/indices/get_data_lifecycle/IndicesGetDataLifecycleResponseExample1.yaml"
459+
- target: "$.components['responses']['indices.get_data_stream#200']"
460+
description: "Add example for get data stream response"
461+
update:
462+
content:
463+
application/json:
464+
examples:
465+
indicesGetDataStreamResponseExample:
466+
$ref: "../../specification/indices/get_data_stream/indicesGetDataStreamResponseExample1.yaml"
467+
- target: "$.paths['/_data_stream/{name}/_lifecycle']['put']"
468+
description: "Add examples update data stream lifecycle request and response"
469+
update:
470+
requestBody:
471+
content:
472+
application/json:
473+
examples:
474+
indicesPutDataLifecycleRequestExample1:
475+
$ref: "../../specification/indices/put_data_lifecycle/IndicesPutDataLifecycleRequestExample1.yaml"
476+
indicesPutLifecycleRequestExample2:
477+
$ref: "../../specification/indices/put_data_lifecycle/IndicesPutDataLifecycleRequestExample2.yaml"
478+
responses:
479+
200:
480+
content:
481+
application/json:
482+
examples:
483+
indicesPutDataLifecycleResponseExample1:
484+
$ref: "../../specification/indices/put_data_lifecycle/IndicesPutDataLifecycleResponseExample1.yaml"
485+
- target: "$.paths['/{index}/_lifecycle/explain']['get']"
486+
description: "Add example for explain data stream lifecycle response"
487+
update:
488+
responses:
489+
200:
490+
content:
491+
application/json:
492+
examples:
493+
indicesExplainDataLifecycleResponseExample:
494+
$ref: "../../specification/indices/explain_data_lifecycle/IndicesExplainDataLifecycleResponseExample1.yaml"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# summary: ''
2+
description: 'A successful response for adding an index block to an index.'
3+
# type: response
4+
# response_code: 200
5+
value:
6+
"{\n \"acknowledged\" : true,\n \"shards_acknowledged\" : true,\n \"indices\"\
7+
\ : [ {\n \"name\" : \"my-index-000001\",\n \"blocked\" : true\n } ]\n}"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
summary: Perform analysis on a text string and returns the resulting tokens.
2+
method_request: GET /_analyze
3+
# description: ''
4+
# type: request
5+
value: "{\n \"analyzer\" : \"standard\",\n \"text\" : \"Quick Brown Foxes!\"\n}"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
summary: Clone an existing index.
2+
# method_request: POST /my_source_index/_clone/my_target_index
3+
description: >
4+
Clone `my_source_index` into a new index called `my_target_index` with `POST /my_source_index/_clone/my_target_index`. The API accepts `settings` and `aliases` parameters for the target index.
5+
# type: request
6+
value:
7+
"{\n \"settings\": {\n \"index.number_of_shards\": 5\n },\n \"aliases\"\
8+
: {\n \"my_search_indices\": {}\n }\n}"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# summary: ''
2+
description: A successful response for closing an index.
3+
# type: response
4+
# response_code: 200
5+
value:
6+
"{\n \"acknowledged\": true,\n \"shards_acknowledged\": true,\n \"indices\"\
7+
: {\n \"my-index-000001\": {\n \"closed\": true\n }\n }\n}"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
summary: Creates an index.
2+
# method_request: PUT /my-index-000001
3+
description: This request specifies the `number_of_shards` and `number_of_replicas`.
4+
# type: request
5+
value:
6+
"{\n \"settings\": {\n \"number_of_shards\": 3,\n \"number_of_replicas\"\
7+
: 2\n }\n}"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
summary: Creates an index with mapping.
2+
# method_request: PUT /test
3+
description: You can provide mapping definitions in the create index API requests.
4+
# type: request
5+
value:
6+
"{\n \"settings\": {\n \"number_of_shards\": 1\n },\n \"mappings\": {\n\
7+
\ \"properties\": {\n \"field1\": { \"type\": \"text\" }\n }\n }\n}"
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# summary: ''
2+
description: A successful response for retrieving statistics for a data stream.
3+
# type: response
4+
# response_code: 200
5+
value:
6+
"{\n \"_shards\": {\n \"total\": 10,\n \"successful\": 5,\n \"failed\"\
7+
: 0\n },\n \"data_stream_count\": 2,\n \"backing_indices\": 5,\n \"total_store_size\"\
8+
: \"7kb\",\n \"total_store_size_bytes\": 7268,\n \"data_streams\": [\n {\n\
9+
\ \"data_stream\": \"my-data-stream\",\n \"backing_indices\": 3,\n \
10+
\ \"store_size\": \"3.7kb\",\n \"store_size_bytes\": 3772,\n \"maximum_timestamp\"\
11+
: 1607512028000\n },\n {\n \"data_stream\": \"my-data-stream-two\",\n\
12+
\ \"backing_indices\": 2,\n \"store_size\": \"3.4kb\",\n \"store_size_bytes\"\
13+
: 3496,\n \"maximum_timestamp\": 1607425567000\n }\n ]\n}"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# summary: ''
2+
description: A successful response for deleting a data stream lifecycle.
3+
# type: response
4+
# response_code: 200
5+
value: "{\n \"acknowledged\": true\n}"
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# summary: ''
2+
description: A successful response for retrieving data stream lifecycle status for a data stream backing index.
3+
# type: response
4+
# response_code: 200
5+
value:
6+
"{\n \"indices\": {\n \".ds-metrics-2023.03.22-000001\": {\n \"index\"\
7+
\ : \".ds-metrics-2023.03.22-000001\",\n \"managed_by_lifecycle\" : true,\n\
8+
\ \"index_creation_date_millis\" : 1679475563571,\n \"time_since_index_creation\"\
9+
\ : \"843ms\",\n \"rollover_date_millis\" : 1679475564293,\n \"time_since_rollover\"\
10+
\ : \"121ms\",\n \"lifecycle\" : { },\n \"generation_time\" : \"121ms\"\
11+
\n }\n}"
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# summary:
2+
description: A successful response of getting the lifecycle of a set of data streams.
3+
# type: response
4+
# response_code: 200
5+
value:
6+
"{\n \"data_streams\": [\n {\n \"name\": \"my-data-stream-1\",\n \
7+
\ \"lifecycle\": {\n \"enabled\": true,\n \"data_retention\":\
8+
\ \"7d\"\n }\n },\n {\n \"name\": \"my-data-stream-2\",\n \"\
9+
lifecycle\": {\n \"enabled\": true,\n \"data_retention\": \"7d\"\n\
10+
\ }\n }\n ]\n}"
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# summary:
2+
description: A successful response for retrieving information about a data stream.
3+
# type: response
4+
# response_code: 200
5+
value:
6+
"{\n \"data_streams\": [\n {\n \"name\": \"my-data-stream\",\n \
7+
\ \"timestamp_field\": {\n \"name\": \"@timestamp\"\n },\n \"\
8+
indices\": [\n {\n \"index_name\": \".ds-my-data-stream-2099.03.07-000001\"\
9+
,\n \"index_uuid\": \"xCEhwsp8Tey0-FLNFYVwSg\",\n \"prefer_ilm\"\
10+
: true,\n \"ilm_policy\": \"my-lifecycle-policy\",\n \"managed_by\"\
11+
: \"Index Lifecycle Management\"\n },\n {\n \"index_name\"\
12+
: \".ds-my-data-stream-2099.03.08-000002\",\n \"index_uuid\": \"PA_JquKGSiKcAKBA8DJ5gw\"\
13+
,\n \"prefer_ilm\": true,\n \"ilm_policy\": \"my-lifecycle-policy\"\
14+
,\n \"managed_by\": \"Index Lifecycle Management\"\n }\n ],\n\
15+
\ \"generation\": 2,\n \"_meta\": {\n \"my-meta-field\": \"foo\"\
16+
\n },\n \"status\": \"GREEN\",\n \"next_generation_managed_by\":\
17+
\ \"Index Lifecycle Management\",\n \"prefer_ilm\": true,\n \"template\"\
18+
: \"my-index-template\",\n \"ilm_policy\": \"my-lifecycle-policy\",\n \
19+
\ \"hidden\": false,\n \"system\": false,\n \"allow_custom_routing\":\
20+
\ false,\n \"replicated\": false,\n \"rollover_on_write\": false\n \
21+
\ },\n {\n \"name\": \"my-data-stream-two\",\n \"timestamp_field\"\
22+
: {\n \"name\": \"@timestamp\"\n },\n \"indices\": [\n {\n\
23+
\ \"index_name\": \".ds-my-data-stream-two-2099.03.08-000001\",\n \
24+
\ \"index_uuid\": \"3liBu2SYS5axasRt6fUIpA\",\n \"prefer_ilm\": true,\n\
25+
\ \"ilm_policy\": \"my-lifecycle-policy\",\n \"managed_by\": \"\
26+
Index Lifecycle Management\"\n }\n ],\n \"generation\": 1,\n \
27+
\ \"_meta\": {\n \"my-meta-field\": \"foo\"\n },\n \"status\"\
28+
: \"YELLOW\",\n \"next_generation_managed_by\": \"Index Lifecycle Management\"\
29+
,\n \"prefer_ilm\": true,\n \"template\": \"my-index-template\",\n \
30+
\ \"ilm_policy\": \"my-lifecycle-policy\",\n \"hidden\": false,\n \"\
31+
system\": false,\n \"allow_custom_routing\": false,\n \"replicated\":\
32+
\ false,\n \"rollover_on_write\": false\n }\n ]\n}"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# summary:
2+
description: A successful response for opening an index.
3+
# type: response
4+
# response_code: 200
5+
value: "{\n \"acknowledged\" : true,\n \"shards_acknowledged\" : true\n}"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
summary: Set the data stream lifecycle retention
2+
# method_request: PUT _data_stream/my-data-stream/_lifecycle
3+
# description: Sets the lifecycle of a data stream.
4+
# type: request
5+
value: "{\n \"data_retention\": \"7d\"\n}"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
summary: Set the data stream lifecycle downsampling
2+
# method_request: PUT _data_stream/my-weather-sensor-data-stream/_lifecycle
3+
description: This example configures two downsampling rounds.
4+
# type: request
5+
value:
6+
"{\n \"downsampling\": [\n {\n \"after\": \"1d\",\n \"\
7+
fixed_interval\": \"10m\"\n },\n {\n \"after\": \"7d\",\n \
8+
\ \"fixed_interval\": \"1d\"\n }\n ]\n}"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# summary:
2+
description: A successful response for configuring a data stream lifecycle.
3+
# type: response
4+
# response_code: 200
5+
value: "{\n \"acknowledged\": true\n}"

0 commit comments

Comments
 (0)