Skip to content

Commit 74a531c

Browse files
Add cluster doc code examples (elastic#2461)
1 parent 44c5c69 commit 74a531c

13 files changed

+132
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// cluster/allocation-explain.asciidoc:10
2+
3+
[source, python]
4+
----
5+
resp = client.cluster.allocation_explain(
6+
body={
7+
"index": "my-index-000001",
8+
"shard": 0,
9+
"primary": False,
10+
"current_node": "my-node",
11+
},
12+
)
13+
print(resp)
14+
----
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// cluster/reroute.asciidoc:195
2+
3+
[source, python]
4+
----
5+
resp = client.cluster.reroute(
6+
metric="none",
7+
body={
8+
"commands": [
9+
{
10+
"move": {
11+
"index": "test",
12+
"shard": 0,
13+
"from_node": "node1",
14+
"to_node": "node2",
15+
}
16+
},
17+
{
18+
"allocate_replica": {
19+
"index": "test",
20+
"shard": 1,
21+
"node": "node3",
22+
}
23+
},
24+
]
25+
},
26+
)
27+
print(resp)
28+
----
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// cluster/update-settings.asciidoc:123
2+
3+
[source, python]
4+
----
5+
resp = client.cluster.put_settings(
6+
body={"transient": {"indices.recovery.*": None}},
7+
)
8+
print(resp)
9+
----
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// health/health.asciidoc:470
2+
3+
[source, python]
4+
----
5+
resp = client.health_report(
6+
verbose="false",
7+
)
8+
print(resp)
9+
----
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// cluster/get-settings.asciidoc:10
2+
3+
[source, python]
4+
----
5+
resp = client.cluster.get_settings()
6+
print(resp)
7+
----
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// cluster/allocation-explain.asciidoc:342
2+
3+
[source, python]
4+
----
5+
resp = client.cluster.allocation_explain()
6+
print(resp)
7+
----
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// health/health.asciidoc:463
2+
3+
[source, python]
4+
----
5+
resp = client.health_report(
6+
feature="shards_availability",
7+
)
8+
print(resp)
9+
----
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// health/health.asciidoc:455
2+
3+
[source, python]
4+
----
5+
resp = client.health_report()
6+
print(resp)
7+
----
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// cluster/allocation-explain.asciidoc:101
2+
3+
[source, python]
4+
----
5+
resp = client.cluster.allocation_explain(
6+
body={"index": "my-index-000001", "shard": 0, "primary": True},
7+
)
8+
print(resp)
9+
----
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// cluster/update-settings.asciidoc:68
2+
3+
[source, python]
4+
----
5+
resp = client.cluster.put_settings(
6+
flat_settings="true",
7+
body={"transient": {"indices.recovery.max_bytes_per_sec": "20mb"}},
8+
)
9+
print(resp)
10+
----
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// cluster/update-settings.asciidoc:45
2+
3+
[source, python]
4+
----
5+
resp = client.cluster.put_settings(
6+
body={"persistent": {"indices.recovery.max_bytes_per_sec": "50mb"}},
7+
)
8+
print(resp)
9+
----
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// cluster/update-settings.asciidoc:96
2+
3+
[source, python]
4+
----
5+
resp = client.cluster.put_settings(
6+
body={"transient": {"indices.recovery.max_bytes_per_sec": None}},
7+
)
8+
print(resp)
9+
----

utils/generate-examples.py

+5
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,11 @@
101101
"mapping/fields/id-field.asciidoc",
102102
"search.asciidoc",
103103
"mapping/params/multi-fields.asciidoc",
104+
"cluster/allocation-explain.asciidoc",
105+
"cluster/get-settings.asciidoc",
106+
"cluster/update-settings.asciidoc",
107+
"health/health.asciidoc",
108+
"cluster/reroute.asciidoc",
104109
]
105110

106111

0 commit comments

Comments
 (0)