From 7dc97a4b88b31599c1edd76b713e5d0b6c172094 Mon Sep 17 00:00:00 2001 From: Przemko Robakowski Date: Mon, 6 Apr 2020 21:11:29 +0200 Subject: [PATCH 01/16] HLRC support for Index Templates V2 This change adds High Level Rest Client support for Index Templates V2. Relates to #53101 --- .../elasticsearch/client/IndicesClient.java | 127 +++++++++++++++- .../client/IndicesRequestConverters.java | 57 +++++++ .../indices/DeleteIndexTemplateV2Request.java | 35 +++++ .../indices/GetIndexTemplatesV2Request.java | 80 ++++++++++ .../indices/GetIndexTemplatesV2Response.java | 108 ++++++++++++++ .../indices/IndexTemplateV2ExistRequest.java | 40 +++++ .../indices/PutIndexTemplateV2Request.java | 100 +++++++++++++ .../elasticsearch/client/IndicesClientIT.java | 58 +++++++ .../client/RestHighLevelClientTests.java | 2 - .../GetIndexTemplatesV2ResponseTests.java | 141 ++++++++++++++++++ .../api/indices.exists_index_template.json | 39 +++++ .../cluster/metadata/IndexTemplateV2.java | 2 +- 12 files changed, 785 insertions(+), 4 deletions(-) create mode 100644 client/rest-high-level/src/main/java/org/elasticsearch/client/indices/DeleteIndexTemplateV2Request.java create mode 100644 client/rest-high-level/src/main/java/org/elasticsearch/client/indices/GetIndexTemplatesV2Request.java create mode 100644 client/rest-high-level/src/main/java/org/elasticsearch/client/indices/GetIndexTemplatesV2Response.java create mode 100644 client/rest-high-level/src/main/java/org/elasticsearch/client/indices/IndexTemplateV2ExistRequest.java create mode 100644 client/rest-high-level/src/main/java/org/elasticsearch/client/indices/PutIndexTemplateV2Request.java create mode 100644 client/rest-high-level/src/test/java/org/elasticsearch/client/indices/GetIndexTemplatesV2ResponseTests.java create mode 100644 rest-api-spec/src/main/resources/rest-api-spec/api/indices.exists_index_template.json diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/IndicesClient.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/IndicesClient.java index 96494238e75e0..da42c3bf9050d 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/IndicesClient.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/IndicesClient.java @@ -48,6 +48,7 @@ import org.elasticsearch.client.indices.CreateIndexRequest; import org.elasticsearch.client.indices.CreateIndexResponse; import org.elasticsearch.client.indices.DeleteAliasRequest; +import org.elasticsearch.client.indices.DeleteIndexTemplateV2Request; import org.elasticsearch.client.indices.FreezeIndexRequest; import org.elasticsearch.client.indices.GetFieldMappingsRequest; import org.elasticsearch.client.indices.GetFieldMappingsResponse; @@ -55,10 +56,14 @@ import org.elasticsearch.client.indices.GetIndexResponse; import org.elasticsearch.client.indices.GetIndexTemplatesRequest; import org.elasticsearch.client.indices.GetIndexTemplatesResponse; +import org.elasticsearch.client.indices.GetIndexTemplatesV2Request; +import org.elasticsearch.client.indices.GetIndexTemplatesV2Response; import org.elasticsearch.client.indices.GetMappingsRequest; import org.elasticsearch.client.indices.GetMappingsResponse; +import org.elasticsearch.client.indices.IndexTemplateV2ExistRequest; import org.elasticsearch.client.indices.IndexTemplatesExistRequest; import org.elasticsearch.client.indices.PutIndexTemplateRequest; +import org.elasticsearch.client.indices.PutIndexTemplateV2Request; import org.elasticsearch.client.indices.PutMappingRequest; import org.elasticsearch.client.indices.ReloadAnalyzersRequest; import org.elasticsearch.client.indices.ReloadAnalyzersResponse; @@ -909,6 +914,36 @@ public Cancellable putTemplateAsync(PutIndexTemplateRequest putIndexTemplateRequ AcknowledgedResponse::fromXContent, listener, emptySet()); } + /** + * Puts an index template using the Index Templates API. + * See Index Templates API + * on elastic.co + * @param putIndexTemplateRequest the request + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @return the response + * @throws IOException in case there is a problem sending the request or parsing back the response + */ + public AcknowledgedResponse putIndexTemplate(PutIndexTemplateV2Request putIndexTemplateRequest, RequestOptions options) + throws IOException { + return restHighLevelClient.performRequestAndParseEntity(putIndexTemplateRequest, IndicesRequestConverters::putIndexTemplate, + options, AcknowledgedResponse::fromXContent, emptySet()); + } + + /** + * Asynchronously puts an index template using the Index Templates API. + * See Index Templates API + * on elastic.co + * @param putIndexTemplateRequest the request + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param listener the listener to be notified upon request completion + * @return cancellable that may be used to cancel the request + */ + public Cancellable putIndexTemplateAsync(PutIndexTemplateV2Request putIndexTemplateRequest, + RequestOptions options, ActionListener listener) { + return restHighLevelClient.performRequestAsyncAndParseEntity(putIndexTemplateRequest, IndicesRequestConverters::putIndexTemplate, + options, AcknowledgedResponse::fromXContent, listener, emptySet()); + } + /** * Validate a potentially expensive query without executing it. *

