From 2bcbf9a20a34e2afef65b4621924d97cdd49cd31 Mon Sep 17 00:00:00 2001 From: Annie Hansen Date: Sat, 24 Feb 2024 11:35:45 -0700 Subject: [PATCH] adding cluster doc code examples --- .../1cecd4d87a92427175157d41859df2af.asciidoc | 14 ++++++++++ .../2cd8439db5054c93c49f1bf50433e1bb.asciidoc | 28 +++++++++++++++++++ .../2fc80a2ad1ca8b2dcb13ed1895b8e861.asciidoc | 9 ++++++ .../3541d4a85e27b2c3896a7a7ee98b4b37.asciidoc | 9 ++++++ .../4029af36cb3f8202549017f7378803b4.asciidoc | 7 +++++ .../4ca15672fc5ab1d80a127d086b6d2837.asciidoc | 7 +++++ .../87733deeea4b441b595d19a0f97346f0.asciidoc | 9 ++++++ .../9d79645ab3a9da3f63c54a1516214a5a.asciidoc | 7 +++++ .../ab8de34fcfc0277901cb39618ecfc9d5.asciidoc | 9 ++++++ .../ac85e05c0bf2fd5099fbcb9c492f447e.asciidoc | 10 +++++++ .../e5901f48eb8a419b878fc2cb815d8691.asciidoc | 9 ++++++ .../eff8ecaed1ed084909c64450fc363a20.asciidoc | 9 ++++++ utils/generate-examples.py | 5 ++++ 13 files changed, 132 insertions(+) create mode 100644 docs/examples/1cecd4d87a92427175157d41859df2af.asciidoc create mode 100644 docs/examples/2cd8439db5054c93c49f1bf50433e1bb.asciidoc create mode 100644 docs/examples/2fc80a2ad1ca8b2dcb13ed1895b8e861.asciidoc create mode 100644 docs/examples/3541d4a85e27b2c3896a7a7ee98b4b37.asciidoc create mode 100644 docs/examples/4029af36cb3f8202549017f7378803b4.asciidoc create mode 100644 docs/examples/4ca15672fc5ab1d80a127d086b6d2837.asciidoc create mode 100644 docs/examples/87733deeea4b441b595d19a0f97346f0.asciidoc create mode 100644 docs/examples/9d79645ab3a9da3f63c54a1516214a5a.asciidoc create mode 100644 docs/examples/ab8de34fcfc0277901cb39618ecfc9d5.asciidoc create mode 100644 docs/examples/ac85e05c0bf2fd5099fbcb9c492f447e.asciidoc create mode 100644 docs/examples/e5901f48eb8a419b878fc2cb815d8691.asciidoc create mode 100644 docs/examples/eff8ecaed1ed084909c64450fc363a20.asciidoc diff --git a/docs/examples/1cecd4d87a92427175157d41859df2af.asciidoc b/docs/examples/1cecd4d87a92427175157d41859df2af.asciidoc new file mode 100644 index 0000000000..f4ff982b7b --- /dev/null +++ b/docs/examples/1cecd4d87a92427175157d41859df2af.asciidoc @@ -0,0 +1,14 @@ +// cluster/allocation-explain.asciidoc:10 + +[source, python] +---- +resp = client.cluster.allocation_explain( + body={ + "index": "my-index-000001", + "shard": 0, + "primary": False, + "current_node": "my-node", + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/2cd8439db5054c93c49f1bf50433e1bb.asciidoc b/docs/examples/2cd8439db5054c93c49f1bf50433e1bb.asciidoc new file mode 100644 index 0000000000..a4a64ba77f --- /dev/null +++ b/docs/examples/2cd8439db5054c93c49f1bf50433e1bb.asciidoc @@ -0,0 +1,28 @@ +// cluster/reroute.asciidoc:195 + +[source, python] +---- +resp = client.cluster.reroute( + metric="none", + body={ + "commands": [ + { + "move": { + "index": "test", + "shard": 0, + "from_node": "node1", + "to_node": "node2", + } + }, + { + "allocate_replica": { + "index": "test", + "shard": 1, + "node": "node3", + } + }, + ] + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/2fc80a2ad1ca8b2dcb13ed1895b8e861.asciidoc b/docs/examples/2fc80a2ad1ca8b2dcb13ed1895b8e861.asciidoc new file mode 100644 index 0000000000..cbc3103152 --- /dev/null +++ b/docs/examples/2fc80a2ad1ca8b2dcb13ed1895b8e861.asciidoc @@ -0,0 +1,9 @@ +// cluster/update-settings.asciidoc:123 + +[source, python] +---- +resp = client.cluster.put_settings( + body={"transient": {"indices.recovery.*": None}}, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/3541d4a85e27b2c3896a7a7ee98b4b37.asciidoc b/docs/examples/3541d4a85e27b2c3896a7a7ee98b4b37.asciidoc new file mode 100644 index 0000000000..e189b1def7 --- /dev/null +++ b/docs/examples/3541d4a85e27b2c3896a7a7ee98b4b37.asciidoc @@ -0,0 +1,9 @@ +// health/health.asciidoc:470 + +[source, python] +---- +resp = client.health_report( + verbose="false", +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/4029af36cb3f8202549017f7378803b4.asciidoc b/docs/examples/4029af36cb3f8202549017f7378803b4.asciidoc new file mode 100644 index 0000000000..8319dd6ce1 --- /dev/null +++ b/docs/examples/4029af36cb3f8202549017f7378803b4.asciidoc @@ -0,0 +1,7 @@ +// cluster/get-settings.asciidoc:10 + +[source, python] +---- +resp = client.cluster.get_settings() +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/4ca15672fc5ab1d80a127d086b6d2837.asciidoc b/docs/examples/4ca15672fc5ab1d80a127d086b6d2837.asciidoc new file mode 100644 index 0000000000..4f9dcb5a91 --- /dev/null +++ b/docs/examples/4ca15672fc5ab1d80a127d086b6d2837.asciidoc @@ -0,0 +1,7 @@ +// cluster/allocation-explain.asciidoc:342 + +[source, python] +---- +resp = client.cluster.allocation_explain() +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/87733deeea4b441b595d19a0f97346f0.asciidoc b/docs/examples/87733deeea4b441b595d19a0f97346f0.asciidoc new file mode 100644 index 0000000000..7dce868733 --- /dev/null +++ b/docs/examples/87733deeea4b441b595d19a0f97346f0.asciidoc @@ -0,0 +1,9 @@ +// health/health.asciidoc:463 + +[source, python] +---- +resp = client.health_report( + feature="shards_availability", +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/9d79645ab3a9da3f63c54a1516214a5a.asciidoc b/docs/examples/9d79645ab3a9da3f63c54a1516214a5a.asciidoc new file mode 100644 index 0000000000..974117af48 --- /dev/null +++ b/docs/examples/9d79645ab3a9da3f63c54a1516214a5a.asciidoc @@ -0,0 +1,7 @@ +// health/health.asciidoc:455 + +[source, python] +---- +resp = client.health_report() +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/ab8de34fcfc0277901cb39618ecfc9d5.asciidoc b/docs/examples/ab8de34fcfc0277901cb39618ecfc9d5.asciidoc new file mode 100644 index 0000000000..7782e0d64e --- /dev/null +++ b/docs/examples/ab8de34fcfc0277901cb39618ecfc9d5.asciidoc @@ -0,0 +1,9 @@ +// cluster/allocation-explain.asciidoc:101 + +[source, python] +---- +resp = client.cluster.allocation_explain( + body={"index": "my-index-000001", "shard": 0, "primary": True}, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/ac85e05c0bf2fd5099fbcb9c492f447e.asciidoc b/docs/examples/ac85e05c0bf2fd5099fbcb9c492f447e.asciidoc new file mode 100644 index 0000000000..cdef1b4a4b --- /dev/null +++ b/docs/examples/ac85e05c0bf2fd5099fbcb9c492f447e.asciidoc @@ -0,0 +1,10 @@ +// cluster/update-settings.asciidoc:68 + +[source, python] +---- +resp = client.cluster.put_settings( + flat_settings="true", + body={"transient": {"indices.recovery.max_bytes_per_sec": "20mb"}}, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/e5901f48eb8a419b878fc2cb815d8691.asciidoc b/docs/examples/e5901f48eb8a419b878fc2cb815d8691.asciidoc new file mode 100644 index 0000000000..740c463d06 --- /dev/null +++ b/docs/examples/e5901f48eb8a419b878fc2cb815d8691.asciidoc @@ -0,0 +1,9 @@ +// cluster/update-settings.asciidoc:45 + +[source, python] +---- +resp = client.cluster.put_settings( + body={"persistent": {"indices.recovery.max_bytes_per_sec": "50mb"}}, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/eff8ecaed1ed084909c64450fc363a20.asciidoc b/docs/examples/eff8ecaed1ed084909c64450fc363a20.asciidoc new file mode 100644 index 0000000000..b4c4142ca2 --- /dev/null +++ b/docs/examples/eff8ecaed1ed084909c64450fc363a20.asciidoc @@ -0,0 +1,9 @@ +// cluster/update-settings.asciidoc:96 + +[source, python] +---- +resp = client.cluster.put_settings( + body={"transient": {"indices.recovery.max_bytes_per_sec": None}}, +) +print(resp) +---- \ No newline at end of file diff --git a/utils/generate-examples.py b/utils/generate-examples.py index 9626e6e963..fedfd1c4dd 100644 --- a/utils/generate-examples.py +++ b/utils/generate-examples.py @@ -101,6 +101,11 @@ "mapping/fields/id-field.asciidoc", "search.asciidoc", "mapping/params/multi-fields.asciidoc", + "cluster/allocation-explain.asciidoc", + "cluster/get-settings.asciidoc", + "cluster/update-settings.asciidoc", + "health/health.asciidoc", + "cluster/reroute.asciidoc", ]