Skip to content

Commit c9d5867

Browse files
committed
Docs: HighLevelRestClient#ping (#29070)
Add documentation for `HighLevelRestClient#ping`. Relates to #28389
1 parent c45e208 commit c9d5867

File tree

6 files changed

+32
-21
lines changed

6 files changed

+32
-21
lines changed

client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/MainDocumentationIT.java renamed to client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/MiscellaneousDocumentationIT.java

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,10 @@
3131
import java.io.IOException;
3232

3333
/**
34-
* This class is used to generate the Java Main API documentation.
35-
* You need to wrap your code between two tags like:
36-
* // tag::example[]
37-
* // end::example[]
38-
*
39-
* Where example is your tag name.
40-
*
41-
* Then in the documentation, you can extract what is between tag and end tags with
42-
* ["source","java",subs="attributes,callouts,macros"]
43-
* --------------------------------------------------
44-
* include-tagged::{doc-tests}/MainDocumentationIT.java[example]
45-
* --------------------------------------------------
34+
* Documentation for miscellaneous APIs in the high level java client.
35+
* Code wrapped in {@code tag} and {@code end} tags is included in the docs.
4636
*/
47-
public class MainDocumentationIT extends ESRestHighLevelClientTestCase {
37+
public class MiscellaneousDocumentationIT extends ESRestHighLevelClientTestCase {
4838

4939
public void testMain() throws IOException {
5040
RestHighLevelClient client = highLevelClient();
@@ -68,6 +58,14 @@ public void testMain() throws IOException {
6858
}
6959
}
7060

61+
public void testPing() throws IOException {
62+
RestHighLevelClient client = highLevelClient();
63+
//tag::ping-execute
64+
boolean response = client.ping();
65+
//end::ping-execute
66+
assertTrue(response);
67+
}
68+
7169
public void testInitializationFromClientBuilder() throws IOException {
7270
//tag::rest-high-level-client-init
7371
RestHighLevelClient client = new RestHighLevelClient(

docs/java-rest/high-level/getting-started.asciidoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ to be built as follows:
126126

127127
["source","java",subs="attributes,callouts,macros"]
128128
--------------------------------------------------
129-
include-tagged::{doc-tests}/MainDocumentationIT.java[rest-high-level-client-init]
129+
include-tagged::{doc-tests}/MiscellaneousDocumentationIT.java[rest-high-level-client-init]
130130
--------------------------------------------------
131131

132132
The high-level client will internally create the low-level client used to
@@ -139,7 +139,7 @@ method, which will close the internal `RestClient` instance.
139139

140140
["source","java",subs="attributes,callouts,macros"]
141141
--------------------------------------------------
142-
include-tagged::{doc-tests}/MainDocumentationIT.java[rest-high-level-client-close]
142+
include-tagged::{doc-tests}/MiscellaneousDocumentationIT.java[rest-high-level-client-close]
143143
--------------------------------------------------
144144

145145
In the rest of this documentation about the Java High Level Client, the `RestHighLevelClient` instance

docs/java-rest/high-level/migration.asciidoc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ argument:
6464

6565
["source","java",subs="attributes,callouts,macros"]
6666
--------------------------------------------------
67-
include-tagged::{doc-tests}/MainDocumentationIT.java[rest-high-level-client-init]
67+
include-tagged::{doc-tests}/MiscellaneousDocumentationIT.java[rest-high-level-client-init]
6868
--------------------------------------------------
6969

7070
NOTE: The `RestClient` uses Elasticsearch's HTTP service which is
@@ -91,7 +91,7 @@ must be replaced with:
9191

9292
["source","java",subs="attributes,callouts,macros"]
9393
--------------------------------------------------
94-
include-tagged::{doc-tests}/MainDocumentationIT.java[rest-high-level-client-close]
94+
include-tagged::{doc-tests}/MiscellaneousDocumentationIT.java[rest-high-level-client-close]
9595
--------------------------------------------------
9696

9797
=== Changing the application's code
@@ -351,5 +351,3 @@ body, but any other JSON parser could have been use instead.
351351

352352
We love to hear from you! Please give us your feedback about your migration
353353
experience and how to improve the Java High Level Rest Client on https://discuss.elastic.co/[our forum].
354-
355-

docs/java-rest/high-level/miscellaneous/main.asciidoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Cluster information can be retrieved using the `info()` method:
88

99
["source","java",subs="attributes,callouts,macros"]
1010
--------------------------------------------------
11-
include-tagged::{doc-tests}/MainDocumentationIT.java[main-execute]
11+
include-tagged::{doc-tests}/MiscellaneousDocumentationIT.java[main-execute]
1212
--------------------------------------------------
1313

1414
[[java-rest-high-main-response]]
@@ -18,7 +18,7 @@ The returned `MainResponse` provides various kinds of information about the clus
1818

1919
["source","java",subs="attributes,callouts,macros"]
2020
--------------------------------------------------
21-
include-tagged::{doc-tests}/MainDocumentationIT.java[main-response]
21+
include-tagged::{doc-tests}/MiscellaneousDocumentationIT.java[main-response]
2222
--------------------------------------------------
2323
<1> Retrieve the name of the cluster as a `ClusterName`
2424
<2> Retrieve the unique identifier of the cluster
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[[java-rest-high-ping]]
2+
=== Ping API
3+
4+
[[java-rest-high-ping-request]]
5+
==== Execution
6+
7+
The `ping()` method checks if the cluster is up and available to
8+
process requests and returns a boolean:
9+
10+
["source","java",subs="attributes,callouts,macros"]
11+
--------------------------------------------------
12+
include-tagged::{doc-tests}/MiscellaneousDocumentationIT.java[ping-execute]
13+
--------------------------------------------------

docs/java-rest/high-level/supported-apis.asciidoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@ include::search/scroll.asciidoc[]
3737
The Java High Level REST Client supports the following Miscellaneous APIs:
3838

3939
* <<java-rest-high-main>>
40+
* <<java-rest-high-ping>>
4041

4142
include::miscellaneous/main.asciidoc[]
43+
include::miscellaneous/ping.asciidoc[]
4244

4345
== Indices APIs
4446

0 commit comments

Comments
 (0)