Skip to content

Commit

Permalink
Adds index API requests and responses - part 1 (#2979)
Browse files Browse the repository at this point in the history
Co-authored-by: lcawl <[email protected]>
  • Loading branch information
szabosteve and lcawl authored Oct 7, 2024
1 parent 0e35843 commit 470590b
Show file tree
Hide file tree
Showing 17 changed files with 261 additions and 4 deletions.
39 changes: 38 additions & 1 deletion docs/overlays/elasticsearch-openapi-overlays.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -226,4 +226,41 @@ actions:
application/json:
examples:
removePolicyResponseExample1:
$ref: "../../specification/ilm/remove_policy/RemovePolicyResponseExample1.json"
$ref: "../../specification/ilm/remove_policy/RemovePolicyResponseExample1.json"
- target: "$.components['requestBodies']['indices.clone']"
description: "Add examples for clone index request"
update:
content:
application/json:
examples:
indicesCloneRequestExample1:
$ref: "../../specification/indices/clone/indicesCloneRequestExample1.yaml"
- target: "$.paths['/{index}/_close']['post']"
description: "Add examples for close index response"
update:
responses:
200:
content:
application/json:
examples:
indicesCloseResponseExample1:
$ref: "../../specification/indices/close/indicesCloseResponseExample1.yaml"
- target: "$.components['responses']['indices.data_streams_stats#200']"
description: "Add example for data stream stats response"
update:
content:
application/json:
examples:
indicesDataStreamStatsResponseExample1:
$ref: "../../specification/indices/data_streams_stats/indicesDataStreamStatsResponseExample1.yaml"
- target: "$.paths['/{index}/_open']['post']"
description: "Add examples for open index response"
update:
responses:
200:
content:
application/json:
examples:
indicesOpenResponseExample1:
$ref: "../../specification/indices/open/indicesOpenResponseExample1.yaml"

91 changes: 88 additions & 3 deletions docs/overlays/elasticsearch-shared-overlays.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ actions:
content:
application/json:
examples:
asyncSearchSubmitResponseExample1:
asyncSearchSubmitRequestExample1:
$ref: "../../specification/async_search/submit/AsyncSearchSubmitRequestExample1.json"
- target: "$.components['responses']['async_search.submit#200']"
description: "Add example for asynch search submit response"
Expand Down Expand Up @@ -338,7 +338,7 @@ actions:
examples:
previewTransformRequestExample1:
$ref: "../../specification/transform/preview_transform/PreviewTransformRequestExample1.json"
- target: "$.components['reponses']['transform.preview_transform#200']"
- target: "$.components['responses']['transform.preview_transform#200']"
description: "Add examples for preview transform operation"
update:
content:
Expand Down Expand Up @@ -406,4 +406,89 @@ actions:
application/json:
examples:
graphExploreRequestExample1:
$ref: "../../specification/graph/explore/graphExploreRequestExample1.json"
$ref: "../../specification/graph/explore/graphExploreRequestExample1.json"
- target: "$.paths['/{index}/_block/{block}']['put']"
description: "Add examples for add index block operation"
update:
responses:
200:
content:
application/json:
examples:
indicesAddBlockResponseExample1:
$ref: "../../specification/indices/add_block/IndicesAddBlockResponseExample1.yaml"
- target: "$.components['requestBodies']['indices.analyze']"
description: "Add example for analyze API request"
update:
content:
application/json:
examples:
indicesAnalyzeRequestExample1:
$ref: "../../specification/indices/analyze/indicesAnalyzeRequestExample1.yaml"
- target: "$.paths['/{index}']['put']"
description: "Add examples for create index request"
update:
requestBody:
content:
application/json:
examples:
indicesCreateRequestExample1:
$ref: "../../specification/indices/create/indicesCreateRequestExample1.yaml"
indicesCreateRequestExample2:
$ref: "../../specification/indices/create/indicesCreateRequestExample2.yaml"
- target: "$.paths['/_data_stream/{name}/_lifecycle']['delete']"
description: "Add example for delete data stream lifecycle response"
update:
responses:
200:
content:
application/json:
examples:
indicesDeleteDataLifecycleResponseExample1:
$ref: "../../specification/indices/delete_data_lifecycle/IndicesDeleteDataLifecycleResponseExample1.yaml"
- target: "$.paths['/_data_stream/{name}/_lifecycle']['get']"
description: "Add example for get data stream lifecycle response"
update:
responses:
200:
content:
application/json:
examples:
indicesGetDataLifecycleResponseExample1:
$ref: "../../specification/indices/get_data_lifecycle/IndicesGetDataLifecycleResponseExample1.yaml"
- target: "$.components['responses']['indices.get_data_stream#200']"
description: "Add example for get data stream response"
update:
content:
application/json:
examples:
indicesGetDataStreamResponseExample:
$ref: "../../specification/indices/get_data_stream/indicesGetDataStreamResponseExample1.yaml"
- target: "$.paths['/_data_stream/{name}/_lifecycle']['put']"
description: "Add examples update data stream lifecycle request and response"
update:
requestBody:
content:
application/json:
examples:
indicesPutDataLifecycleRequestExample1:
$ref: "../../specification/indices/put_data_lifecycle/IndicesPutDataLifecycleRequestExample1.yaml"
indicesPutLifecycleRequestExample2:
$ref: "../../specification/indices/put_data_lifecycle/IndicesPutDataLifecycleRequestExample2.yaml"
responses:
200:
content:
application/json:
examples:
indicesPutDataLifecycleResponseExample1:
$ref: "../../specification/indices/put_data_lifecycle/IndicesPutDataLifecycleResponseExample1.yaml"
- target: "$.paths['/{index}/_lifecycle/explain']['get']"
description: "Add example for explain data stream lifecycle response"
update:
responses:
200:
content:
application/json:
examples:
indicesExplainDataLifecycleResponseExample:
$ref: "../../specification/indices/explain_data_lifecycle/IndicesExplainDataLifecycleResponseExample1.yaml"
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# summary: ''
description: 'A successful response for adding an index block to an index.'
# type: response
# response_code: 200
value:
"{\n \"acknowledged\" : true,\n \"shards_acknowledged\" : true,\n \"indices\"\
\ : [ {\n \"name\" : \"my-index-000001\",\n \"blocked\" : true\n } ]\n}"
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
summary: Perform analysis on a text string and returns the resulting tokens.
method_request: GET /_analyze
# description: ''
# type: request
value: "{\n \"analyzer\" : \"standard\",\n \"text\" : \"Quick Brown Foxes!\"\n}"
8 changes: 8 additions & 0 deletions specification/indices/clone/indicesCloneRequestExample1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
summary: Clone an existing index.
# method_request: POST /my_source_index/_clone/my_target_index
description: >
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.
# type: request
value:
"{\n \"settings\": {\n \"index.number_of_shards\": 5\n },\n \"aliases\"\
: {\n \"my_search_indices\": {}\n }\n}"
7 changes: 7 additions & 0 deletions specification/indices/close/indicesCloseResponseExample1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# summary: ''
description: A successful response for closing an index.
# type: response
# response_code: 200
value:
"{\n \"acknowledged\": true,\n \"shards_acknowledged\": true,\n \"indices\"\
: {\n \"my-index-000001\": {\n \"closed\": true\n }\n }\n}"
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
summary: Creates an index.
# method_request: PUT /my-index-000001
description: This request specifies the `number_of_shards` and `number_of_replicas`.
# type: request
value:
"{\n \"settings\": {\n \"number_of_shards\": 3,\n \"number_of_replicas\"\
: 2\n }\n}"
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
summary: Creates an index with mapping.
# method_request: PUT /test
description: You can provide mapping definitions in the create index API requests.
# type: request
value:
"{\n \"settings\": {\n \"number_of_shards\": 1\n },\n \"mappings\": {\n\
\ \"properties\": {\n \"field1\": { \"type\": \"text\" }\n }\n }\n}"
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# summary: ''
description: A successful response for retrieving statistics for a data stream.
# type: response
# response_code: 200
value:
"{\n \"_shards\": {\n \"total\": 10,\n \"successful\": 5,\n \"failed\"\
: 0\n },\n \"data_stream_count\": 2,\n \"backing_indices\": 5,\n \"total_store_size\"\
: \"7kb\",\n \"total_store_size_bytes\": 7268,\n \"data_streams\": [\n {\n\
\ \"data_stream\": \"my-data-stream\",\n \"backing_indices\": 3,\n \
\ \"store_size\": \"3.7kb\",\n \"store_size_bytes\": 3772,\n \"maximum_timestamp\"\
: 1607512028000\n },\n {\n \"data_stream\": \"my-data-stream-two\",\n\
\ \"backing_indices\": 2,\n \"store_size\": \"3.4kb\",\n \"store_size_bytes\"\
: 3496,\n \"maximum_timestamp\": 1607425567000\n }\n ]\n}"
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# summary: ''
description: A successful response for deleting a data stream lifecycle.
# type: response
# response_code: 200
value: "{\n \"acknowledged\": true\n}"
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# summary: ''
description: A successful response for retrieving data stream lifecycle status for a data stream backing index.
# type: response
# response_code: 200
value:
"{\n \"indices\": {\n \".ds-metrics-2023.03.22-000001\": {\n \"index\"\
\ : \".ds-metrics-2023.03.22-000001\",\n \"managed_by_lifecycle\" : true,\n\
\ \"index_creation_date_millis\" : 1679475563571,\n \"time_since_index_creation\"\
\ : \"843ms\",\n \"rollover_date_millis\" : 1679475564293,\n \"time_since_rollover\"\
\ : \"121ms\",\n \"lifecycle\" : { },\n \"generation_time\" : \"121ms\"\
\n }\n}"
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# summary:
description: A successful response of getting the lifecycle of a set of data streams.
# type: response
# response_code: 200
value:
"{\n \"data_streams\": [\n {\n \"name\": \"my-data-stream-1\",\n \
\ \"lifecycle\": {\n \"enabled\": true,\n \"data_retention\":\
\ \"7d\"\n }\n },\n {\n \"name\": \"my-data-stream-2\",\n \"\
lifecycle\": {\n \"enabled\": true,\n \"data_retention\": \"7d\"\n\
\ }\n }\n ]\n}"
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# summary:
description: A successful response for retrieving information about a data stream.
# type: response
# response_code: 200
value:
"{\n \"data_streams\": [\n {\n \"name\": \"my-data-stream\",\n \
\ \"timestamp_field\": {\n \"name\": \"@timestamp\"\n },\n \"\
indices\": [\n {\n \"index_name\": \".ds-my-data-stream-2099.03.07-000001\"\
,\n \"index_uuid\": \"xCEhwsp8Tey0-FLNFYVwSg\",\n \"prefer_ilm\"\
: true,\n \"ilm_policy\": \"my-lifecycle-policy\",\n \"managed_by\"\
: \"Index Lifecycle Management\"\n },\n {\n \"index_name\"\
: \".ds-my-data-stream-2099.03.08-000002\",\n \"index_uuid\": \"PA_JquKGSiKcAKBA8DJ5gw\"\
,\n \"prefer_ilm\": true,\n \"ilm_policy\": \"my-lifecycle-policy\"\
,\n \"managed_by\": \"Index Lifecycle Management\"\n }\n ],\n\
\ \"generation\": 2,\n \"_meta\": {\n \"my-meta-field\": \"foo\"\
\n },\n \"status\": \"GREEN\",\n \"next_generation_managed_by\":\
\ \"Index Lifecycle Management\",\n \"prefer_ilm\": true,\n \"template\"\
: \"my-index-template\",\n \"ilm_policy\": \"my-lifecycle-policy\",\n \
\ \"hidden\": false,\n \"system\": false,\n \"allow_custom_routing\":\
\ false,\n \"replicated\": false,\n \"rollover_on_write\": false\n \
\ },\n {\n \"name\": \"my-data-stream-two\",\n \"timestamp_field\"\
: {\n \"name\": \"@timestamp\"\n },\n \"indices\": [\n {\n\
\ \"index_name\": \".ds-my-data-stream-two-2099.03.08-000001\",\n \
\ \"index_uuid\": \"3liBu2SYS5axasRt6fUIpA\",\n \"prefer_ilm\": true,\n\
\ \"ilm_policy\": \"my-lifecycle-policy\",\n \"managed_by\": \"\
Index Lifecycle Management\"\n }\n ],\n \"generation\": 1,\n \
\ \"_meta\": {\n \"my-meta-field\": \"foo\"\n },\n \"status\"\
: \"YELLOW\",\n \"next_generation_managed_by\": \"Index Lifecycle Management\"\
,\n \"prefer_ilm\": true,\n \"template\": \"my-index-template\",\n \
\ \"ilm_policy\": \"my-lifecycle-policy\",\n \"hidden\": false,\n \"\
system\": false,\n \"allow_custom_routing\": false,\n \"replicated\":\
\ false,\n \"rollover_on_write\": false\n }\n ]\n}"
5 changes: 5 additions & 0 deletions specification/indices/open/indicesOpenResponseExample1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# summary:
description: A successful response for opening an index.
# type: response
# response_code: 200
value: "{\n \"acknowledged\" : true,\n \"shards_acknowledged\" : true\n}"
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
summary: Set the data stream lifecycle retention
# method_request: PUT _data_stream/my-data-stream/_lifecycle
# description: Sets the lifecycle of a data stream.
# type: request
value: "{\n \"data_retention\": \"7d\"\n}"
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
summary: Set the data stream lifecycle downsampling
# method_request: PUT _data_stream/my-weather-sensor-data-stream/_lifecycle
description: This example configures two downsampling rounds.
# type: request
value:
"{\n \"downsampling\": [\n {\n \"after\": \"1d\",\n \"\
fixed_interval\": \"10m\"\n },\n {\n \"after\": \"7d\",\n \
\ \"fixed_interval\": \"1d\"\n }\n ]\n}"
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# summary:
description: A successful response for configuring a data stream lifecycle.
# type: response
# response_code: 200
value: "{\n \"acknowledged\": true\n}"

0 comments on commit 470590b

Please sign in to comment.