Skip to content

Commit

Permalink
Adds cluster API example requests and responses (#2870)
Browse files Browse the repository at this point in the history
Co-authored-by: lcawl <[email protected]>
  • Loading branch information
szabosteve and lcawl authored Sep 20, 2024
1 parent 8305ec9 commit 85a1534
Show file tree
Hide file tree
Showing 10 changed files with 129 additions and 1 deletion.
69 changes: 68 additions & 1 deletion docs/overlays/elasticsearch-openapi-overlays.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,71 @@ actions:
examples:
resetFeaturesResponseExample1:
$ref: "../../specification/features/reset_features/ResetFeaturesResponseExample1.json"

- target: "$.components['requestBodies']['cluster.allocation_explain']"
description: "Add examples for cluster allocation explain operation"
update:
content:
application/json:
examples:
clusterAllocationExplainRequestExample1:
$ref: "../../specification/cluster/allocation_explain/clusterAllocationExplainRequestExample1.json"
- target: "$.components['responses']['cluster.health#200']"
description: "Add examples for cluster health operation"
update:
content:
application/json:
examples:
clusterHealthResponseExample1:
$ref: "../../specification/cluster/health/clusterHealthResponseExample1.json"
- target: "$.paths['/_cluster/settings']['put']"
description: "Add examples for cluster update settings operation"
update:
requestBody:
content:
application/json:
examples:
clusterPutSettingsRequestExample1:
$ref: "../../specification/cluster/put_settings/clusterPutSettingsRequestExample1.json"
- target: "$.paths['/_cluster/reroute']['post']"
description: "Add examples for cluster reroute operation"
update:
requestBody:
content:
application/json:
examples:
clusterRerouteRequestExample1:
$ref: "../../specification/cluster/reroute/clusterRerouteRequestExample1.json"
- target: "$.components['requestBodies']['nodes.reload_secure_settings']"
description: "Add examples for nodes reload secure settings operation"
update:
content:
application/json:
examples:
clusterNodesReloadSecureSettingsRequestExample1:
$ref: "../../specification/nodes/reload_secure_settings/clusterNodesReloadSecureSettingsRequestExample1.json"
- target: "$.components['responses']['nodes.reload_secure_settings#200']"
description: "Add response examples for nodes reload secure settings operation"
update:
content:
application/json:
examples:
clusterNodesReloadSecureSettingsResponseExample1:
$ref: "../../specification/nodes/reload_secure_settings/clusterNodesReloadSecureSettingsResponseExample1.json"
- target: "$.paths['/_tasks']['get']"
description: "Add examples for task management operation"
update:
responses:
200:
content:
application/json:
examples:
getTasksResponseExample1:
$ref: "../../specification/tasks/get/getTasksResponseExample1.json"
- target: "$.components['responses']['nodes.info#200']"
description: "Add response examples for nodes info"
update:
content:
application/json:
examples:
nodesInfoResponseExample1:
$ref: "../../specification/nodes/info/nodesInfoResponseExample1.yaml"
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"summary": "Provides an explanation for a shard’s current allocation.",
"method_request": "GET _cluster/allocation/explain",
"description": "",
"type": "request",
"value": "{\n \"index\": \"my-index-000001\",\n \"shard\": 0,\n \"primary\": false,\n \"current_node\": \"my-node\"\n}"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"summary": "A successful response when requesting the health status of a cluster.",
"description": "This is the API response in case of a quiet single node cluster with a single index with one shard and one replica.",
"type": "response",
"response_code": 200,
"value": "{\n \"cluster_name\" : \"testcluster\",\n \"status\" : \"yellow\",\n \"timed_out\" : false,\n \"number_of_nodes\" : 1,\n \"number_of_data_nodes\" : 1,\n \"active_primary_shards\" : 1,\n \"active_shards\" : 1,\n \"relocating_shards\" : 0,\n \"initializing_shards\" : 0,\n \"unassigned_shards\" : 1,\n \"delayed_unassigned_shards\": 0,\n \"number_of_pending_tasks\" : 0,\n \"number_of_in_flight_fetch\": 0,\n \"task_max_waiting_in_queue_millis\": 0,\n \"active_shards_percent_as_number\": 50.0\n}"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"summary": "Configures dynamic cluster settings.",
"method_request": "PUT /_cluster/settings",
"description": "An example of a persistent update.",
"type": "request",
"value": "{\n \"persistent\" : {\n \"indices.recovery.max_bytes_per_sec\" : \"50mb\"\n }\n}"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"summary": "Changes the allocation of shards in a cluster.",
"method_request": "POST /_cluster/reroute?metric=none",
"description": "",
"type": "request",
"value": "{\n \"commands\": [\n {\n \"move\": {\n \"index\": \"test\", \"shard\": 0,\n \"from_node\": \"node1\", \"to_node\": \"node2\"\n }\n },\n {\n \"allocate_replica\": {\n \"index\": \"test\", \"shard\": 1,\n \"node\": \"node3\"\n }\n }\n ]\n}"
}
7 changes: 7 additions & 0 deletions specification/nodes/info/nodesInfoResponseExample1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"summary": "A successful response when requesting cluster nodes information.",
"description": "",
"type": "response",
"response_code": 200,
"value": "{\n \"_nodes\": \"...\",\n \"cluster_name\": \"elasticsearch\",\n \"nodes\": {\n \"USpTGYaBSIKbgSUJR2Z9lg\": {\n \"name\": \"node-0\",\n \"transport_address\": \"192.168.17:9300\",\n \"host\": \"node-0.elastic.co\",\n \"ip\": \"192.168.17\",\n \"version\": \"{version}\",\n \"transport_version\": 100000298,\n \"index_version\": 100000074,\n \"component_versions\": {\n \"ml_config_version\": 100000162,\n \"transform_config_version\": 100000096\n },\n \"build_flavor\": \"default\",\n \"build_type\": \"{build_type}\",\n \"build_hash\": \"587409e\",\n \"roles\": [\n \"master\",\n \"data\",\n \"ingest\"\n ],\n \"attributes\": {},\n \"plugins\": [\n {\n \"name\": \"analysis-icu\",\n \"version\": \"{version}\",\n \"description\": \"The ICU Analysis plugin integrates Lucene ICU module into elasticsearch, adding ICU relates analysis components.\",\n \"classname\": \"org.elasticsearch.plugin.analysis.icu.AnalysisICUPlugin\",\n \"has_native_controller\": false\n }\n ],\n \"modules\": [\n {\n \"name\": \"lang-painless\",\n \"version\": \"{version}\",\n \"description\": \"An easy, safe and fast scripting language for Elasticsearch\",\n \"classname\": \"org.elasticsearch.painless.PainlessPlugin\",\n \"has_native_controller\": false\n }\n ]\n }\n }\n}"
}
5 changes: 5 additions & 0 deletions specification/nodes/info/nodesInfoResponseExample1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
summary: 200 Successful response
description: A successful response when requesting cluster nodes information.
# type: response
# response_code: 200
value: "{\n \"_nodes\": \"...\",\n \"cluster_name\": \"elasticsearch\",\n \"nodes\": {\n \"USpTGYaBSIKbgSUJR2Z9lg\": {\n \"name\": \"node-0\",\n \"transport_address\": \"192.168.17:9300\",\n \"host\": \"node-0.elastic.co\",\n \"ip\": \"192.168.17\",\n \"version\": \"{version}\",\n \"transport_version\": 100000298,\n \"index_version\": 100000074,\n \"component_versions\": {\n \"ml_config_version\": 100000162,\n \"transform_config_version\": 100000096\n },\n \"build_flavor\": \"default\",\n \"build_type\": \"{build_type}\",\n \"build_hash\": \"587409e\",\n \"roles\": [\n \"master\",\n \"data\",\n \"ingest\"\n ],\n \"attributes\": {},\n \"plugins\": [\n {\n \"name\": \"analysis-icu\",\n \"version\": \"{version}\",\n \"description\": \"The ICU Analysis plugin integrates Lucene ICU module into elasticsearch, adding ICU relates analysis components.\",\n \"classname\": \"org.elasticsearch.plugin.analysis.icu.AnalysisICUPlugin\",\n \"has_native_controller\": false\n }\n ],\n \"modules\": [\n {\n \"name\": \"lang-painless\",\n \"version\": \"{version}\",\n \"description\": \"An easy, safe and fast scripting language for Elasticsearch\",\n \"classname\": \"org.elasticsearch.painless.PainlessPlugin\",\n \"has_native_controller\": false\n }\n ]\n }\n }\n}"
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"summary": "Reloads the keystore on nodes in the cluster.",
"method_request": "POST _nodes/reload_secure_settings",
"description": "",
"type": "request",
"value": "{\n \"secure_settings_password\":\"keystore-password\"\n}"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"summary": "A successful response when reloading keystore on nodes in your cluster.",
"description": "",
"type": "response",
"response_code": 200,
"value": "{\n \"_nodes\": {\n \"total\": 1,\n \"successful\": 1,\n \"failed\": 0\n },\n \"cluster_name\": \"my_cluster\",\n \"nodes\": {\n \"pQHNt5rXTTWNvUgOrdynKg\": {\n \"name\": \"node-0\"\n }\n }\n}"
}
7 changes: 7 additions & 0 deletions specification/tasks/get/getTasksResponseExample1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"summary": "A successful response when requesting information about the tasks currently executing in the cluster.",
"description": "",
"type": "response",
"response_code": "",
"value": "{\n \"nodes\" : {\n \"oTUltX4IQMOUUVeiohTt8A\" : {\n \"name\" : \"H5dfFeA\",\n \"transport_address\" : \"127.0.0.1:9300\",\n \"host\" : \"127.0.0.1\",\n \"ip\" : \"127.0.0.1:9300\",\n \"tasks\" : {\n \"oTUltX4IQMOUUVeiohTt8A:124\" : {\n \"node\" : \"oTUltX4IQMOUUVeiohTt8A\",\n \"id\" : 124,\n \"type\" : \"direct\",\n \"action\" : \"cluster:monitor/tasks/lists[n]\",\n \"start_time_in_millis\" : 1458585884904,\n \"running_time_in_nanos\" : 47402,\n \"cancellable\" : false,\n \"parent_task_id\" : \"oTUltX4IQMOUUVeiohTt8A:123\"\n },\n \"oTUltX4IQMOUUVeiohTt8A:123\" : {\n \"node\" : \"oTUltX4IQMOUUVeiohTt8A\",\n \"id\" : 123,\n \"type\" : \"transport\",\n \"action\" : \"cluster:monitor/tasks/lists\",\n \"start_time_in_millis\" : 1458585884904,\n \"running_time_in_nanos\" : 236042,\n \"cancellable\" : false\n }\n }\n }\n }\n}"
}

0 comments on commit 85a1534

Please sign in to comment.