Skip to content

Commit 85a1534

Browse files
szabostevelcawl
andauthored
Adds cluster API example requests and responses (#2870)
Co-authored-by: lcawl <[email protected]>
1 parent 8305ec9 commit 85a1534

10 files changed

+129
-1
lines changed

docs/overlays/elasticsearch-openapi-overlays.yaml

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,71 @@ actions:
4040
examples:
4141
resetFeaturesResponseExample1:
4242
$ref: "../../specification/features/reset_features/ResetFeaturesResponseExample1.json"
43-
43+
- target: "$.components['requestBodies']['cluster.allocation_explain']"
44+
description: "Add examples for cluster allocation explain operation"
45+
update:
46+
content:
47+
application/json:
48+
examples:
49+
clusterAllocationExplainRequestExample1:
50+
$ref: "../../specification/cluster/allocation_explain/clusterAllocationExplainRequestExample1.json"
51+
- target: "$.components['responses']['cluster.health#200']"
52+
description: "Add examples for cluster health operation"
53+
update:
54+
content:
55+
application/json:
56+
examples:
57+
clusterHealthResponseExample1:
58+
$ref: "../../specification/cluster/health/clusterHealthResponseExample1.json"
59+
- target: "$.paths['/_cluster/settings']['put']"
60+
description: "Add examples for cluster update settings operation"
61+
update:
62+
requestBody:
63+
content:
64+
application/json:
65+
examples:
66+
clusterPutSettingsRequestExample1:
67+
$ref: "../../specification/cluster/put_settings/clusterPutSettingsRequestExample1.json"
68+
- target: "$.paths['/_cluster/reroute']['post']"
69+
description: "Add examples for cluster reroute operation"
70+
update:
71+
requestBody:
72+
content:
73+
application/json:
74+
examples:
75+
clusterRerouteRequestExample1:
76+
$ref: "../../specification/cluster/reroute/clusterRerouteRequestExample1.json"
77+
- target: "$.components['requestBodies']['nodes.reload_secure_settings']"
78+
description: "Add examples for nodes reload secure settings operation"
79+
update:
80+
content:
81+
application/json:
82+
examples:
83+
clusterNodesReloadSecureSettingsRequestExample1:
84+
$ref: "../../specification/nodes/reload_secure_settings/clusterNodesReloadSecureSettingsRequestExample1.json"
85+
- target: "$.components['responses']['nodes.reload_secure_settings#200']"
86+
description: "Add response examples for nodes reload secure settings operation"
87+
update:
88+
content:
89+
application/json:
90+
examples:
91+
clusterNodesReloadSecureSettingsResponseExample1:
92+
$ref: "../../specification/nodes/reload_secure_settings/clusterNodesReloadSecureSettingsResponseExample1.json"
93+
- target: "$.paths['/_tasks']['get']"
94+
description: "Add examples for task management operation"
95+
update:
96+
responses:
97+
200:
98+
content:
99+
application/json:
100+
examples:
101+
getTasksResponseExample1:
102+
$ref: "../../specification/tasks/get/getTasksResponseExample1.json"
103+
- target: "$.components['responses']['nodes.info#200']"
104+
description: "Add response examples for nodes info"
105+
update:
106+
content:
107+
application/json:
108+
examples:
109+
nodesInfoResponseExample1:
110+
$ref: "../../specification/nodes/info/nodesInfoResponseExample1.yaml"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"summary": "Provides an explanation for a shard’s current allocation.",
3+
"method_request": "GET _cluster/allocation/explain",
4+
"description": "",
5+
"type": "request",
6+
"value": "{\n \"index\": \"my-index-000001\",\n \"shard\": 0,\n \"primary\": false,\n \"current_node\": \"my-node\"\n}"
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"summary": "A successful response when requesting the health status of a cluster.",
3+
"description": "This is the API response in case of a quiet single node cluster with a single index with one shard and one replica.",
4+
"type": "response",
5+
"response_code": 200,
6+
"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}"
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"summary": "Configures dynamic cluster settings.",
3+
"method_request": "PUT /_cluster/settings",
4+
"description": "An example of a persistent update.",
5+
"type": "request",
6+
"value": "{\n \"persistent\" : {\n \"indices.recovery.max_bytes_per_sec\" : \"50mb\"\n }\n}"
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"summary": "Changes the allocation of shards in a cluster.",
3+
"method_request": "POST /_cluster/reroute?metric=none",
4+
"description": "",
5+
"type": "request",
6+
"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+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"summary": "A successful response when requesting cluster nodes information.",
3+
"description": "",
4+
"type": "response",
5+
"response_code": 200,
6+
"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}"
7+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
summary: 200 Successful response
2+
description: A successful response when requesting cluster nodes information.
3+
# type: response
4+
# response_code: 200
5+
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}"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"summary": "Reloads the keystore on nodes in the cluster.",
3+
"method_request": "POST _nodes/reload_secure_settings",
4+
"description": "",
5+
"type": "request",
6+
"value": "{\n \"secure_settings_password\":\"keystore-password\"\n}"
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"summary": "A successful response when reloading keystore on nodes in your cluster.",
3+
"description": "",
4+
"type": "response",
5+
"response_code": 200,
6+
"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+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"summary": "A successful response when requesting information about the tasks currently executing in the cluster.",
3+
"description": "",
4+
"type": "response",
5+
"response_code": "",
6+
"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}"
7+
}

0 commit comments

Comments
 (0)