@@ -943,6 +978,36 @@ public Cancellable validateQueryAsync(ValidateQueryRequest validateQueryRequest, ValidateQueryResponse::fromXContent, listener, emptySet()); } + /** + * Gets index templates using the Index Templates API + * See Index Templates API + * on elastic.co + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param getIndexTemplatesRequest the request + * @return the response + * @throws IOException in case there is a problem sending the request or parsing back the response + */ + public GetIndexTemplatesV2Response getIndexTemplate(GetIndexTemplatesV2Request getIndexTemplatesRequest, + RequestOptions options) throws IOException { + return restHighLevelClient.performRequestAndParseEntity(getIndexTemplatesRequest, IndicesRequestConverters::getIndexTemplates, + options, GetIndexTemplatesV2Response::fromXContent, emptySet()); + } + + /** + * Asynchronously gets index templates using the Index Templates API + * See Index Templates API + * on elastic.co + * @param getIndexTemplatesRequest the request + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param listener the listener to be notified upon request completion + * @return cancellable that may be used to cancel the request + */ + public Cancellable getIndexTemplateAsync(GetIndexTemplatesV2Request getIndexTemplatesRequest, RequestOptions options, + ActionListener listener) { + return restHighLevelClient.performRequestAsyncAndParseEntity(getIndexTemplatesRequest, + IndicesRequestConverters::getIndexTemplates, options, GetIndexTemplatesV2Response::fromXContent, listener, emptySet()); + } + /** * Gets index templates using the Index Templates API * See Index Templates API @@ -953,7 +1018,7 @@ public Cancellable validateQueryAsync(ValidateQueryRequest validateQueryRequest, * @throws IOException in case there is a problem sending the request or parsing back the response */ public GetIndexTemplatesResponse getIndexTemplate(GetIndexTemplatesRequest getIndexTemplatesRequest, - RequestOptions options) throws IOException { + RequestOptions options) throws IOException { return restHighLevelClient.performRequestAndParseEntity(getIndexTemplatesRequest, IndicesRequestConverters::getTemplates, options, GetIndexTemplatesResponse::fromXContent, emptySet()); @@ -1006,6 +1071,37 @@ public Cancellable existsTemplateAsync(IndexTemplatesExistRequest indexTemplates RestHighLevelClient::convertExistsResponse, listener, emptySet()); } + /** + * Uses the Index Templates API to determine if index templates exist + * + * @param indexTemplatesRequest the request + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @return true if any index templates in the request exist, false otherwise + * @throws IOException in case there is a problem sending the request or parsing back the response + */ + public boolean existsIndexTemplate(IndexTemplateV2ExistRequest indexTemplatesRequest, + RequestOptions options) throws IOException { + return restHighLevelClient.performRequest(indexTemplatesRequest, + IndicesRequestConverters::templatesExist, options, + RestHighLevelClient::convertExistsResponse, emptySet()); + } + + /** + * Uses the Index Templates API to determine if index templates exist + * @param indexTemplatesExistRequest the request + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param listener the listener to be notified upon request completion. The listener will be called with the value {@code true} + * @return cancellable that may be used to cancel the request + */ + public Cancellable existsIndexTemplateAsync(IndexTemplateV2ExistRequest indexTemplatesExistRequest, + RequestOptions options, + ActionListener listener) { + + return restHighLevelClient.performRequestAsync(indexTemplatesExistRequest, + IndicesRequestConverters::templatesExist, options, + RestHighLevelClient::convertExistsResponse, listener, emptySet()); + } + /** * Calls the analyze API * @@ -1112,6 +1208,35 @@ public Cancellable deleteTemplateAsync(DeleteIndexTemplateRequest request, Reque options, AcknowledgedResponse::fromXContent, listener, emptySet()); } + /** + * Delete an index template using the Index Templates API + * See Index Templates API + * on elastic.co + * + * @param request the request + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @throws IOException in case there is a problem sending the request or parsing back the response + */ + public AcknowledgedResponse deleteIndexTemplate(DeleteIndexTemplateV2Request request, RequestOptions options) throws IOException { + return restHighLevelClient.performRequestAndParseEntity(request, IndicesRequestConverters::deleteIndexTemplate, + options, AcknowledgedResponse::fromXContent, emptySet()); + } + + /** + * Asynchronously delete an index template using the Index Templates API + * See Index Templates API + * on elastic.co + * @param request the request + * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized + * @param listener the listener to be notified upon request completion + * @return cancellable that may be used to cancel the request + */ + public Cancellable deleteIndexTemplateAsync(DeleteIndexTemplateV2Request request, RequestOptions options, + ActionListener listener) { + return restHighLevelClient.performRequestAsyncAndParseEntity(request, IndicesRequestConverters::deleteIndexTemplate, + options, AcknowledgedResponse::fromXContent, listener, emptySet()); + } + /** * Synchronously calls the _reload_search_analyzers API * diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/IndicesRequestConverters.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/IndicesRequestConverters.java index b0afa84a05e38..eb29320cf097e 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/IndicesRequestConverters.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/IndicesRequestConverters.java @@ -41,13 +41,17 @@ import org.elasticsearch.client.indices.CloseIndexRequest; import org.elasticsearch.client.indices.CreateIndexRequest; import org.elasticsearch.client.indices.DeleteAliasRequest; +import org.elasticsearch.client.indices.DeleteIndexTemplateV2Request; import org.elasticsearch.client.indices.FreezeIndexRequest; import org.elasticsearch.client.indices.GetFieldMappingsRequest; import org.elasticsearch.client.indices.GetIndexRequest; import org.elasticsearch.client.indices.GetIndexTemplatesRequest; +import org.elasticsearch.client.indices.GetIndexTemplatesV2Request; import org.elasticsearch.client.indices.GetMappingsRequest; +import org.elasticsearch.client.indices.IndexTemplateV2ExistRequest; import org.elasticsearch.client.indices.IndexTemplatesExistRequest; import org.elasticsearch.client.indices.PutIndexTemplateRequest; +import org.elasticsearch.client.indices.PutIndexTemplateV2Request; import org.elasticsearch.client.indices.PutMappingRequest; import org.elasticsearch.client.indices.ReloadAnalyzersRequest; import org.elasticsearch.client.indices.ResizeRequest; @@ -403,6 +407,23 @@ static Request putTemplate(PutIndexTemplateRequest putIndexTemplateRequest) thro return request; } + static Request putIndexTemplate(PutIndexTemplateV2Request putIndexTemplateRequest) throws IOException { + String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_index_template") + .addPathPart(putIndexTemplateRequest.name()).build(); + Request request = new Request(HttpPut.METHOD_NAME, endpoint); + RequestConverters.Params params = new RequestConverters.Params(); + params.withMasterTimeout(putIndexTemplateRequest.masterNodeTimeout()); + if (putIndexTemplateRequest.create()) { + params.putParam("create", Boolean.TRUE.toString()); + } + if (Strings.hasText(putIndexTemplateRequest.cause())) { + params.putParam("cause", putIndexTemplateRequest.cause()); + } + request.addParameters(params.asMap()); + request.setEntity(RequestConverters.createEntity(putIndexTemplateRequest, RequestConverters.REQUEST_BODY_CONTENT_TYPE)); + return request; + } + static Request validateQuery(ValidateQueryRequest validateQueryRequest) throws IOException { String[] indices = validateQueryRequest.indices() == null ? Strings.EMPTY_ARRAY : validateQueryRequest.indices(); String endpoint = RequestConverters.endpoint(indices, "_validate/query"); @@ -442,6 +463,19 @@ static Request getTemplates(GetIndexTemplatesRequest getIndexTemplatesRequest) { return request; } + static Request getIndexTemplates(GetIndexTemplatesV2Request getIndexTemplatesRequest) { + final String endpoint = new RequestConverters.EndpointBuilder() + .addPathPartAsIs("_index_template") + .addPathPart(getIndexTemplatesRequest.name()) + .build(); + final Request request = new Request(HttpGet.METHOD_NAME, endpoint); + final RequestConverters.Params params = new RequestConverters.Params(); + params.withLocal(getIndexTemplatesRequest.isLocal()); + params.withMasterTimeout(getIndexTemplatesRequest.getMasterNodeTimeout()); + request.addParameters(params.asMap()); + return request; + } + static Request templatesExist(IndexTemplatesExistRequest indexTemplatesExistRequest) { final String endpoint = new RequestConverters.EndpointBuilder() .addPathPartAsIs("_template") @@ -455,6 +489,19 @@ static Request templatesExist(IndexTemplatesExistRequest indexTemplatesExistRequ return request; } + static Request templatesExist(IndexTemplateV2ExistRequest indexTemplatesExistRequest) { + final String endpoint = new RequestConverters.EndpointBuilder() + .addPathPartAsIs("_index_template") + .addPathPart(indexTemplatesExistRequest.name()) + .build(); + final Request request = new Request(HttpHead.METHOD_NAME, endpoint); + final RequestConverters.Params params = new RequestConverters.Params(); + params.withLocal(indexTemplatesExistRequest.isLocal()); + params.withMasterTimeout(indexTemplatesExistRequest.getMasterNodeTimeout()); + request.addParameters(params.asMap()); + return request; + } + static Request analyze(AnalyzeRequest request) throws IOException { RequestConverters.EndpointBuilder builder = new RequestConverters.EndpointBuilder(); String index = request.index(); @@ -501,6 +548,16 @@ static Request deleteTemplate(DeleteIndexTemplateRequest deleteIndexTemplateRequ return request; } + static Request deleteIndexTemplate(DeleteIndexTemplateV2Request deleteIndexTemplateRequest) { + String name = deleteIndexTemplateRequest.getName(); + String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_index_template").addPathPart(name).build(); + Request request = new Request(HttpDelete.METHOD_NAME, endpoint); + RequestConverters.Params params = new RequestConverters.Params(); + params.withMasterTimeout(deleteIndexTemplateRequest.masterNodeTimeout()); + request.addParameters(params.asMap()); + return request; + } + static Request reloadAnalyzers(ReloadAnalyzersRequest reloadAnalyzersRequest) { String endpoint = RequestConverters.endpoint(reloadAnalyzersRequest.getIndices(), "_reload_search_analyzers"); Request request = new Request(HttpPost.METHOD_NAME, endpoint); diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/DeleteIndexTemplateV2Request.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/DeleteIndexTemplateV2Request.java new file mode 100644 index 0000000000000..cb757e0e58433 --- /dev/null +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/DeleteIndexTemplateV2Request.java @@ -0,0 +1,35 @@ +/* + * Licensed to Elasticsearch under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.elasticsearch.client.indices; + +import org.elasticsearch.client.TimedRequest; + +public class DeleteIndexTemplateV2Request extends TimedRequest { + + private final String name; + + public DeleteIndexTemplateV2Request(String name) { + this.name = name; + } + + public String getName() { + return name; + } +} diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/GetIndexTemplatesV2Request.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/GetIndexTemplatesV2Request.java new file mode 100644 index 0000000000000..0d606535d9328 --- /dev/null +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/GetIndexTemplatesV2Request.java @@ -0,0 +1,80 @@ +/* + * Licensed to Elasticsearch under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.elasticsearch.client.indices; + +import org.elasticsearch.client.TimedRequest; +import org.elasticsearch.client.Validatable; +import org.elasticsearch.common.Nullable; +import org.elasticsearch.common.unit.TimeValue; + +/** + * A request to read the content of component templates + */ +public class GetIndexTemplatesV2Request implements Validatable { + + private final String name; + + private TimeValue masterNodeTimeout = TimedRequest.DEFAULT_MASTER_NODE_TIMEOUT; + private boolean local = false; + + /** + * Create a request to read the content of component template. If no template name is provided, all templates will + * be read + * + * @param name the name of template to read + */ + public GetIndexTemplatesV2Request(String name) { + this.name = name; + } + + /** + * @return the name of component template this request is requesting + */ + public String name() { + return name; + } + + /** + * @return the timeout for waiting for the master node to respond + */ + public TimeValue getMasterNodeTimeout() { + return masterNodeTimeout; + } + + public void setMasterNodeTimeout(@Nullable TimeValue masterNodeTimeout) { + this.masterNodeTimeout = masterNodeTimeout; + } + + public void setMasterNodeTimeout(String masterNodeTimeout) { + final TimeValue timeValue = TimeValue.parseTimeValue(masterNodeTimeout, getClass().getSimpleName() + ".masterNodeTimeout"); + setMasterNodeTimeout(timeValue); + } + + /** + * @return true if this request is to read from the local cluster state, rather than the master node - false otherwise + */ + public boolean isLocal() { + return local; + } + + public void setLocal(boolean local) { + this.local = local; + } +} diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/GetIndexTemplatesV2Response.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/GetIndexTemplatesV2Response.java new file mode 100644 index 0000000000000..c96f874087ffe --- /dev/null +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/GetIndexTemplatesV2Response.java @@ -0,0 +1,108 @@ +/* + * Licensed to Elasticsearch under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.elasticsearch.client.indices; + +import org.elasticsearch.cluster.metadata.IndexTemplateV2; +import org.elasticsearch.common.ParseField; +import org.elasticsearch.common.xcontent.ConstructingObjectParser; +import org.elasticsearch.common.xcontent.XContentParser; + +import java.io.IOException; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; + + +public class GetIndexTemplatesV2Response { + + public static final ParseField NAME = new ParseField("name"); + public static final ParseField INDEX_TEMPLATES = new ParseField("index_templates"); + public static final ParseField INDEX_TEMPLATE = new ParseField("index_template"); + + @SuppressWarnings("unchecked") + private static final ConstructingObjectParser, Void> PARSER = + new ConstructingObjectParser<>("index_templates", false, + a -> ((List) a[0]).stream().collect(Collectors.toMap(n -> n.name, n -> n.indexTemplate, + (n1, n2) -> n1, LinkedHashMap::new))); + + private static final ConstructingObjectParser INNER_PARSER = + new ConstructingObjectParser<>("named_index_template", false, + a -> new NamedIndexTemplate((String) a[0], (IndexTemplateV2) a[1])); + + static { + INNER_PARSER.declareString(ConstructingObjectParser.constructorArg(), NAME); + INNER_PARSER.declareObject(ConstructingObjectParser.constructorArg(), IndexTemplateV2.PARSER, INDEX_TEMPLATE); + PARSER.declareObjectArray(ConstructingObjectParser.constructorArg(), INNER_PARSER, INDEX_TEMPLATES); + } + + private static class NamedIndexTemplate { + String name; + IndexTemplateV2 indexTemplate; + + private NamedIndexTemplate(String name, IndexTemplateV2 indexTemplate) { + this.name = name; + this.indexTemplate = indexTemplate; + } + } + + @Override + public String toString() { + return "GetIndexTemplatesResponse [indexTemplates=" + indexTemplates + "]"; + } + + private final Map indexTemplates; + + GetIndexTemplatesV2Response(Map indexTemplates) { + this.indexTemplates = Collections.unmodifiableMap(new LinkedHashMap<>(indexTemplates)); + } + + public Map getIndexTemplates() { + return indexTemplates; + } + + + public static GetIndexTemplatesV2Response fromXContent(XContentParser parser) throws IOException { + return new GetIndexTemplatesV2Response(PARSER.apply(parser, null)); + } + + @Override + public int hashCode() { + return Objects.hash(indexTemplates); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + GetIndexTemplatesV2Response other = (GetIndexTemplatesV2Response) obj; + return Objects.equals(indexTemplates, other.indexTemplates); + } + + +} diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/IndexTemplateV2ExistRequest.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/IndexTemplateV2ExistRequest.java new file mode 100644 index 0000000000000..f631ea5525f84 --- /dev/null +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/IndexTemplateV2ExistRequest.java @@ -0,0 +1,40 @@ +/* + * Licensed to Elasticsearch under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.elasticsearch.client.indices; + +import org.elasticsearch.common.Strings; + +/** + * A request to check for the existence of component templates + */ +public class IndexTemplateV2ExistRequest extends GetComponentTemplatesRequest { + + /** + * Create a request to check for the existence of component template. Name must be provided + * + * @param name the name of template to check for the existence of + */ + public IndexTemplateV2ExistRequest(String name) { + super(name); + if (Strings.isNullOrEmpty(name)) { + throw new IllegalArgumentException("must provide component template name"); + } + } +} diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/PutIndexTemplateV2Request.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/PutIndexTemplateV2Request.java new file mode 100644 index 0000000000000..95cdfee00d578 --- /dev/null +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/PutIndexTemplateV2Request.java @@ -0,0 +1,100 @@ +/* + * Licensed to Elasticsearch under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.elasticsearch.client.indices; + +import org.elasticsearch.client.TimedRequest; +import org.elasticsearch.cluster.metadata.IndexTemplateV2; +import org.elasticsearch.common.Strings; +import org.elasticsearch.common.xcontent.ToXContentObject; +import org.elasticsearch.common.xcontent.XContentBuilder; + +import java.io.IOException; + +/** + * A request to create an component template. + */ +public class PutIndexTemplateV2Request extends TimedRequest implements ToXContentObject { + + private String name; + + private String cause = ""; + + private boolean create; + + private IndexTemplateV2 indexTemplate; + + /** + * Sets the name of the component template. + */ + public PutIndexTemplateV2Request name(String name) { + if (Strings.isNullOrEmpty(name)) { + throw new IllegalArgumentException("name cannot be null or empty"); + } + this.name = name; + return this; + } + + /** + * The name of the component template. + */ + public String name() { + return this.name; + } + + /** + * Set to {@code true} to force only creation, not an update of an component template. If it already + * exists, it will fail with an {@link IllegalArgumentException}. + */ + public PutIndexTemplateV2Request create(boolean create) { + this.create = create; + return this; + } + + public boolean create() { + return create; + } + + /** + * The component template to create. + */ + public PutIndexTemplateV2Request indexTemplate(IndexTemplateV2 indexTemplate) { + this.indexTemplate = indexTemplate; + return this; + } + + /** + * The cause for this component template creation. + */ + public PutIndexTemplateV2Request cause(String cause) { + this.cause = cause; + return this; + } + + public String cause() { + return this.cause; + } + + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + if (indexTemplate != null) { + indexTemplate.toXContent(builder, params); + } + return builder; + } +} diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/IndicesClientIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/IndicesClientIT.java index cbe0b683b9726..27beba134e83c 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/IndicesClientIT.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/IndicesClientIT.java @@ -61,6 +61,7 @@ import org.elasticsearch.client.indices.CreateIndexRequest; import org.elasticsearch.client.indices.CreateIndexResponse; import org.elasticsearch.client.indices.DeleteAliasRequest; +import org.elasticsearch.client.indices.DeleteIndexTemplateV2Request; import org.elasticsearch.client.indices.FreezeIndexRequest; import org.elasticsearch.client.indices.GetFieldMappingsRequest; import org.elasticsearch.client.indices.GetFieldMappingsResponse; @@ -68,11 +69,15 @@ import org.elasticsearch.client.indices.GetIndexResponse; import org.elasticsearch.client.indices.GetIndexTemplatesRequest; import org.elasticsearch.client.indices.GetIndexTemplatesResponse; +import org.elasticsearch.client.indices.GetIndexTemplatesV2Request; +import org.elasticsearch.client.indices.GetIndexTemplatesV2Response; import org.elasticsearch.client.indices.GetMappingsRequest; import org.elasticsearch.client.indices.GetMappingsResponse; import org.elasticsearch.client.indices.IndexTemplateMetadata; +import org.elasticsearch.client.indices.IndexTemplateV2ExistRequest; import org.elasticsearch.client.indices.IndexTemplatesExistRequest; import org.elasticsearch.client.indices.PutIndexTemplateRequest; +import org.elasticsearch.client.indices.PutIndexTemplateV2Request; import org.elasticsearch.client.indices.PutMappingRequest; import org.elasticsearch.client.indices.ReloadAnalyzersRequest; import org.elasticsearch.client.indices.ReloadAnalyzersResponse; @@ -81,9 +86,12 @@ import org.elasticsearch.client.indices.rollover.RolloverResponse; import org.elasticsearch.cluster.metadata.AliasMetadata; import org.elasticsearch.cluster.metadata.IndexMetadata; +import org.elasticsearch.cluster.metadata.IndexTemplateV2; import org.elasticsearch.cluster.metadata.MappingMetadata; +import org.elasticsearch.cluster.metadata.Template; import org.elasticsearch.common.Strings; import org.elasticsearch.common.bytes.BytesArray; +import org.elasticsearch.common.compress.CompressedXContent; import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.ByteSizeUnit; @@ -1560,4 +1568,54 @@ public void testDeleteAlias() throws IOException { assertThat(aliasExists(index, alias), equalTo(false)); assertThat(aliasExists(index, alias2), equalTo(true)); } + + //{"index_patterns":["pattern"],"template":{"settings":{"index":{"number_of_shards":"1"}},"mappings":{"properties":{"host_name":{"type":"keyword"}}},"aliases":{"alias":{"is_write_index":true}}},"priority":1,"version":1,"_meta":{}}> + //{"index_patterns":["pattern"],"template":{"settings":{"index":{"number_of_shards":"1"}},"mappings":{"properties":{"host_name":{"type":"keyword"}}},"aliases":{"alias":{"is_write_index":true}}},"composed_of":[],"priority":1,"version":1,"_meta":{}}> + + + public void testIndexTemplates() throws Exception { + String templateName = "my-template"; + Settings settings = Settings.builder().put("index.number_of_shards", 1).build(); + CompressedXContent mappings = new CompressedXContent("{\"properties\":{\"host_name\":{\"type\":\"keyword\"}}}"); + AliasMetadata alias = AliasMetadata.builder("alias").writeIndex(true).build(); + Template template = new Template(settings, mappings, Map.of("alias", alias)); + List pattern = List.of("pattern"); + IndexTemplateV2 indexTemplate = new IndexTemplateV2(pattern, template, Collections.emptyList(), 1L, 1L, new HashMap<>()); + PutIndexTemplateV2Request putIndexTemplateV2Request = + new PutIndexTemplateV2Request().name(templateName).create(true).indexTemplate(indexTemplate); + + AcknowledgedResponse response = execute(putIndexTemplateV2Request, + highLevelClient().indices()::putIndexTemplate, highLevelClient().indices()::putIndexTemplateAsync); + assertThat(response.isAcknowledged(), equalTo(true)); + + IndexTemplateV2ExistRequest indexTemplateV2ExistRequest = new IndexTemplateV2ExistRequest(templateName); + boolean exist = execute(indexTemplateV2ExistRequest, + highLevelClient().indices()::existsIndexTemplate, highLevelClient().indices()::existsIndexTemplateAsync); + + assertTrue(exist); + + GetIndexTemplatesV2Request getIndexTemplatesV2Request = new GetIndexTemplatesV2Request(templateName); + GetIndexTemplatesV2Response getResponse = execute(getIndexTemplatesV2Request, + highLevelClient().indices()::getIndexTemplate, highLevelClient().indices()::getIndexTemplateAsync); + + assertThat(getResponse.getIndexTemplates().size(), equalTo(1)); + assertThat(getResponse.getIndexTemplates().containsKey(templateName), equalTo(true)); + assertThat(getResponse.getIndexTemplates().get(templateName), equalTo(indexTemplate)); + + DeleteIndexTemplateV2Request deleteIndexTemplateV2Request = new DeleteIndexTemplateV2Request(templateName); + response = execute(deleteIndexTemplateV2Request, highLevelClient().indices()::deleteIndexTemplate, + highLevelClient().indices()::deleteIndexTemplateAsync); + assertThat(response.isAcknowledged(), equalTo(true)); + + ElasticsearchStatusException statusException = expectThrows(ElasticsearchStatusException.class, + () -> execute(getIndexTemplatesV2Request, + highLevelClient().indices()::getIndexTemplate, highLevelClient().indices()::getIndexTemplateAsync)); + + assertThat(statusException.status(), equalTo(RestStatus.NOT_FOUND)); + + exist = exist = execute(indexTemplateV2ExistRequest, + highLevelClient().indices()::existsIndexTemplate, highLevelClient().indices()::existsIndexTemplateAsync); + + assertFalse(exist); + } } diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/RestHighLevelClientTests.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/RestHighLevelClientTests.java index 0c01163755a60..b067bd20c731c 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/RestHighLevelClientTests.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/RestHighLevelClientTests.java @@ -861,8 +861,6 @@ public void testApiNamingConventions() throws Exception { "indices.create_data_stream", "indices.get_data_streams", "indices.delete_data_stream", - "indices.put_index_template", - "indices.delete_index_template" }; //These API are not required for high-level client feature completeness String[] notRequiredApi = new String[] { diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/indices/GetIndexTemplatesV2ResponseTests.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/indices/GetIndexTemplatesV2ResponseTests.java new file mode 100644 index 0000000000000..ec1dac6a74c95 --- /dev/null +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/indices/GetIndexTemplatesV2ResponseTests.java @@ -0,0 +1,141 @@ +/* + * Licensed to Elasticsearch under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.elasticsearch.client.indices; + +import org.elasticsearch.cluster.metadata.AliasMetadata; +import org.elasticsearch.cluster.metadata.IndexTemplateV2; +import org.elasticsearch.cluster.metadata.Template; +import org.elasticsearch.common.compress.CompressedXContent; +import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.common.xcontent.XContentBuilder; +import org.elasticsearch.test.ESTestCase; + +import java.io.IOException; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static org.elasticsearch.test.AbstractXContentTestCase.xContentTester; + +public class GetIndexTemplatesV2ResponseTests extends ESTestCase { + + public void testFromXContent() throws Exception { + xContentTester( + this::createParser, + GetIndexTemplatesV2ResponseTests::createTestInstance, + GetIndexTemplatesV2ResponseTests::toXContent, + GetIndexTemplatesV2Response::fromXContent) + .supportsUnknownFields(true) + .randomFieldsExcludeFilter(a -> true) + .test(); + } + + private static GetIndexTemplatesV2Response createTestInstance() { + Map templates = new HashMap<>(); + if (randomBoolean()) { + int count = randomInt(10); + for (int i = 0; i < count; i++) { + templates.put(randomAlphaOfLength(10), randomTemplate()); + } + } + return new GetIndexTemplatesV2Response(templates); + } + + private static void toXContent(GetIndexTemplatesV2Response response, XContentBuilder builder) throws IOException { + builder.startObject(); + builder.startArray("index_templates"); + for (Map.Entry e : response.getIndexTemplates().entrySet()) { + builder.startObject(); + builder.field("name", e.getKey()); + builder.field("index_template"); + e.getValue().toXContent(builder, null); + builder.endObject(); + } + builder.endArray(); + builder.endObject(); + } + + private static IndexTemplateV2 randomTemplate() { + Settings settings = null; + CompressedXContent mappings = null; + Map aliases = null; + List patterns = Arrays.asList(generateRandomStringArray(10, 10, false, false)); + List composedOf = null; + if (randomBoolean()) { + settings = randomSettings(); + } + if (randomBoolean()) { + mappings = randomMappings(); + } + if (randomBoolean()) { + aliases = randomAliases(); + } + if (randomBoolean()) { + composedOf = Arrays.asList(generateRandomStringArray(10, 10, false, false)); + } + Template template = new Template(settings, mappings, aliases); + + Map meta = null; + if (randomBoolean()) { + meta = randomMeta(); + } + + Long priority = randomBoolean() ? null : randomNonNegativeLong(); + Long version = randomBoolean() ? null : randomNonNegativeLong(); + return new IndexTemplateV2(patterns, template, composedOf, priority, version, meta); + } + + private static Map randomAliases() { + String aliasName = randomAlphaOfLength(5); + AliasMetadata aliasMeta = AliasMetadata.builder(aliasName) + .filter(Collections.singletonMap(randomAlphaOfLength(2), randomAlphaOfLength(2))) + .routing(randomBoolean() ? null : randomAlphaOfLength(3)) + .isHidden(randomBoolean() ? null : randomBoolean()) + .writeIndex(randomBoolean() ? null : randomBoolean()) + .build(); + return Collections.singletonMap(aliasName, aliasMeta); + } + + private static CompressedXContent randomMappings() { + try { + return new CompressedXContent("{\"" + randomAlphaOfLength(3) + "\":\"" + randomAlphaOfLength(7) + "\"}"); + } catch (IOException e) { + fail("got an IO exception creating fake mappings: " + e); + return null; + } + } + + private static Settings randomSettings() { + return Settings.builder() + .put(randomAlphaOfLength(4), randomAlphaOfLength(10)) + .build(); + } + + private static Map randomMeta() { + if (randomBoolean()) { + return Collections.singletonMap(randomAlphaOfLength(4), randomAlphaOfLength(4)); + } else { + return Collections.singletonMap(randomAlphaOfLength(5), + Collections.singletonMap(randomAlphaOfLength(4), randomAlphaOfLength(4))); + } + } +} diff --git a/rest-api-spec/src/main/resources/rest-api-spec/api/indices.exists_index_template.json b/rest-api-spec/src/main/resources/rest-api-spec/api/indices.exists_index_template.json new file mode 100644 index 0000000000000..99471c50deef2 --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/api/indices.exists_index_template.json @@ -0,0 +1,39 @@ +{ + "indices.exists_index_template":{ + "documentation":{ + "url":"https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html", + "description":"Returns information about whether a particular index template exists." + }, + "stability":"stable", + "url":{ + "paths":[ + { + "path":"/_index_template/{name}", + "methods":[ + "HEAD" + ], + "parts":{ + "name":{ + "type":"string", + "description":"The name of the template" + } + } + } + ] + }, + "params":{ + "flat_settings":{ + "type":"boolean", + "description":"Return settings in flat format (default: false)" + }, + "master_timeout":{ + "type":"time", + "description":"Explicit operation timeout for connection to master node" + }, + "local":{ + "type":"boolean", + "description":"Return local information, do not retrieve the state from master node (default: false)" + } + } + } +} diff --git a/server/src/main/java/org/elasticsearch/cluster/metadata/IndexTemplateV2.java b/server/src/main/java/org/elasticsearch/cluster/metadata/IndexTemplateV2.java index 06394a3a1c4d4..0b5a68c14ad3a 100644 --- a/server/src/main/java/org/elasticsearch/cluster/metadata/IndexTemplateV2.java +++ b/server/src/main/java/org/elasticsearch/cluster/metadata/IndexTemplateV2.java @@ -50,7 +50,7 @@ public class IndexTemplateV2 extends AbstractDiffable implement private static final ParseField METADATA = new ParseField("_meta"); @SuppressWarnings("unchecked") - private static final ConstructingObjectParser PARSER = new ConstructingObjectParser<>("index_template", false, + public static final ConstructingObjectParser PARSER = new ConstructingObjectParser<>("index_template", false, a -> new IndexTemplateV2((List) a[0], (Template) a[1], (List) a[2], From 7f9dcbe2aafb4af9b4a8d4f4fe1e06316f3194fc Mon Sep 17 00:00:00 2001 From: Przemko Robakowski Date: Mon, 6 Apr 2020 21:22:33 +0200 Subject: [PATCH 02/16] remove debug comment --- .../test/java/org/elasticsearch/client/IndicesClientIT.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/IndicesClientIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/IndicesClientIT.java index 27beba134e83c..a226535b33250 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/IndicesClientIT.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/IndicesClientIT.java @@ -1568,11 +1568,7 @@ public void testDeleteAlias() throws IOException { assertThat(aliasExists(index, alias), equalTo(false)); assertThat(aliasExists(index, alias2), equalTo(true)); } - - //{"index_patterns":["pattern"],"template":{"settings":{"index":{"number_of_shards":"1"}},"mappings":{"properties":{"host_name":{"type":"keyword"}}},"aliases":{"alias":{"is_write_index":true}}},"priority":1,"version":1,"_meta":{}}> - //{"index_patterns":["pattern"],"template":{"settings":{"index":{"number_of_shards":"1"}},"mappings":{"properties":{"host_name":{"type":"keyword"}}},"aliases":{"alias":{"is_write_index":true}}},"composed_of":[],"priority":1,"version":1,"_meta":{}}> - - + public void testIndexTemplates() throws Exception { String templateName = "my-template"; Settings settings = Settings.builder().put("index.number_of_shards", 1).build(); From 38dd892eab2b36e18718ca6b9e0569ab07cd9aef Mon Sep 17 00:00:00 2001 From: Przemko Robakowski Date: Tue, 7 Apr 2020 22:36:35 +0200 Subject: [PATCH 03/16] Update client/rest-high-level/src/main/java/org/elasticsearch/client/indices/IndexTemplateV2ExistRequest.java Co-Authored-By: Lee Hinman --- .../client/indices/IndexTemplateV2ExistRequest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/IndexTemplateV2ExistRequest.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/IndexTemplateV2ExistRequest.java index f631ea5525f84..69717d0a408ce 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/IndexTemplateV2ExistRequest.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/IndexTemplateV2ExistRequest.java @@ -34,7 +34,7 @@ public class IndexTemplateV2ExistRequest extends GetComponentTemplatesRequest { public IndexTemplateV2ExistRequest(String name) { super(name); if (Strings.isNullOrEmpty(name)) { - throw new IllegalArgumentException("must provide component template name"); + throw new IllegalArgumentException("must provide index template name"); } } } From a1f765b659f42594fb7a3c7d49bbdc850824c206 Mon Sep 17 00:00:00 2001 From: Przemko Robakowski Date: Tue, 7 Apr 2020 22:36:49 +0200 Subject: [PATCH 04/16] Update client/rest-high-level/src/main/java/org/elasticsearch/client/indices/PutIndexTemplateV2Request.java Co-Authored-By: Lee Hinman --- .../elasticsearch/client/indices/PutIndexTemplateV2Request.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/PutIndexTemplateV2Request.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/PutIndexTemplateV2Request.java index 95cdfee00d578..83ce9461eaa11 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/PutIndexTemplateV2Request.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/PutIndexTemplateV2Request.java @@ -71,7 +71,7 @@ public boolean create() { } /** - * The component template to create. + * The index template to create. */ public PutIndexTemplateV2Request indexTemplate(IndexTemplateV2 indexTemplate) { this.indexTemplate = indexTemplate; From 14443a1b0c1f1befadaf49e97e55a7ee9cd9b8b4 Mon Sep 17 00:00:00 2001 From: Przemko Robakowski Date: Tue, 7 Apr 2020 22:36:55 +0200 Subject: [PATCH 05/16] Update client/rest-high-level/src/main/java/org/elasticsearch/client/indices/PutIndexTemplateV2Request.java Co-Authored-By: Lee Hinman --- .../elasticsearch/client/indices/PutIndexTemplateV2Request.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/PutIndexTemplateV2Request.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/PutIndexTemplateV2Request.java index 83ce9461eaa11..1ce284488996a 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/PutIndexTemplateV2Request.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/PutIndexTemplateV2Request.java @@ -79,7 +79,7 @@ public PutIndexTemplateV2Request indexTemplate(IndexTemplateV2 indexTemplate) { } /** - * The cause for this component template creation. + * The cause for this index template creation. */ public PutIndexTemplateV2Request cause(String cause) { this.cause = cause; From 4ab09b38df0b0f392d957310b2076814e0a1d2e1 Mon Sep 17 00:00:00 2001 From: Przemko Robakowski Date: Tue, 7 Apr 2020 22:37:46 +0200 Subject: [PATCH 06/16] Update client/rest-high-level/src/test/java/org/elasticsearch/client/IndicesClientIT.java Co-Authored-By: Lee Hinman --- .../src/test/java/org/elasticsearch/client/IndicesClientIT.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/IndicesClientIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/IndicesClientIT.java index a226535b33250..71f47e28c6067 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/IndicesClientIT.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/IndicesClientIT.java @@ -1609,7 +1609,7 @@ public void testIndexTemplates() throws Exception { assertThat(statusException.status(), equalTo(RestStatus.NOT_FOUND)); - exist = exist = execute(indexTemplateV2ExistRequest, + exist = execute(indexTemplateV2ExistRequest, highLevelClient().indices()::existsIndexTemplate, highLevelClient().indices()::existsIndexTemplateAsync); assertFalse(exist); From 812d06c0fedf80c49da547cb1c24924be301e4b2 Mon Sep 17 00:00:00 2001 From: Przemko Robakowski Date: Tue, 7 Apr 2020 22:38:35 +0200 Subject: [PATCH 07/16] Update client/rest-high-level/src/main/java/org/elasticsearch/client/indices/GetIndexTemplatesV2Request.java Co-Authored-By: Lee Hinman --- .../client/indices/GetIndexTemplatesV2Request.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/GetIndexTemplatesV2Request.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/GetIndexTemplatesV2Request.java index 0d606535d9328..582469ccbb4af 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/GetIndexTemplatesV2Request.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/GetIndexTemplatesV2Request.java @@ -25,7 +25,7 @@ import org.elasticsearch.common.unit.TimeValue; /** - * A request to read the content of component templates + * A request to read the content of index templates */ public class GetIndexTemplatesV2Request implements Validatable { From a3d08372c7b78c8bf399742e3c446e67f2cb6ce3 Mon Sep 17 00:00:00 2001 From: Przemko Robakowski Date: Tue, 7 Apr 2020 22:51:12 +0200 Subject: [PATCH 08/16] review comments --- .../elasticsearch/client/IndicesClient.java | 16 ++--- .../client/IndicesRequestConverters.java | 4 +- ...st.java => GetIndexTemplateV2Request.java} | 4 +- .../elasticsearch/client/IndicesClientIT.java | 10 +-- .../GetComponentTemplatesResponseTests.java | 52 ++++++++------- .../GetIndexTemplatesV2ResponseTests.java | 64 ++----------------- 6 files changed, 51 insertions(+), 99 deletions(-) rename client/rest-high-level/src/main/java/org/elasticsearch/client/indices/{GetIndexTemplatesV2Request.java => GetIndexTemplateV2Request.java} (95%) diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/IndicesClient.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/IndicesClient.java index da42c3bf9050d..4adfdbf36f73f 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/IndicesClient.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/IndicesClient.java @@ -56,7 +56,7 @@ import org.elasticsearch.client.indices.GetIndexResponse; import org.elasticsearch.client.indices.GetIndexTemplatesRequest; import org.elasticsearch.client.indices.GetIndexTemplatesResponse; -import org.elasticsearch.client.indices.GetIndexTemplatesV2Request; +import org.elasticsearch.client.indices.GetIndexTemplateV2Request; import org.elasticsearch.client.indices.GetIndexTemplatesV2Response; import org.elasticsearch.client.indices.GetMappingsRequest; import org.elasticsearch.client.indices.GetMappingsResponse; @@ -939,7 +939,7 @@ public AcknowledgedResponse putIndexTemplate(PutIndexTemplateV2Request putIndexT * @return cancellable that may be used to cancel the request */ public Cancellable putIndexTemplateAsync(PutIndexTemplateV2Request putIndexTemplateRequest, - RequestOptions options, ActionListener listener) { + RequestOptions options, ActionListener listener) { return restHighLevelClient.performRequestAsyncAndParseEntity(putIndexTemplateRequest, IndicesRequestConverters::putIndexTemplate, options, AcknowledgedResponse::fromXContent, listener, emptySet()); } @@ -987,7 +987,7 @@ public Cancellable validateQueryAsync(ValidateQueryRequest validateQueryRequest, * @return the response * @throws IOException in case there is a problem sending the request or parsing back the response */ - public GetIndexTemplatesV2Response getIndexTemplate(GetIndexTemplatesV2Request getIndexTemplatesRequest, + public GetIndexTemplatesV2Response getIndexTemplate(GetIndexTemplateV2Request getIndexTemplatesRequest, RequestOptions options) throws IOException { return restHighLevelClient.performRequestAndParseEntity(getIndexTemplatesRequest, IndicesRequestConverters::getIndexTemplates, options, GetIndexTemplatesV2Response::fromXContent, emptySet()); @@ -1002,7 +1002,7 @@ public GetIndexTemplatesV2Response getIndexTemplate(GetIndexTemplatesV2Request g * @param listener the listener to be notified upon request completion * @return cancellable that may be used to cancel the request */ - public Cancellable getIndexTemplateAsync(GetIndexTemplatesV2Request getIndexTemplatesRequest, RequestOptions options, + public Cancellable getIndexTemplateAsync(GetIndexTemplateV2Request getIndexTemplatesRequest, RequestOptions options, ActionListener listener) { return restHighLevelClient.performRequestAsyncAndParseEntity(getIndexTemplatesRequest, IndicesRequestConverters::getIndexTemplates, options, GetIndexTemplatesV2Response::fromXContent, listener, emptySet()); @@ -1080,7 +1080,7 @@ public Cancellable existsTemplateAsync(IndexTemplatesExistRequest indexTemplates * @throws IOException in case there is a problem sending the request or parsing back the response */ public boolean existsIndexTemplate(IndexTemplateV2ExistRequest indexTemplatesRequest, - RequestOptions options) throws IOException { + RequestOptions options) throws IOException { return restHighLevelClient.performRequest(indexTemplatesRequest, IndicesRequestConverters::templatesExist, options, RestHighLevelClient::convertExistsResponse, emptySet()); @@ -1094,8 +1094,8 @@ public boolean existsIndexTemplate(IndexTemplateV2ExistRequest indexTemplatesReq * @return cancellable that may be used to cancel the request */ public Cancellable existsIndexTemplateAsync(IndexTemplateV2ExistRequest indexTemplatesExistRequest, - RequestOptions options, - ActionListener listener) { + RequestOptions options, + ActionListener listener) { return restHighLevelClient.performRequestAsync(indexTemplatesExistRequest, IndicesRequestConverters::templatesExist, options, @@ -1232,7 +1232,7 @@ public AcknowledgedResponse deleteIndexTemplate(DeleteIndexTemplateV2Request req * @return cancellable that may be used to cancel the request */ public Cancellable deleteIndexTemplateAsync(DeleteIndexTemplateV2Request request, RequestOptions options, - ActionListener listener) { + ActionListener listener) { return restHighLevelClient.performRequestAsyncAndParseEntity(request, IndicesRequestConverters::deleteIndexTemplate, options, AcknowledgedResponse::fromXContent, listener, emptySet()); } diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/IndicesRequestConverters.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/IndicesRequestConverters.java index eb29320cf097e..ffa2fc1a3f523 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/IndicesRequestConverters.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/IndicesRequestConverters.java @@ -46,7 +46,7 @@ import org.elasticsearch.client.indices.GetFieldMappingsRequest; import org.elasticsearch.client.indices.GetIndexRequest; import org.elasticsearch.client.indices.GetIndexTemplatesRequest; -import org.elasticsearch.client.indices.GetIndexTemplatesV2Request; +import org.elasticsearch.client.indices.GetIndexTemplateV2Request; import org.elasticsearch.client.indices.GetMappingsRequest; import org.elasticsearch.client.indices.IndexTemplateV2ExistRequest; import org.elasticsearch.client.indices.IndexTemplatesExistRequest; @@ -463,7 +463,7 @@ static Request getTemplates(GetIndexTemplatesRequest getIndexTemplatesRequest) { return request; } - static Request getIndexTemplates(GetIndexTemplatesV2Request getIndexTemplatesRequest) { + static Request getIndexTemplates(GetIndexTemplateV2Request getIndexTemplatesRequest) { final String endpoint = new RequestConverters.EndpointBuilder() .addPathPartAsIs("_index_template") .addPathPart(getIndexTemplatesRequest.name()) diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/GetIndexTemplatesV2Request.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/GetIndexTemplateV2Request.java similarity index 95% rename from client/rest-high-level/src/main/java/org/elasticsearch/client/indices/GetIndexTemplatesV2Request.java rename to client/rest-high-level/src/main/java/org/elasticsearch/client/indices/GetIndexTemplateV2Request.java index 582469ccbb4af..27efe516c1351 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/GetIndexTemplatesV2Request.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/GetIndexTemplateV2Request.java @@ -27,7 +27,7 @@ /** * A request to read the content of index templates */ -public class GetIndexTemplatesV2Request implements Validatable { +public class GetIndexTemplateV2Request implements Validatable { private final String name; @@ -40,7 +40,7 @@ public class GetIndexTemplatesV2Request implements Validatable { * * @param name the name of template to read */ - public GetIndexTemplatesV2Request(String name) { + public GetIndexTemplateV2Request(String name) { this.name = name; } diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/IndicesClientIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/IndicesClientIT.java index 71f47e28c6067..66d7174d04053 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/IndicesClientIT.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/IndicesClientIT.java @@ -69,7 +69,7 @@ import org.elasticsearch.client.indices.GetIndexResponse; import org.elasticsearch.client.indices.GetIndexTemplatesRequest; import org.elasticsearch.client.indices.GetIndexTemplatesResponse; -import org.elasticsearch.client.indices.GetIndexTemplatesV2Request; +import org.elasticsearch.client.indices.GetIndexTemplateV2Request; import org.elasticsearch.client.indices.GetIndexTemplatesV2Response; import org.elasticsearch.client.indices.GetMappingsRequest; import org.elasticsearch.client.indices.GetMappingsResponse; @@ -1568,7 +1568,7 @@ public void testDeleteAlias() throws IOException { assertThat(aliasExists(index, alias), equalTo(false)); assertThat(aliasExists(index, alias2), equalTo(true)); } - + public void testIndexTemplates() throws Exception { String templateName = "my-template"; Settings settings = Settings.builder().put("index.number_of_shards", 1).build(); @@ -1590,8 +1590,8 @@ public void testIndexTemplates() throws Exception { assertTrue(exist); - GetIndexTemplatesV2Request getIndexTemplatesV2Request = new GetIndexTemplatesV2Request(templateName); - GetIndexTemplatesV2Response getResponse = execute(getIndexTemplatesV2Request, + GetIndexTemplateV2Request getIndexTemplateV2Request = new GetIndexTemplateV2Request(templateName); + GetIndexTemplatesV2Response getResponse = execute(getIndexTemplateV2Request, highLevelClient().indices()::getIndexTemplate, highLevelClient().indices()::getIndexTemplateAsync); assertThat(getResponse.getIndexTemplates().size(), equalTo(1)); @@ -1604,7 +1604,7 @@ public void testIndexTemplates() throws Exception { assertThat(response.isAcknowledged(), equalTo(true)); ElasticsearchStatusException statusException = expectThrows(ElasticsearchStatusException.class, - () -> execute(getIndexTemplatesV2Request, + () -> execute(getIndexTemplateV2Request, highLevelClient().indices()::getIndexTemplate, highLevelClient().indices()::getIndexTemplateAsync)); assertThat(statusException.status(), equalTo(RestStatus.NOT_FOUND)); diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/indices/GetComponentTemplatesResponseTests.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/indices/GetComponentTemplatesResponseTests.java index 1f4acce23a61e..ca3a5fcf8eec1 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/indices/GetComponentTemplatesResponseTests.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/indices/GetComponentTemplatesResponseTests.java @@ -47,12 +47,37 @@ public void testFromXContent() throws Exception { .test(); } + public static Template randomTemplate() { + Settings settings = null; + CompressedXContent mappings = null; + Map aliases = null; + if (randomBoolean()) { + settings = randomSettings(); + } + if (randomBoolean()) { + mappings = randomMappings(); + } + if (randomBoolean()) { + aliases = randomAliases(); + } + return new Template(settings, mappings, aliases); + } + + public static Map randomMeta() { + if (randomBoolean()) { + return Collections.singletonMap(randomAlphaOfLength(4), randomAlphaOfLength(4)); + } else { + return Collections.singletonMap(randomAlphaOfLength(5), + Collections.singletonMap(randomAlphaOfLength(4), randomAlphaOfLength(4))); + } + } + private static GetComponentTemplatesResponse createTestInstance() { Map templates = new HashMap<>(); if (randomBoolean()) { int count = randomInt(10); for (int i = 0; i < count; i++) { - templates.put(randomAlphaOfLength(10), randomTemplate()); + templates.put(randomAlphaOfLength(10), randomComponentTemplate()); } } return new GetComponentTemplatesResponse(templates); @@ -72,20 +97,8 @@ private static void toXContent(GetComponentTemplatesResponse response, XContentB builder.endObject(); } - private static ComponentTemplate randomTemplate() { - Settings settings = null; - CompressedXContent mappings = null; - Map aliases = null; - if (randomBoolean()) { - settings = randomSettings(); - } - if (randomBoolean()) { - mappings = randomMappings(); - } - if (randomBoolean()) { - aliases = randomAliases(); - } - Template template = new Template(settings, mappings, aliases); + private static ComponentTemplate randomComponentTemplate() { + Template template = randomTemplate(); Map meta = null; if (randomBoolean()) { @@ -119,13 +132,4 @@ private static Settings randomSettings() { .put(randomAlphaOfLength(4), randomAlphaOfLength(10)) .build(); } - - private static Map randomMeta() { - if (randomBoolean()) { - return Collections.singletonMap(randomAlphaOfLength(4), randomAlphaOfLength(4)); - } else { - return Collections.singletonMap(randomAlphaOfLength(5), - Collections.singletonMap(randomAlphaOfLength(4), randomAlphaOfLength(4))); - } - } } diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/indices/GetIndexTemplatesV2ResponseTests.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/indices/GetIndexTemplatesV2ResponseTests.java index ec1dac6a74c95..f5977cf69012c 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/indices/GetIndexTemplatesV2ResponseTests.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/indices/GetIndexTemplatesV2ResponseTests.java @@ -19,21 +19,18 @@ package org.elasticsearch.client.indices; -import org.elasticsearch.cluster.metadata.AliasMetadata; import org.elasticsearch.cluster.metadata.IndexTemplateV2; -import org.elasticsearch.cluster.metadata.Template; -import org.elasticsearch.common.compress.CompressedXContent; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.test.ESTestCase; import java.io.IOException; import java.util.Arrays; -import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; +import static org.elasticsearch.client.indices.GetComponentTemplatesResponseTests.randomMeta; +import static org.elasticsearch.client.indices.GetComponentTemplatesResponseTests.randomTemplate; import static org.elasticsearch.test.AbstractXContentTestCase.xContentTester; public class GetIndexTemplatesV2ResponseTests extends ESTestCase { @@ -54,7 +51,7 @@ private static GetIndexTemplatesV2Response createTestInstance() { if (randomBoolean()) { int count = randomInt(10); for (int i = 0; i < count; i++) { - templates.put(randomAlphaOfLength(10), randomTemplate()); + templates.put(randomAlphaOfLength(10), randomIndexTemplate()); } } return new GetIndexTemplatesV2Response(templates); @@ -74,68 +71,19 @@ private static void toXContent(GetIndexTemplatesV2Response response, XContentBui builder.endObject(); } - private static IndexTemplateV2 randomTemplate() { - Settings settings = null; - CompressedXContent mappings = null; - Map aliases = null; + private static IndexTemplateV2 randomIndexTemplate() { List patterns = Arrays.asList(generateRandomStringArray(10, 10, false, false)); List composedOf = null; - if (randomBoolean()) { - settings = randomSettings(); - } - if (randomBoolean()) { - mappings = randomMappings(); - } - if (randomBoolean()) { - aliases = randomAliases(); - } + Map meta = null; if (randomBoolean()) { composedOf = Arrays.asList(generateRandomStringArray(10, 10, false, false)); } - Template template = new Template(settings, mappings, aliases); - - Map meta = null; if (randomBoolean()) { meta = randomMeta(); } Long priority = randomBoolean() ? null : randomNonNegativeLong(); Long version = randomBoolean() ? null : randomNonNegativeLong(); - return new IndexTemplateV2(patterns, template, composedOf, priority, version, meta); - } - - private static Map randomAliases() { - String aliasName = randomAlphaOfLength(5); - AliasMetadata aliasMeta = AliasMetadata.builder(aliasName) - .filter(Collections.singletonMap(randomAlphaOfLength(2), randomAlphaOfLength(2))) - .routing(randomBoolean() ? null : randomAlphaOfLength(3)) - .isHidden(randomBoolean() ? null : randomBoolean()) - .writeIndex(randomBoolean() ? null : randomBoolean()) - .build(); - return Collections.singletonMap(aliasName, aliasMeta); - } - - private static CompressedXContent randomMappings() { - try { - return new CompressedXContent("{\"" + randomAlphaOfLength(3) + "\":\"" + randomAlphaOfLength(7) + "\"}"); - } catch (IOException e) { - fail("got an IO exception creating fake mappings: " + e); - return null; - } - } - - private static Settings randomSettings() { - return Settings.builder() - .put(randomAlphaOfLength(4), randomAlphaOfLength(10)) - .build(); - } - - private static Map randomMeta() { - if (randomBoolean()) { - return Collections.singletonMap(randomAlphaOfLength(4), randomAlphaOfLength(4)); - } else { - return Collections.singletonMap(randomAlphaOfLength(5), - Collections.singletonMap(randomAlphaOfLength(4), randomAlphaOfLength(4))); - } + return new IndexTemplateV2(patterns, randomTemplate(), composedOf, priority, version, meta); } } From 7b26fb141311834b252e371127b1fa72d115d4fe Mon Sep 17 00:00:00 2001 From: Przemko Robakowski Date: Tue, 7 Apr 2020 22:57:31 +0200 Subject: [PATCH 09/16] review comments --- .../elasticsearch/client/indices/GetIndexTemplateV2Request.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/GetIndexTemplateV2Request.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/GetIndexTemplateV2Request.java index 27efe516c1351..a7a8f4ac04c44 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/GetIndexTemplateV2Request.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/GetIndexTemplateV2Request.java @@ -35,7 +35,7 @@ public class GetIndexTemplateV2Request implements Validatable { private boolean local = false; /** - * Create a request to read the content of component template. If no template name is provided, all templates will + * Create a request to read the content of index template. If no template name is provided, all templates will * be read * * @param name the name of template to read From ec4fdf3104c2f04a2ce2eaa33a25b6b2a819a78f Mon Sep 17 00:00:00 2001 From: Przemko Robakowski Date: Tue, 7 Apr 2020 22:58:16 +0200 Subject: [PATCH 10/16] review comments --- .../elasticsearch/client/indices/GetIndexTemplateV2Request.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/GetIndexTemplateV2Request.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/GetIndexTemplateV2Request.java index a7a8f4ac04c44..0cc8e2af3a7e0 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/GetIndexTemplateV2Request.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/GetIndexTemplateV2Request.java @@ -45,7 +45,7 @@ public GetIndexTemplateV2Request(String name) { } /** - * @return the name of component template this request is requesting + * @return the name of index template this request is requesting */ public String name() { return name; From 15ad1d2a18c7e8ce7a900747729cc8f9005568bb Mon Sep 17 00:00:00 2001 From: Przemko Robakowski Date: Tue, 7 Apr 2020 23:03:21 +0200 Subject: [PATCH 11/16] Update client/rest-high-level/src/main/java/org/elasticsearch/client/indices/IndexTemplateV2ExistRequest.java Co-Authored-By: Lee Hinman --- .../client/indices/IndexTemplateV2ExistRequest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/IndexTemplateV2ExistRequest.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/IndexTemplateV2ExistRequest.java index 69717d0a408ce..289529d6c57be 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/IndexTemplateV2ExistRequest.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/IndexTemplateV2ExistRequest.java @@ -22,7 +22,7 @@ import org.elasticsearch.common.Strings; /** - * A request to check for the existence of component templates + * A request to check for the existence of index templates */ public class IndexTemplateV2ExistRequest extends GetComponentTemplatesRequest { From 8b562f987a21f6c038378c338f8db7bcec054212 Mon Sep 17 00:00:00 2001 From: Przemko Robakowski Date: Tue, 7 Apr 2020 23:03:43 +0200 Subject: [PATCH 12/16] Update client/rest-high-level/src/main/java/org/elasticsearch/client/indices/IndexTemplateV2ExistRequest.java Co-Authored-By: Lee Hinman --- .../client/indices/IndexTemplateV2ExistRequest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/IndexTemplateV2ExistRequest.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/IndexTemplateV2ExistRequest.java index 289529d6c57be..d803406b307f4 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/IndexTemplateV2ExistRequest.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/IndexTemplateV2ExistRequest.java @@ -27,7 +27,7 @@ public class IndexTemplateV2ExistRequest extends GetComponentTemplatesRequest { /** - * Create a request to check for the existence of component template. Name must be provided + * Create a request to check for the existence of index template. Name must be provided * * @param name the name of template to check for the existence of */ From 8e4d6a57397c5bc8c6412685d9f794e3284cdc61 Mon Sep 17 00:00:00 2001 From: Przemko Robakowski Date: Tue, 7 Apr 2020 23:04:18 +0200 Subject: [PATCH 13/16] Update client/rest-high-level/src/main/java/org/elasticsearch/client/indices/PutIndexTemplateV2Request.java Co-Authored-By: Lee Hinman --- .../elasticsearch/client/indices/PutIndexTemplateV2Request.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/PutIndexTemplateV2Request.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/PutIndexTemplateV2Request.java index 1ce284488996a..62905cffaddf6 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/PutIndexTemplateV2Request.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/PutIndexTemplateV2Request.java @@ -40,7 +40,7 @@ public class PutIndexTemplateV2Request extends TimedRequest implements ToXConten private IndexTemplateV2 indexTemplate; /** - * Sets the name of the component template. + * Sets the name of the index template. */ public PutIndexTemplateV2Request name(String name) { if (Strings.isNullOrEmpty(name)) { From 1bcf1dce8cfea14a9f6cf928d818dd2626269162 Mon Sep 17 00:00:00 2001 From: Przemko Robakowski Date: Tue, 7 Apr 2020 23:04:32 +0200 Subject: [PATCH 14/16] Update client/rest-high-level/src/main/java/org/elasticsearch/client/indices/PutIndexTemplateV2Request.java Co-Authored-By: Lee Hinman --- .../elasticsearch/client/indices/PutIndexTemplateV2Request.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/PutIndexTemplateV2Request.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/PutIndexTemplateV2Request.java index 62905cffaddf6..fb7f0fec9c66a 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/PutIndexTemplateV2Request.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/PutIndexTemplateV2Request.java @@ -27,7 +27,7 @@ import java.io.IOException; /** - * A request to create an component template. + * A request to create an index template. */ public class PutIndexTemplateV2Request extends TimedRequest implements ToXContentObject { From d4364591b0141f747e27708d145a022daf0450c8 Mon Sep 17 00:00:00 2001 From: Przemko Robakowski Date: Tue, 7 Apr 2020 23:05:04 +0200 Subject: [PATCH 15/16] Update client/rest-high-level/src/main/java/org/elasticsearch/client/indices/PutIndexTemplateV2Request.java Co-Authored-By: Lee Hinman --- .../elasticsearch/client/indices/PutIndexTemplateV2Request.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/PutIndexTemplateV2Request.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/PutIndexTemplateV2Request.java index fb7f0fec9c66a..16e7d398fbd3b 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/PutIndexTemplateV2Request.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/PutIndexTemplateV2Request.java @@ -51,7 +51,7 @@ public PutIndexTemplateV2Request name(String name) { } /** - * The name of the component template. + * The name of the index template. */ public String name() { return this.name; From b54f1054abd208e75ee7f3ad16c370d2bd6b2e1c Mon Sep 17 00:00:00 2001 From: Przemko Robakowski Date: Tue, 7 Apr 2020 23:05:18 +0200 Subject: [PATCH 16/16] Update client/rest-high-level/src/main/java/org/elasticsearch/client/indices/PutIndexTemplateV2Request.java Co-Authored-By: Lee Hinman --- .../elasticsearch/client/indices/PutIndexTemplateV2Request.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/PutIndexTemplateV2Request.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/PutIndexTemplateV2Request.java index 16e7d398fbd3b..93c7db5eb014e 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/PutIndexTemplateV2Request.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/indices/PutIndexTemplateV2Request.java @@ -58,7 +58,7 @@ public String name() { } /** - * Set to {@code true} to force only creation, not an update of an component template. If it already + * Set to {@code true} to force only creation, not an update of an index template. If it already * exists, it will fail with an {@link IllegalArgumentException}. */ public PutIndexTemplateV2Request create(boolean create) {