Skip to content

Commit 7117a3d

Browse files
committed
getTemplates -> getTemplate
1 parent 16d9e27 commit 7117a3d

File tree

3 files changed

+17
-12
lines changed

3 files changed

+17
-12
lines changed

client/rest-high-level/src/main/java/org/elasticsearch/client/IndicesClient.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,24 +1064,29 @@ public void putTemplateAsync(PutIndexTemplateRequest putIndexTemplateRequest, Re
10641064

10651065
/**
10661066
* Gets index templates using the Index Templates API
1067-
* <p>
10681067
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html"> Index Templates API
10691068
* on elastic.co</a>
1069+
* @param getIndexTemplatesRequest the request
1070+
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
1071+
* @return the response
1072+
* @throws IOException in case there is a problem sending the request or parsing back the response
10701073
*/
1071-
public GetIndexTemplatesResponse getTemplates(GetIndexTemplatesRequest getIndexTemplatesRequest,
1072-
RequestOptions options) throws IOException {
1074+
public GetIndexTemplatesResponse getTemplate(GetIndexTemplatesRequest getIndexTemplatesRequest,
1075+
RequestOptions options) throws IOException {
10731076
return restHighLevelClient.performRequestAndParseEntity(getIndexTemplatesRequest, RequestConverters::getTemplates,
10741077
options, GetIndexTemplatesResponse::fromXContent, emptySet());
10751078
}
10761079

10771080
/**
10781081
* Asynchronously gets index templates using the Index Templates API
1079-
* <p>
10801082
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html"> Index Templates API
10811083
* on elastic.co</a>
1084+
* @param getIndexTemplatesRequest the request
1085+
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
1086+
* @param listener the listener to be notified upon request completion
10821087
*/
1083-
public void getTemplatesAsync(GetIndexTemplatesRequest getIndexTemplatesRequest, RequestOptions options,
1084-
ActionListener<GetIndexTemplatesResponse> listener) {
1088+
public void getTemplateAsync(GetIndexTemplatesRequest getIndexTemplatesRequest, RequestOptions options,
1089+
ActionListener<GetIndexTemplatesResponse> listener) {
10851090
restHighLevelClient.performRequestAsyncAndParseEntity(getIndexTemplatesRequest, RequestConverters::getTemplates,
10861091
options, GetIndexTemplatesResponse::fromXContent, listener, emptySet());
10871092
}

client/rest-high-level/src/test/java/org/elasticsearch/client/IndicesClientIT.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,15 +1021,15 @@ public void testGetIndexTemplate() throws Exception {
10211021
equalTo(true));
10221022

10231023
GetIndexTemplatesResponse getTemplate1 = execute(new GetIndexTemplatesRequest().names("template-1"),
1024-
client.indices()::getTemplates, client.indices()::getTemplatesAsync);
1024+
client.indices()::getTemplate, client.indices()::getTemplateAsync);
10251025
assertThat(getTemplate1.getIndexTemplates(), hasSize(1));
10261026
IndexTemplateMetaData template1 = getTemplate1.getIndexTemplates().get(0);
10271027
assertThat(template1.name(), equalTo("template-1"));
10281028
assertThat(template1.patterns(), contains("pattern-1", "name-1"));
10291029
assertTrue(template1.aliases().containsKey("alias-1"));
10301030

10311031
GetIndexTemplatesResponse getTemplate2 = execute(new GetIndexTemplatesRequest().names("template-2"),
1032-
client.indices()::getTemplates, client.indices()::getTemplatesAsync);
1032+
client.indices()::getTemplate, client.indices()::getTemplateAsync);
10331033
assertThat(getTemplate2.getIndexTemplates(), hasSize(1));
10341034
IndexTemplateMetaData template2 = getTemplate2.getIndexTemplates().get(0);
10351035
assertThat(template2.name(), equalTo("template-2"));
@@ -1044,13 +1044,13 @@ public void testGetIndexTemplate() throws Exception {
10441044
} else {
10451045
getBothRequest.names("template-*");
10461046
}
1047-
GetIndexTemplatesResponse getBoth = execute(getBothRequest, client.indices()::getTemplates, client.indices()::getTemplatesAsync);
1047+
GetIndexTemplatesResponse getBoth = execute(getBothRequest, client.indices()::getTemplate, client.indices()::getTemplateAsync);
10481048
assertThat(getBoth.getIndexTemplates(), hasSize(2));
10491049
assertThat(getBoth.getIndexTemplates().stream().map(IndexTemplateMetaData::getName).toArray(),
10501050
arrayContainingInAnyOrder("template-1", "template-2"));
10511051

10521052
ElasticsearchException notFound = expectThrows(ElasticsearchException.class, () -> execute(
1053-
new GetIndexTemplatesRequest().names("the-template-*"), client.indices()::getTemplates, client.indices()::getTemplatesAsync));
1053+
new GetIndexTemplatesRequest().names("the-template-*"), client.indices()::getTemplate, client.indices()::getTemplateAsync));
10541054
assertThat(notFound.status(), equalTo(RestStatus.NOT_FOUND));
10551055
}
10561056
}

client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/IndicesClientDocumentationIT.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2020,7 +2020,7 @@ public void testGetTemplates() throws Exception {
20202020
// end::get-templates-request-masterTimeout
20212021

20222022
// tag::get-templates-execute
2023-
GetIndexTemplatesResponse getTemplatesResponse = client.indices().getTemplates(request, RequestOptions.DEFAULT);
2023+
GetIndexTemplatesResponse getTemplatesResponse = client.indices().getTemplate(request, RequestOptions.DEFAULT);
20242024
// end::get-templates-execute
20252025

20262026
// tag::get-templates-response
@@ -2050,7 +2050,7 @@ public void onFailure(Exception e) {
20502050
listener = new LatchedActionListener<>(listener, latch);
20512051

20522052
// tag::get-templates-execute-async
2053-
client.indices().getTemplatesAsync(request, RequestOptions.DEFAULT, listener); // <1>
2053+
client.indices().getTemplateAsync(request, RequestOptions.DEFAULT, listener); // <1>
20542054
// end::get-templates-execute-async
20552055

20562056
assertTrue(latch.await(30L, TimeUnit.SECONDS));

0 commit comments

Comments
 (0)