From c7103d87423e44aa5ef57bb940496a6e3b74ff78 Mon Sep 17 00:00:00 2001 From: Thomas Farr Date: Fri, 15 Nov 2024 10:18:10 +1300 Subject: [PATCH] Generate basic index template operations (#1293) * Generate basic index template operations Generate indices.get_index_template Signed-off-by: Thomas Farr Generate indices.put_index_template Signed-off-by: Thomas Farr Generate indices.exists_index_template Signed-off-by: Thomas Farr Generate indices.delete_index_template Signed-off-by: Thomas Farr Generate indices.simulate_index_template Signed-off-by: Thomas Farr * Allow deserializing path params from JSON Signed-off-by: Thomas Farr * Fix compile Signed-off-by: Thomas Farr --------- Signed-off-by: Thomas Farr --- UPGRADING.md | 15 +- .../mapping/IcuCollationKeywordProperty.java | 92 ++++- .../indices/CreateIndexRequest.java | 1 + .../indices/DataStreamTimestampField.java | 83 ++-- .../indices/DeleteIndexTemplateRequest.java | 295 ++++++++++++++ .../indices/DeleteIndexTemplateResponse.java | 33 +- .../indices/ExistsIndexTemplateRequest.java | 237 +++++++---- .../indices/GetIndexTemplateRequest.java | 183 +++++---- .../indices/GetIndexTemplateResponse.java | 55 ++- .../opensearch/indices}/IndexTemplate.java | 340 +++++++++------- ...IndexTemplateDataStreamConfiguration.java} | 106 ++++- .../indices}/IndexTemplateSummary.java | 121 ++++-- .../OpenSearchIndicesAsyncClientBase.java | 112 ++++++ .../indices/OpenSearchIndicesClientBase.java | 108 +++++ .../indices/PutIndexTemplateRequest.java | 376 ++++++++++++++---- .../indices/PutIndexTemplateResponse.java | 31 +- .../indices/SimulateIndexTemplateRequest.java | 374 ++++++++++------- .../SimulateIndexTemplateResponse.java | 18 + .../get_index_template/IndexTemplateItem.java | 82 ++-- .../IndexTemplateMapping.java | 92 +++-- .../snapshot/CloneSnapshotRequest.java | 3 + .../indices/DeleteIndexTemplateRequest.java | 149 ------- .../indices/ExistsIndexTemplateResponse.java | 51 --- .../indices/OpenSearchIndicesAsyncClient.java | 186 --------- .../indices/OpenSearchIndicesClient.java | 182 --------- .../indices/SimulateTemplateRequest.java | 1 - .../transport/util/FunnellingHttpsProxy.java | 2 +- .../integTest/AbstractIndicesClientIT.java | 3 +- java-codegen/opensearch-openapi.yaml | 22 +- .../client/codegen/CodeGenerator.java | 15 +- .../client/codegen/model/ObjectShape.java | 14 +- .../client/codegen/model/RequestShape.java | 8 + .../codegen/templates/ObjectShape.mustache | 12 + .../ObjectShape/Deserialize.mustache | 4 +- .../templates/ObjectShape/Serialize.mustache | 4 +- .../codegen/templates/RequestShape.mustache | 18 +- .../client/samples/DataStreamBasics.java | 3 +- 37 files changed, 2127 insertions(+), 1304 deletions(-) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/indices/DataStreamTimestampField.java (54%) create mode 100644 java-client/src/generated/java/org/opensearch/client/opensearch/indices/DeleteIndexTemplateRequest.java rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/indices/DeleteIndexTemplateResponse.java (77%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/indices/ExistsIndexTemplateRequest.java (57%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/indices/GetIndexTemplateRequest.java (73%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/indices/GetIndexTemplateResponse.java (80%) rename java-client/src/{main/java/org/opensearch/client/opensearch/indices/get_index_template => generated/java/org/opensearch/client/opensearch/indices}/IndexTemplate.java (67%) rename java-client/src/{main/java/org/opensearch/client/opensearch/indices/DataStream.java => generated/java/org/opensearch/client/opensearch/indices/IndexTemplateDataStreamConfiguration.java} (55%) rename java-client/src/{main/java/org/opensearch/client/opensearch/indices/get_index_template => generated/java/org/opensearch/client/opensearch/indices}/IndexTemplateSummary.java (63%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/indices/PutIndexTemplateRequest.java (56%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/indices/PutIndexTemplateResponse.java (77%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/indices/SimulateIndexTemplateRequest.java (65%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/indices/SimulateIndexTemplateResponse.java (76%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/indices/get_index_template/IndexTemplateItem.java (80%) rename java-client/src/{main => generated}/java/org/opensearch/client/opensearch/indices/put_index_template/IndexTemplateMapping.java (71%) delete mode 100644 java-client/src/main/java/org/opensearch/client/opensearch/indices/DeleteIndexTemplateRequest.java delete mode 100644 java-client/src/main/java/org/opensearch/client/opensearch/indices/ExistsIndexTemplateResponse.java diff --git a/UPGRADING.md b/UPGRADING.md index 4e007d76d7..15925c7aab 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -82,4 +82,17 @@ After: - `PointProperty` has been removed and is replaced by `XyPointProperty`. ### PropertyBase -- The `name` and `localMetadata` fields, getters and builder methods have been removed from `PropertyBase` as they are not supported by OpenSearch. \ No newline at end of file +- The `name` and `localMetadata` fields, getters and builder methods have been removed from `PropertyBase` as they are not supported by OpenSearch. + +### IndexTemplate +- `IndexTemplate` has been moved from the `org.opensearch.client.opensearch.indices.get_index_template` package to the `org.opensearch.client.opensearch.indices` package. +- The `dataStream` property is now of type `IndexTemplateDataStreamConfiguration` instead of `Map`. + +### IndexTemplateSummary +- `IndexTemplateSummary` has been moved from the `org.opensearch.client.opensearch.indices.get_index_template` package to the `org.opensearch.client.opensearch.indices` package. +- The `settings` property is now of type `IndexSettings` instead of `Map`. + +### DataStream renamed to IndexTemplateDataStreamConfiguration +- The `DataStream` class has been renamed to `IndexTemplateDataStreamConfiguration`, this affects: + - `PutIndexTemplateRequest`'s `dataStream` field. + - `SimulateIndexTemplateRequest`'s `dataStream` field. diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/IcuCollationKeywordProperty.java b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/IcuCollationKeywordProperty.java index 3fd17b4084..7a6715cc8b 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/IcuCollationKeywordProperty.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/IcuCollationKeywordProperty.java @@ -67,6 +67,9 @@ public class IcuCollationKeywordProperty extends DocValuesPropertyBase implement @Nullable private final Boolean caseLevel; + @Nullable + private final String country; + @Nullable private final IcuCollationDecomposition decomposition; @@ -76,6 +79,9 @@ public class IcuCollationKeywordProperty extends DocValuesPropertyBase implement @Nullable private final Boolean index; + @Nullable + private final String language; + @Nullable private final String nullValue; @@ -88,6 +94,9 @@ public class IcuCollationKeywordProperty extends DocValuesPropertyBase implement @Nullable private final String variableTop; + @Nullable + private final String variant; + // --------------------------------------------------------------------------------------------- private IcuCollationKeywordProperty(Builder builder) { @@ -95,13 +104,16 @@ private IcuCollationKeywordProperty(Builder builder) { this.alternate = builder.alternate; this.caseFirst = builder.caseFirst; this.caseLevel = builder.caseLevel; + this.country = builder.country; this.decomposition = builder.decomposition; this.hiraganaQuaternaryMode = builder.hiraganaQuaternaryMode; this.index = builder.index; + this.language = builder.language; this.nullValue = builder.nullValue; this.numeric = builder.numeric; this.strength = builder.strength; this.variableTop = builder.variableTop; + this.variant = builder.variant; } public static IcuCollationKeywordProperty of( @@ -142,6 +154,14 @@ public final Boolean caseLevel() { return this.caseLevel; } + /** + * API name: {@code country} + */ + @Nullable + public final String country() { + return this.country; + } + /** * API name: {@code decomposition} */ @@ -166,6 +186,14 @@ public final Boolean index() { return this.index; } + /** + * API name: {@code language} + */ + @Nullable + public final String language() { + return this.language; + } + /** * API name: {@code null_value} */ @@ -198,6 +226,14 @@ public final String variableTop() { return this.variableTop; } + /** + * API name: {@code variant} + */ + @Nullable + public final String variant() { + return this.variant; + } + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.write("type", "icu_collation_keyword"); super.serializeInternal(generator, mapper); @@ -216,6 +252,11 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.write(this.caseLevel); } + if (this.country != null) { + generator.writeKey("country"); + generator.write(this.country); + } + if (this.decomposition != null) { generator.writeKey("decomposition"); this.decomposition.serialize(generator, mapper); @@ -231,6 +272,11 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.write(this.index); } + if (this.language != null) { + generator.writeKey("language"); + generator.write(this.language); + } + if (this.nullValue != null) { generator.writeKey("null_value"); generator.write(this.nullValue); @@ -250,6 +296,11 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeKey("variable_top"); generator.write(this.variableTop); } + + if (this.variant != null) { + generator.writeKey("variant"); + generator.write(this.variant); + } } // --------------------------------------------------------------------------------------------- @@ -267,12 +318,16 @@ public static class Builder extends DocValuesPropertyBase.AbstractBuilder op) { op.add(Builder::aliases, JsonpDeserializer.stringMapDeserializer(Alias._DESERIALIZER), "aliases"); + op.add(Builder::index, JsonpDeserializer.stringDeserializer(), "index"); op.add(Builder::mappings, TypeMapping._DESERIALIZER, "mappings"); op.add(Builder::settings, IndexSettings._DESERIALIZER, "settings"); } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/indices/DataStreamTimestampField.java b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/DataStreamTimestampField.java similarity index 54% rename from java-client/src/main/java/org/opensearch/client/opensearch/indices/DataStreamTimestampField.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/indices/DataStreamTimestampField.java index 7d015b5558..091eb86049 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/indices/DataStreamTimestampField.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/DataStreamTimestampField.java @@ -6,43 +6,73 @@ * compatible open source license. */ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. 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. + */ + +/* + * Modifications Copyright OpenSearch Contributors. See + * GitHub history for details. + */ + +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch.indices; import jakarta.json.stream.JsonGenerator; import java.util.function.Function; -import javax.annotation.Nullable; +import javax.annotation.Generated; +import javax.annotation.Nonnull; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.JsonpMapper; import org.opensearch.client.json.ObjectBuilderDeserializer; import org.opensearch.client.json.ObjectDeserializer; import org.opensearch.client.json.PlainJsonSerializable; +import org.opensearch.client.util.ApiTypeHelper; import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; -// typedef: indices._types.DataStreamTimestampField +// typedef: indices.DataStreamTimestampField @JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") public class DataStreamTimestampField implements PlainJsonSerializable { - @Nullable + + @Nonnull private final String name; // --------------------------------------------------------------------------------------------- private DataStreamTimestampField(Builder builder) { - - this.name = builder.name; - + this.name = ApiTypeHelper.requireNonNull(builder.name, this, "name"); } - public static DataStreamTimestampField of(Function> fn) { + public static DataStreamTimestampField of(Function> fn) { return fn.apply(new Builder()).build(); } /** - * API name: {@code name} + * Required - API name: {@code name} */ - @Nullable + @Nonnull public final String name() { return this.name; } @@ -50,6 +80,7 @@ public final String name() { /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -57,13 +88,8 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - - if (this.name != null) { - generator.writeKey("name"); - generator.write(this.name); - - } - + generator.writeKey("name"); + generator.write(this.name); } // --------------------------------------------------------------------------------------------- @@ -71,15 +97,13 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { /** * Builder for {@link DataStreamTimestampField}. */ - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - @Nullable private String name; /** - * API name: {@code name} + * Required - API name: {@code name} */ - public final Builder name(@Nullable String value) { + public final Builder name(String value) { this.name = value; return this; } @@ -87,8 +111,7 @@ public final Builder name(@Nullable String value) { /** * Builds a {@link DataStreamTimestampField}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ public DataStreamTimestampField build() { _checkSingleUse(); @@ -107,10 +130,22 @@ public DataStreamTimestampField build() { DataStreamTimestampField::setupDataStreamTimestampFieldDeserializer ); - protected static void setupDataStreamTimestampFieldDeserializer(ObjectDeserializer op) { - + protected static void setupDataStreamTimestampFieldDeserializer(ObjectDeserializer op) { op.add(Builder::name, JsonpDeserializer.stringDeserializer(), "name"); + } + @Override + public int hashCode() { + int result = 17; + result = 31 * result + this.name.hashCode(); + return result; } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + DataStreamTimestampField other = (DataStreamTimestampField) o; + return this.name.equals(other.name); + } } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/indices/DeleteIndexTemplateRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/DeleteIndexTemplateRequest.java new file mode 100644 index 0000000000..06356ca6b3 --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/DeleteIndexTemplateRequest.java @@ -0,0 +1,295 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. 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. + */ + +/* + * Modifications Copyright OpenSearch Contributors. See + * GitHub history for details. + */ + +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + +package org.opensearch.client.opensearch.indices; + +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.function.Function; +import javax.annotation.Generated; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import org.opensearch.client.opensearch._types.ErrorResponse; +import org.opensearch.client.opensearch._types.RequestBase; +import org.opensearch.client.opensearch._types.Time; +import org.opensearch.client.transport.Endpoint; +import org.opensearch.client.transport.endpoints.SimpleEndpoint; +import org.opensearch.client.util.ApiTypeHelper; +import org.opensearch.client.util.ObjectBuilder; +import org.opensearch.client.util.ObjectBuilderBase; + +// typedef: indices.delete_index_template.Request + +/** + * Deletes an index template. + */ +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class DeleteIndexTemplateRequest extends RequestBase { + + @Nullable + private final Time clusterManagerTimeout; + + @Deprecated + @Nullable + private final Time masterTimeout; + + @Nonnull + private final String name; + + @Nullable + private final Time timeout; + + // --------------------------------------------------------------------------------------------- + + private DeleteIndexTemplateRequest(Builder builder) { + this.clusterManagerTimeout = builder.clusterManagerTimeout; + this.masterTimeout = builder.masterTimeout; + this.name = ApiTypeHelper.requireNonNull(builder.name, this, "name"); + this.timeout = builder.timeout; + } + + public static DeleteIndexTemplateRequest of( + Function> fn + ) { + return fn.apply(new Builder()).build(); + } + + /** + * Operation timeout for connection to cluster-manager node. + *

+ * API name: {@code cluster_manager_timeout} + *

+ */ + @Nullable + public final Time clusterManagerTimeout() { + return this.clusterManagerTimeout; + } + + /** + * Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and + * returns an error. + *

+ * API name: {@code master_timeout} + *

+ */ + @Deprecated + @Nullable + public final Time masterTimeout() { + return this.masterTimeout; + } + + /** + * Required - Name of the index template to delete. Wildcard (*) expressions are supported. + *

+ * API name: {@code name} + *

+ */ + @Nonnull + public final String name() { + return this.name; + } + + /** + * Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. + *

+ * API name: {@code timeout} + *

+ */ + @Nullable + public final Time timeout() { + return this.timeout; + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link DeleteIndexTemplateRequest}. + */ + public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + @Nullable + private Time clusterManagerTimeout; + @Nullable + private Time masterTimeout; + private String name; + @Nullable + private Time timeout; + + /** + * Operation timeout for connection to cluster-manager node. + *

+ * API name: {@code cluster_manager_timeout} + *

+ */ + public final Builder clusterManagerTimeout(@Nullable Time value) { + this.clusterManagerTimeout = value; + return this; + } + + /** + * Operation timeout for connection to cluster-manager node. + *

+ * API name: {@code cluster_manager_timeout} + *

+ */ + public final Builder clusterManagerTimeout(Function> fn) { + return clusterManagerTimeout(fn.apply(new Time.Builder()).build()); + } + + /** + * Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and + * returns an error. + *

+ * API name: {@code master_timeout} + *

+ */ + @Deprecated + public final Builder masterTimeout(@Nullable Time value) { + this.masterTimeout = value; + return this; + } + + /** + * Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and + * returns an error. + *

+ * API name: {@code master_timeout} + *

+ */ + @Deprecated + public final Builder masterTimeout(Function> fn) { + return masterTimeout(fn.apply(new Time.Builder()).build()); + } + + /** + * Required - Name of the index template to delete. Wildcard (*) expressions are supported. + *

+ * API name: {@code name} + *

+ */ + public final Builder name(String value) { + this.name = value; + return this; + } + + /** + * Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. + *

+ * API name: {@code timeout} + *

+ */ + public final Builder timeout(@Nullable Time value) { + this.timeout = value; + return this; + } + + /** + * Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. + *

+ * API name: {@code timeout} + *

+ */ + public final Builder timeout(Function> fn) { + return timeout(fn.apply(new Time.Builder()).build()); + } + + /** + * Builds a {@link DeleteIndexTemplateRequest}. + * + * @throws NullPointerException if some of the required fields are null. + */ + public DeleteIndexTemplateRequest build() { + _checkSingleUse(); + + return new DeleteIndexTemplateRequest(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Endpoint "{@code indices.delete_index_template}". + */ + public static final Endpoint _ENDPOINT = new SimpleEndpoint<>( + // Request method + request -> "DELETE", + // Request path + request -> { + StringBuilder buf = new StringBuilder(); + buf.append("/_index_template/"); + SimpleEndpoint.pathEncode(request.name, buf); + return buf.toString(); + }, + // Request parameters + request -> { + Map params = new HashMap<>(); + if (request.clusterManagerTimeout != null) { + params.put("cluster_manager_timeout", request.clusterManagerTimeout._toJsonString()); + } + if (request.masterTimeout != null) { + params.put("master_timeout", request.masterTimeout._toJsonString()); + } + if (request.timeout != null) { + params.put("timeout", request.timeout._toJsonString()); + } + return params; + }, + SimpleEndpoint.emptyMap(), + false, + DeleteIndexTemplateResponse._DESERIALIZER + ); + + @Override + public int hashCode() { + int result = 17; + result = 31 * result + Objects.hashCode(this.clusterManagerTimeout); + result = 31 * result + Objects.hashCode(this.masterTimeout); + result = 31 * result + this.name.hashCode(); + result = 31 * result + Objects.hashCode(this.timeout); + return result; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + DeleteIndexTemplateRequest other = (DeleteIndexTemplateRequest) o; + return Objects.equals(this.clusterManagerTimeout, other.clusterManagerTimeout) + && Objects.equals(this.masterTimeout, other.masterTimeout) + && this.name.equals(other.name) + && Objects.equals(this.timeout, other.timeout); + } +} diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/indices/DeleteIndexTemplateResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/DeleteIndexTemplateResponse.java similarity index 77% rename from java-client/src/main/java/org/opensearch/client/opensearch/indices/DeleteIndexTemplateResponse.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/indices/DeleteIndexTemplateResponse.java index 01172d3c5f..0cc82ca5b8 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/indices/DeleteIndexTemplateResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/DeleteIndexTemplateResponse.java @@ -30,9 +30,14 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch.indices; import java.util.function.Function; +import javax.annotation.Generated; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.ObjectBuilderDeserializer; @@ -43,15 +48,18 @@ // typedef: indices.delete_index_template.Response @JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") public class DeleteIndexTemplateResponse extends AcknowledgedResponseBase { + // --------------------------------------------------------------------------------------------- private DeleteIndexTemplateResponse(Builder builder) { super(builder); - } - public static DeleteIndexTemplateResponse of(Function> fn) { + public static DeleteIndexTemplateResponse of( + Function> fn + ) { return fn.apply(new Builder()).build(); } @@ -60,10 +68,10 @@ public static DeleteIndexTemplateResponse of(Function implements ObjectBuilder { + @Override protected Builder self() { return this; @@ -72,8 +80,7 @@ protected Builder self() { /** * Builds a {@link DeleteIndexTemplateResponse}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ public DeleteIndexTemplateResponse build() { _checkSingleUse(); @@ -93,8 +100,22 @@ public DeleteIndexTemplateResponse build() { ); protected static void setupDeleteIndexTemplateResponseDeserializer(ObjectDeserializer op) { - AcknowledgedResponseBase.setupAcknowledgedResponseBaseDeserializer(op); + setupAcknowledgedResponseBaseDeserializer(op); + } + @Override + public int hashCode() { + int result = super.hashCode(); + return result; } + @Override + public boolean equals(Object o) { + if (!super.equals(o)) { + return false; + } + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + return true; + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/indices/ExistsIndexTemplateRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/ExistsIndexTemplateRequest.java similarity index 57% rename from java-client/src/main/java/org/opensearch/client/opensearch/indices/ExistsIndexTemplateRequest.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/indices/ExistsIndexTemplateRequest.java index a50df663c5..8ea5da93d6 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/indices/ExistsIndexTemplateRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/ExistsIndexTemplateRequest.java @@ -30,11 +30,18 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch.indices; import java.util.HashMap; import java.util.Map; +import java.util.Objects; import java.util.function.Function; +import javax.annotation.Generated; +import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.opensearch.client.opensearch._types.ErrorResponse; import org.opensearch.client.opensearch._types.RequestBase; @@ -51,62 +58,95 @@ /** * Returns information about whether a particular index template exists. - * */ - +@Generated("org.opensearch.client.codegen.CodeGenerator") public class ExistsIndexTemplateRequest extends RequestBase { - @Deprecated - @Nullable - private final Time masterTimeout; @Nullable private final Time clusterManagerTimeout; + @Nullable + private final Boolean flatSettings; + + @Nullable + private final Boolean local; + + @Deprecated + @Nullable + private final Time masterTimeout; + + @Nonnull private final String name; // --------------------------------------------------------------------------------------------- private ExistsIndexTemplateRequest(Builder builder) { - - this.masterTimeout = builder.masterTimeout; this.clusterManagerTimeout = builder.clusterManagerTimeout; + this.flatSettings = builder.flatSettings; + this.local = builder.local; + this.masterTimeout = builder.masterTimeout; this.name = ApiTypeHelper.requireNonNull(builder.name, this, "name"); - } - public static ExistsIndexTemplateRequest of(Function> fn) { + public static ExistsIndexTemplateRequest of( + Function> fn + ) { return fn.apply(new Builder()).build(); } /** - * Period to wait for a connection to the master node. If no response is - * received before the timeout expires, the request fails and returns an error. + * Operation timeout for connection to cluster-manager node. *

- * API name: {@code master_timeout} + * API name: {@code cluster_manager_timeout} + *

*/ - @Deprecated @Nullable - public final Time masterTimeout() { - return this.masterTimeout; + public final Time clusterManagerTimeout() { + return this.clusterManagerTimeout; } /** - * Period to wait for a connection to the cluster-manager node. If no response is - * received before the timeout expires, the request fails and returns an error. + * Return settings in flat format. *

- * API name: {@code cluster_manager_timeout} + * API name: {@code flat_settings} + *

*/ @Nullable - public final Time clusterManagerTimeout() { - return this.clusterManagerTimeout; + public final Boolean flatSettings() { + return this.flatSettings; } /** - * Required - Comma-separated list of index template names used to limit the - * request. Wildcard (*) expressions are supported. + * Return local information, do not retrieve the state from cluster-manager node. + *

+ * API name: {@code local} + *

+ */ + @Nullable + public final Boolean local() { + return this.local; + } + + /** + * Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and + * returns an error. + *

+ * API name: {@code master_timeout} + *

+ */ + @Deprecated + @Nullable + public final Time masterTimeout() { + return this.masterTimeout; + } + + /** + * Required - Name of the index template to check existence of. Wildcard (*) expressions are supported. *

* API name: {@code name} + *

*/ + @Nonnull public final String name() { return this.name; } @@ -116,66 +156,90 @@ public final String name() { /** * Builder for {@link ExistsIndexTemplateRequest}. */ - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - @Deprecated + @Nullable + private Time clusterManagerTimeout; + @Nullable + private Boolean flatSettings; + @Nullable + private Boolean local; @Nullable private Time masterTimeout; + private String name; - @Nullable - private Time clusterManagerTimeout; + /** + * Operation timeout for connection to cluster-manager node. + *

+ * API name: {@code cluster_manager_timeout} + *

+ */ + public final Builder clusterManagerTimeout(@Nullable Time value) { + this.clusterManagerTimeout = value; + return this; + } - private String name; + /** + * Operation timeout for connection to cluster-manager node. + *

+ * API name: {@code cluster_manager_timeout} + *

+ */ + public final Builder clusterManagerTimeout(Function> fn) { + return clusterManagerTimeout(fn.apply(new Time.Builder()).build()); + } /** - * Period to wait for a connection to the master node. If no response is - * received before the timeout expires, the request fails and returns an error. + * Return settings in flat format. *

- * API name: {@code master_timeout} + * API name: {@code flat_settings} + *

*/ - @Deprecated - public final Builder masterTimeout(@Nullable Time value) { - this.masterTimeout = value; + public final Builder flatSettings(@Nullable Boolean value) { + this.flatSettings = value; return this; } /** - * Period to wait for a connection to the master node. If no response is - * received before the timeout expires, the request fails and returns an error. + * Return local information, do not retrieve the state from cluster-manager node. *

- * API name: {@code master_timeout} + * API name: {@code local} + *

*/ - @Deprecated - public final Builder masterTimeout(Function> fn) { - return this.masterTimeout(fn.apply(new Time.Builder()).build()); + public final Builder local(@Nullable Boolean value) { + this.local = value; + return this; } /** - * Period to wait for a connection to the cluster-manager node. If no response is - * received before the timeout expires, the request fails and returns an error. + * Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and + * returns an error. *

- * API name: {@code cluster_manager_timeout} + * API name: {@code master_timeout} + *

*/ - public final Builder clusterManagerTimeout(@Nullable Time value) { - this.clusterManagerTimeout = value; + @Deprecated + public final Builder masterTimeout(@Nullable Time value) { + this.masterTimeout = value; return this; } /** - * Period to wait for a connection to the cluster-manager node. If no response is - * received before the timeout expires, the request fails and returns an error. + * Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and + * returns an error. *

- * API name: {@code cluster_manager_timeout} + * API name: {@code master_timeout} + *

*/ - public final Builder clusterManagerTimeout(Function> fn) { - return this.clusterManagerTimeout(fn.apply(new Time.Builder()).build()); + @Deprecated + public final Builder masterTimeout(Function> fn) { + return masterTimeout(fn.apply(new Time.Builder()).build()); } /** - * Required - Comma-separated list of index template names used to limit the - * request. Wildcard (*) expressions are supported. + * Required - Name of the index template to check existence of. Wildcard (*) expressions are supported. *

* API name: {@code name} + *

*/ public final Builder name(String value) { this.name = value; @@ -185,8 +249,7 @@ public final Builder name(String value) { /** * Builds a {@link ExistsIndexTemplateRequest}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ public ExistsIndexTemplateRequest build() { _checkSingleUse(); @@ -201,47 +264,55 @@ public ExistsIndexTemplateRequest build() { * Endpoint "{@code indices.exists_index_template}". */ public static final Endpoint _ENDPOINT = new BooleanEndpoint<>( - "opensearch/indices.exists_index_template", - // Request method - request -> { - return "HEAD"; - - }, - + request -> "HEAD", // Request path request -> { - final int _name = 1 << 0; - - int propsSet = 0; - - propsSet |= _name; - - if (propsSet == (_name)) { - StringBuilder buf = new StringBuilder(); - buf.append("/_index_template"); - buf.append("/"); - SimpleEndpoint.pathEncode(request.name, buf); - return buf.toString(); - } - throw SimpleEndpoint.noPathTemplateFound("path"); - + StringBuilder buf = new StringBuilder(); + buf.append("/_index_template/"); + SimpleEndpoint.pathEncode(request.name, buf); + return buf.toString(); }, - // Request parameters request -> { Map params = new HashMap<>(); - if (request.masterTimeout != null) { - params.put("master_timeout", request.masterTimeout._toJsonString()); - } if (request.clusterManagerTimeout != null) { params.put("cluster_manager_timeout", request.clusterManagerTimeout._toJsonString()); } + if (request.flatSettings != null) { + params.put("flat_settings", String.valueOf(request.flatSettings)); + } + if (request.local != null) { + params.put("local", String.valueOf(request.local)); + } + if (request.masterTimeout != null) { + params.put("master_timeout", request.masterTimeout._toJsonString()); + } return params; - }, - SimpleEndpoint.emptyMap(), - false, - null + SimpleEndpoint.emptyMap() ); + + @Override + public int hashCode() { + int result = 17; + result = 31 * result + Objects.hashCode(this.clusterManagerTimeout); + result = 31 * result + Objects.hashCode(this.flatSettings); + result = 31 * result + Objects.hashCode(this.local); + result = 31 * result + Objects.hashCode(this.masterTimeout); + result = 31 * result + this.name.hashCode(); + return result; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + ExistsIndexTemplateRequest other = (ExistsIndexTemplateRequest) o; + return Objects.equals(this.clusterManagerTimeout, other.clusterManagerTimeout) + && Objects.equals(this.flatSettings, other.flatSettings) + && Objects.equals(this.local, other.local) + && Objects.equals(this.masterTimeout, other.masterTimeout) + && this.name.equals(other.name); + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/indices/GetIndexTemplateRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/GetIndexTemplateRequest.java similarity index 73% rename from java-client/src/main/java/org/opensearch/client/opensearch/indices/GetIndexTemplateRequest.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/indices/GetIndexTemplateRequest.java index df8a55d999..0f08fc8624 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/indices/GetIndexTemplateRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/GetIndexTemplateRequest.java @@ -30,11 +30,17 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch.indices; import java.util.HashMap; import java.util.Map; +import java.util.Objects; import java.util.function.Function; +import javax.annotation.Generated; import javax.annotation.Nullable; import org.opensearch.client.opensearch._types.ErrorResponse; import org.opensearch.client.opensearch._types.RequestBase; @@ -48,10 +54,13 @@ /** * Returns an index template. - * */ - +@Generated("org.opensearch.client.codegen.CodeGenerator") public class GetIndexTemplateRequest extends RequestBase { + + @Nullable + private final Time clusterManagerTimeout; + @Nullable private final Boolean flatSettings; @@ -62,32 +71,39 @@ public class GetIndexTemplateRequest extends RequestBase { @Nullable private final Time masterTimeout; - @Nullable - private final Time clusterManagerTimeout; - @Nullable private final String name; // --------------------------------------------------------------------------------------------- private GetIndexTemplateRequest(Builder builder) { - + this.clusterManagerTimeout = builder.clusterManagerTimeout; this.flatSettings = builder.flatSettings; this.local = builder.local; this.masterTimeout = builder.masterTimeout; - this.clusterManagerTimeout = builder.clusterManagerTimeout; this.name = builder.name; - } - public static GetIndexTemplateRequest of(Function> fn) { + public static GetIndexTemplateRequest of(Function> fn) { return fn.apply(new Builder()).build(); } + /** + * Operation timeout for connection to cluster-manager node. + *

+ * API name: {@code cluster_manager_timeout} + *

+ */ + @Nullable + public final Time clusterManagerTimeout() { + return this.clusterManagerTimeout; + } + /** * If true, returns settings in flat format. *

* API name: {@code flat_settings} + *

*/ @Nullable public final Boolean flatSettings() { @@ -95,10 +111,11 @@ public final Boolean flatSettings() { } /** - * If true, the request retrieves information from the local node only. Defaults - * to false, which means information is retrieved from the cluster-manager node. + * If true, the request retrieves information from the local node only. Defaults to false, which means information is retrieved from the + * master node. *

* API name: {@code local} + *

*/ @Nullable public final Boolean local() { @@ -106,10 +123,11 @@ public final Boolean local() { } /** - * Period to wait for a connection to the master node. If no response is - * received before the timeout expires, the request fails and returns an error. + * Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and + * returns an error. *

* API name: {@code master_timeout} + *

*/ @Deprecated @Nullable @@ -118,21 +136,10 @@ public final Time masterTimeout() { } /** - * Period to wait for a connection to the cluster-manager node. If no response is - * received before the timeout expires, the request fails and returns an error. - *

- * API name: {@code cluster_manager_timeout} - */ - @Nullable - public final Time clusterManagerTimeout() { - return this.clusterManagerTimeout; - } - - /** - * Comma-separated list of index template names used to limit the request. - * Wildcard (*) expressions are supported. + * Name of the index template to retrieve. Wildcard (*) expressions are supported. *

* API name: {@code name} + *

*/ @Nullable public final String name() { @@ -144,28 +151,44 @@ public final String name() { /** * Builder for {@link GetIndexTemplateRequest}. */ - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + @Nullable + private Time clusterManagerTimeout; @Nullable private Boolean flatSettings; - @Nullable private Boolean local; - - @Deprecated @Nullable private Time masterTimeout; - - @Nullable - private Time clusterManagerTimeout; - @Nullable private String name; + /** + * Operation timeout for connection to cluster-manager node. + *

+ * API name: {@code cluster_manager_timeout} + *

+ */ + public final Builder clusterManagerTimeout(@Nullable Time value) { + this.clusterManagerTimeout = value; + return this; + } + + /** + * Operation timeout for connection to cluster-manager node. + *

+ * API name: {@code cluster_manager_timeout} + *

+ */ + public final Builder clusterManagerTimeout(Function> fn) { + return clusterManagerTimeout(fn.apply(new Time.Builder()).build()); + } + /** * If true, returns settings in flat format. *

* API name: {@code flat_settings} + *

*/ public final Builder flatSettings(@Nullable Boolean value) { this.flatSettings = value; @@ -173,10 +196,11 @@ public final Builder flatSettings(@Nullable Boolean value) { } /** - * If true, the request retrieves information from the local node only. Defaults - * to false, which means information is retrieved from the cluster-manager node. + * If true, the request retrieves information from the local node only. Defaults to false, which means information is retrieved from + * the master node. *

* API name: {@code local} + *

*/ public final Builder local(@Nullable Boolean value) { this.local = value; @@ -184,10 +208,11 @@ public final Builder local(@Nullable Boolean value) { } /** - * Period to wait for a connection to the master node. If no response is - * received before the timeout expires, the request fails and returns an error. + * Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and + * returns an error. *

* API name: {@code master_timeout} + *

*/ @Deprecated public final Builder masterTimeout(@Nullable Time value) { @@ -196,42 +221,22 @@ public final Builder masterTimeout(@Nullable Time value) { } /** - * Period to wait for a connection to the master node. If no response is - * received before the timeout expires, the request fails and returns an error. + * Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and + * returns an error. *

* API name: {@code master_timeout} + *

*/ @Deprecated public final Builder masterTimeout(Function> fn) { - return this.masterTimeout(fn.apply(new Time.Builder()).build()); - } - - /** - * Period to wait for a connection to the cluster-manager node. If no response is - * received before the timeout expires, the request fails and returns an error. - *

- * API name: {@code cluster_manager_timeout} - */ - public final Builder clusterManagerTimeout(@Nullable Time value) { - this.clusterManagerTimeout = value; - return this; + return masterTimeout(fn.apply(new Time.Builder()).build()); } /** - * Period to wait for a connection to the cluster-manager node. If no response is - * received before the timeout expires, the request fails and returns an error. - *

- * API name: {@code cluster_manager_timeout} - */ - public final Builder clusterManagerTimeout(Function> fn) { - return this.clusterManagerTimeout(fn.apply(new Time.Builder()).build()); - } - - /** - * Comma-separated list of index template names used to limit the request. - * Wildcard (*) expressions are supported. + * Name of the index template to retrieve. Wildcard (*) expressions are supported. *

* API name: {@code name} + *

*/ public final Builder name(@Nullable String value) { this.name = value; @@ -241,8 +246,7 @@ public final Builder name(@Nullable String value) { /** * Builds a {@link GetIndexTemplateRequest}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ public GetIndexTemplateRequest build() { _checkSingleUse(); @@ -257,13 +261,8 @@ public GetIndexTemplateRequest build() { * Endpoint "{@code indices.get_index_template}". */ public static final Endpoint _ENDPOINT = new SimpleEndpoint<>( - // Request method - request -> { - return "GET"; - - }, - + request -> "GET", // Request path request -> { final int _name = 1 << 0; @@ -273,27 +272,20 @@ public GetIndexTemplateRequest build() { if (request.name() != null) propsSet |= _name; if (propsSet == 0) { - StringBuilder buf = new StringBuilder(); - buf.append("/_index_template"); - return buf.toString(); + return "/_index_template"; } if (propsSet == (_name)) { StringBuilder buf = new StringBuilder(); - buf.append("/_index_template"); - buf.append("/"); + buf.append("/_index_template/"); SimpleEndpoint.pathEncode(request.name, buf); return buf.toString(); } - throw SimpleEndpoint.noPathTemplateFound("path"); + throw SimpleEndpoint.noPathTemplateFound("path"); }, - // Request parameters request -> { Map params = new HashMap<>(); - if (request.masterTimeout != null) { - params.put("master_timeout", request.masterTimeout._toJsonString()); - } if (request.clusterManagerTimeout != null) { params.put("cluster_manager_timeout", request.clusterManagerTimeout._toJsonString()); } @@ -303,11 +295,36 @@ public GetIndexTemplateRequest build() { if (request.local != null) { params.put("local", String.valueOf(request.local)); } + if (request.masterTimeout != null) { + params.put("master_timeout", request.masterTimeout._toJsonString()); + } return params; - }, SimpleEndpoint.emptyMap(), false, GetIndexTemplateResponse._DESERIALIZER ); + + @Override + public int hashCode() { + int result = 17; + result = 31 * result + Objects.hashCode(this.clusterManagerTimeout); + result = 31 * result + Objects.hashCode(this.flatSettings); + result = 31 * result + Objects.hashCode(this.local); + result = 31 * result + Objects.hashCode(this.masterTimeout); + result = 31 * result + Objects.hashCode(this.name); + return result; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + GetIndexTemplateRequest other = (GetIndexTemplateRequest) o; + return Objects.equals(this.clusterManagerTimeout, other.clusterManagerTimeout) + && Objects.equals(this.flatSettings, other.flatSettings) + && Objects.equals(this.local, other.local) + && Objects.equals(this.masterTimeout, other.masterTimeout) + && Objects.equals(this.name, other.name); + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/indices/GetIndexTemplateResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/GetIndexTemplateResponse.java similarity index 80% rename from java-client/src/main/java/org/opensearch/client/opensearch/indices/GetIndexTemplateResponse.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/indices/GetIndexTemplateResponse.java index 709b613233..85f4742874 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/indices/GetIndexTemplateResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/GetIndexTemplateResponse.java @@ -30,11 +30,17 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch.indices; import jakarta.json.stream.JsonGenerator; import java.util.List; import java.util.function.Function; +import javax.annotation.Generated; +import javax.annotation.Nonnull; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.JsonpMapper; @@ -49,24 +55,26 @@ // typedef: indices.get_index_template.Response @JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") public class GetIndexTemplateResponse implements PlainJsonSerializable { + + @Nonnull private final List indexTemplates; // --------------------------------------------------------------------------------------------- private GetIndexTemplateResponse(Builder builder) { - this.indexTemplates = ApiTypeHelper.unmodifiableRequired(builder.indexTemplates, this, "indexTemplates"); - } - public static GetIndexTemplateResponse of(Function> fn) { + public static GetIndexTemplateResponse of(Function> fn) { return fn.apply(new Builder()).build(); } /** * Required - API name: {@code index_templates} */ + @Nonnull public final List indexTemplates() { return this.indexTemplates; } @@ -74,6 +82,7 @@ public final List indexTemplates() { /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -81,18 +90,12 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - - if (ApiTypeHelper.isDefined(this.indexTemplates)) { - generator.writeKey("index_templates"); - generator.writeStartArray(); - for (IndexTemplateItem item0 : this.indexTemplates) { - item0.serialize(generator, mapper); - - } - generator.writeEnd(); - + generator.writeKey("index_templates"); + generator.writeStartArray(); + for (IndexTemplateItem item0 : this.indexTemplates) { + item0.serialize(generator, mapper); } - + generator.writeEnd(); } // --------------------------------------------------------------------------------------------- @@ -100,14 +103,15 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { /** * Builder for {@link GetIndexTemplateResponse}. */ - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { private List indexTemplates; /** * Required - API name: {@code index_templates} + * *

* Adds all elements of list to indexTemplates. + *

*/ public final Builder indexTemplates(List list) { this.indexTemplates = _listAddAll(this.indexTemplates, list); @@ -116,8 +120,10 @@ public final Builder indexTemplates(List list) { /** * Required - API name: {@code index_templates} + * *

* Adds one or more values to indexTemplates. + *

*/ public final Builder indexTemplates(IndexTemplateItem value, IndexTemplateItem... values) { this.indexTemplates = _listAdd(this.indexTemplates, value, values); @@ -126,8 +132,10 @@ public final Builder indexTemplates(IndexTemplateItem value, IndexTemplateItem.. /** * Required - API name: {@code index_templates} + * *

* Adds a value to indexTemplates using a builder lambda. + *

*/ public final Builder indexTemplates(Function> fn) { return indexTemplates(fn.apply(new IndexTemplateItem.Builder()).build()); @@ -136,8 +144,7 @@ public final Builder indexTemplates(Function op) { - op.add(Builder::indexTemplates, JsonpDeserializer.arrayDeserializer(IndexTemplateItem._DESERIALIZER), "index_templates"); + } + @Override + public int hashCode() { + int result = 17; + result = 31 * result + this.indexTemplates.hashCode(); + return result; } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + GetIndexTemplateResponse other = (GetIndexTemplateResponse) o; + return this.indexTemplates.equals(other.indexTemplates); + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/indices/get_index_template/IndexTemplate.java b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/IndexTemplate.java similarity index 67% rename from java-client/src/main/java/org/opensearch/client/opensearch/indices/get_index_template/IndexTemplate.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/indices/IndexTemplate.java index cebcb16192..ed5acb21df 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/indices/get_index_template/IndexTemplate.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/IndexTemplate.java @@ -30,12 +30,19 @@ * GitHub history for details. */ -package org.opensearch.client.opensearch.indices.get_index_template; +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + +package org.opensearch.client.opensearch.indices; import jakarta.json.stream.JsonGenerator; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.function.Function; +import javax.annotation.Generated; +import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.opensearch.client.json.JsonData; import org.opensearch.client.json.JsonpDeserializable; @@ -48,112 +55,133 @@ import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; -// typedef: indices.get_index_template.IndexTemplate +// typedef: indices.IndexTemplate +/** + * New index template definition to be simulated, if no index template name is specified. + */ @JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") public class IndexTemplate implements PlainJsonSerializable { - private final List indexPatterns; + @Nullable + private final Boolean allowAutoCreate; + + @Nonnull private final List composedOf; @Nullable - private final IndexTemplateSummary template; + private final IndexTemplateDataStreamConfiguration dataStream; - @Nullable - private final Long version; + @Nonnull + private final List indexPatterns; + + @Nonnull + private final Map meta; @Nullable private final Long priority; - private final Map meta; - @Nullable - private final Boolean allowAutoCreate; + private final IndexTemplateSummary template; - private final Map dataStream; + @Nullable + private final Long version; // --------------------------------------------------------------------------------------------- private IndexTemplate(Builder builder) { - + this.allowAutoCreate = builder.allowAutoCreate; + this.composedOf = ApiTypeHelper.unmodifiable(builder.composedOf); + this.dataStream = builder.dataStream; this.indexPatterns = ApiTypeHelper.unmodifiableRequired(builder.indexPatterns, this, "indexPatterns"); - this.composedOf = ApiTypeHelper.unmodifiableRequired(builder.composedOf, this, "composedOf"); + this.meta = ApiTypeHelper.unmodifiable(builder.meta); + this.priority = builder.priority; this.template = builder.template; this.version = builder.version; - this.priority = builder.priority; - this.meta = ApiTypeHelper.unmodifiable(builder.meta); - this.allowAutoCreate = builder.allowAutoCreate; - this.dataStream = ApiTypeHelper.unmodifiable(builder.dataStream); - } - public static IndexTemplate of(Function> fn) { + public static IndexTemplate of(Function> fn) { return fn.apply(new Builder()).build(); } /** - * Required - API name: {@code index_patterns} + * API name: {@code allow_auto_create} */ - public final List indexPatterns() { - return this.indexPatterns; + @Nullable + public final Boolean allowAutoCreate() { + return this.allowAutoCreate; } /** - * Required - API name: {@code composed_of} + * An ordered list of component template names. Component templates are merged in the order specified, meaning that the last component + * template specified has the highest precedence. + *

+ * API name: {@code composed_of} + *

*/ + @Nonnull public final List composedOf() { return this.composedOf; } /** - * API name: {@code template} + * API name: {@code data_stream} */ @Nullable - public final IndexTemplateSummary template() { - return this.template; + public final IndexTemplateDataStreamConfiguration dataStream() { + return this.dataStream; } /** - * API name: {@code version} + * Required - API name: {@code index_patterns} */ - @Nullable - public final Long version() { - return this.version; + @Nonnull + public final List indexPatterns() { + return this.indexPatterns; } /** - * API name: {@code priority} + * API name: {@code _meta} */ - @Nullable - public final Long priority() { - return this.priority; + @Nonnull + public final Map meta() { + return this.meta; } /** - * API name: {@code _meta} + * Priority to determine index template precedence when a new data stream or index is created. The index template with the highest + * priority is chosen. If no priority is specified the template is treated as though it is of priority 0 (lowest priority). This number + * is not automatically generated by OpenSearch. + *

+ * API name: {@code priority} + *

*/ - public final Map meta() { - return this.meta; + @Nullable + public final Long priority() { + return this.priority; } /** - * API name: {@code allow_auto_create} + * API name: {@code template} */ @Nullable - public final Boolean allowAutoCreate() { - return this.allowAutoCreate; + public final IndexTemplateSummary template() { + return this.template; } /** - * API name: {@code data_stream} + * API name: {@code version} */ - public final Map dataStream() { - return this.dataStream; + @Nullable + public final Long version() { + return this.version; } /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -161,70 +189,56 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - - if (ApiTypeHelper.isDefined(this.indexPatterns)) { - generator.writeKey("index_patterns"); - generator.writeStartArray(); - for (String item0 : this.indexPatterns) { - generator.write(item0); - - } - generator.writeEnd(); - + if (this.allowAutoCreate != null) { + generator.writeKey("allow_auto_create"); + generator.write(this.allowAutoCreate); } + if (ApiTypeHelper.isDefined(this.composedOf)) { generator.writeKey("composed_of"); generator.writeStartArray(); for (String item0 : this.composedOf) { generator.write(item0); - } generator.writeEnd(); - } - if (this.template != null) { - generator.writeKey("template"); - this.template.serialize(generator, mapper); + if (this.dataStream != null) { + generator.writeKey("data_stream"); + this.dataStream.serialize(generator, mapper); } - if (this.version != null) { - generator.writeKey("version"); - generator.write(this.version); + generator.writeKey("index_patterns"); + generator.writeStartArray(); + for (String item0 : this.indexPatterns) { + generator.write(item0); } - if (this.priority != null) { - generator.writeKey("priority"); - generator.write(this.priority); + generator.writeEnd(); - } if (ApiTypeHelper.isDefined(this.meta)) { generator.writeKey("_meta"); generator.writeStartObject(); for (Map.Entry item0 : this.meta.entrySet()) { generator.writeKey(item0.getKey()); item0.getValue().serialize(generator, mapper); - } generator.writeEnd(); - } - if (this.allowAutoCreate != null) { - generator.writeKey("allow_auto_create"); - generator.write(this.allowAutoCreate); + if (this.priority != null) { + generator.writeKey("priority"); + generator.write(this.priority); } - if (ApiTypeHelper.isDefined(this.dataStream)) { - generator.writeKey("data_stream"); - generator.writeStartObject(); - for (Map.Entry item0 : this.dataStream.entrySet()) { - generator.writeKey(item0.getKey()); - item0.getValue().serialize(generator, mapper); - - } - generator.writeEnd(); + if (this.template != null) { + generator.writeKey("template"); + this.template.serialize(generator, mapper); } + if (this.version != null) { + generator.writeKey("version"); + generator.write(this.version); + } } // --------------------------------------------------------------------------------------------- @@ -232,54 +246,41 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { /** * Builder for {@link IndexTemplate}. */ - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - private List indexPatterns; - - private List composedOf; - @Nullable - private IndexTemplateSummary template; - + private Boolean allowAutoCreate; @Nullable - private Long version; - + private List composedOf; @Nullable - private Long priority; - + private IndexTemplateDataStreamConfiguration dataStream; + private List indexPatterns; @Nullable private Map meta; - @Nullable - private Boolean allowAutoCreate; - + private Long priority; + @Nullable + private IndexTemplateSummary template; @Nullable - private Map dataStream; + private Long version; /** - * Required - API name: {@code index_patterns} - *

- * Adds all elements of list to indexPatterns. + * API name: {@code allow_auto_create} */ - public final Builder indexPatterns(List list) { - this.indexPatterns = _listAddAll(this.indexPatterns, list); + public final Builder allowAutoCreate(@Nullable Boolean value) { + this.allowAutoCreate = value; return this; } /** - * Required - API name: {@code index_patterns} + * An ordered list of component template names. Component templates are merged in the order specified, meaning that the last + * component template specified has the highest precedence. *

- * Adds one or more values to indexPatterns. - */ - public final Builder indexPatterns(String value, String... values) { - this.indexPatterns = _listAdd(this.indexPatterns, value, values); - return this; - } - - /** - * Required - API name: {@code composed_of} + * API name: {@code composed_of} + *

+ * *

* Adds all elements of list to composedOf. + *

*/ public final Builder composedOf(List list) { this.composedOf = _listAddAll(this.composedOf, list); @@ -287,9 +288,15 @@ public final Builder composedOf(List list) { } /** - * Required - API name: {@code composed_of} + * An ordered list of component template names. Component templates are merged in the order specified, meaning that the last + * component template specified has the highest precedence. + *

+ * API name: {@code composed_of} + *

+ * *

* Adds one or more values to composedOf. + *

*/ public final Builder composedOf(String value, String... values) { this.composedOf = _listAdd(this.composedOf, value, values); @@ -297,40 +304,52 @@ public final Builder composedOf(String value, String... values) { } /** - * API name: {@code template} + * API name: {@code data_stream} */ - public final Builder template(@Nullable IndexTemplateSummary value) { - this.template = value; + public final Builder dataStream(@Nullable IndexTemplateDataStreamConfiguration value) { + this.dataStream = value; return this; } /** - * API name: {@code template} + * API name: {@code data_stream} */ - public final Builder template(Function> fn) { - return this.template(fn.apply(new IndexTemplateSummary.Builder()).build()); + public final Builder dataStream( + Function> fn + ) { + return dataStream(fn.apply(new IndexTemplateDataStreamConfiguration.Builder()).build()); } /** - * API name: {@code version} + * Required - API name: {@code index_patterns} + * + *

+ * Adds all elements of list to indexPatterns. + *

*/ - public final Builder version(@Nullable Long value) { - this.version = value; + public final Builder indexPatterns(List list) { + this.indexPatterns = _listAddAll(this.indexPatterns, list); return this; } /** - * API name: {@code priority} + * Required - API name: {@code index_patterns} + * + *

+ * Adds one or more values to indexPatterns. + *

*/ - public final Builder priority(@Nullable Long value) { - this.priority = value; + public final Builder indexPatterns(String value, String... values) { + this.indexPatterns = _listAdd(this.indexPatterns, value, values); return this; } /** * API name: {@code _meta} + * *

- * Adds all entries of map to meta. + * Adds all elements of map to meta. + *

*/ public final Builder meta(Map map) { this.meta = _mapPutAll(this.meta, map); @@ -339,8 +358,10 @@ public final Builder meta(Map map) { /** * API name: {@code _meta} + * *

* Adds an entry to meta. + *

*/ public final Builder meta(String key, JsonData value) { this.meta = _mapPut(this.meta, key, value); @@ -348,38 +369,45 @@ public final Builder meta(String key, JsonData value) { } /** - * API name: {@code allow_auto_create} + * Priority to determine index template precedence when a new data stream or index is created. The index template with the highest + * priority is chosen. If no priority is specified the template is treated as though it is of priority 0 (lowest priority). This + * number is not automatically generated by OpenSearch. + *

+ * API name: {@code priority} + *

*/ - public final Builder allowAutoCreate(@Nullable Boolean value) { - this.allowAutoCreate = value; + public final Builder priority(@Nullable Long value) { + this.priority = value; return this; } /** - * API name: {@code data_stream} - *

- * Adds all entries of map to dataStream. + * API name: {@code template} */ - public final Builder dataStream(Map map) { - this.dataStream = _mapPutAll(this.dataStream, map); + public final Builder template(@Nullable IndexTemplateSummary value) { + this.template = value; return this; } /** - * API name: {@code data_stream} - *

- * Adds an entry to dataStream. + * API name: {@code template} + */ + public final Builder template(Function> fn) { + return template(fn.apply(new IndexTemplateSummary.Builder()).build()); + } + + /** + * API name: {@code version} */ - public final Builder dataStream(String key, JsonData value) { - this.dataStream = _mapPut(this.dataStream, key, value); + public final Builder version(@Nullable Long value) { + this.version = value; return this; } /** * Builds a {@link IndexTemplate}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ public IndexTemplate build() { _checkSingleUse(); @@ -399,16 +427,42 @@ public IndexTemplate build() { ); protected static void setupIndexTemplateDeserializer(ObjectDeserializer op) { - - op.add(Builder::indexPatterns, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "index_patterns"); + op.add(Builder::allowAutoCreate, JsonpDeserializer.booleanDeserializer(), "allow_auto_create"); op.add(Builder::composedOf, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "composed_of"); + op.add(Builder::dataStream, IndexTemplateDataStreamConfiguration._DESERIALIZER, "data_stream"); + op.add(Builder::indexPatterns, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "index_patterns"); + op.add(Builder::meta, JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), "_meta"); + op.add(Builder::priority, JsonpDeserializer.longDeserializer(), "priority"); op.add(Builder::template, IndexTemplateSummary._DESERIALIZER, "template"); op.add(Builder::version, JsonpDeserializer.longDeserializer(), "version"); - op.add(Builder::priority, JsonpDeserializer.longDeserializer(), "priority"); - op.add(Builder::meta, JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), "_meta"); - op.add(Builder::allowAutoCreate, JsonpDeserializer.booleanDeserializer(), "allow_auto_create"); - op.add(Builder::dataStream, JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), "data_stream"); + } + @Override + public int hashCode() { + int result = 17; + result = 31 * result + Objects.hashCode(this.allowAutoCreate); + result = 31 * result + Objects.hashCode(this.composedOf); + result = 31 * result + Objects.hashCode(this.dataStream); + result = 31 * result + this.indexPatterns.hashCode(); + result = 31 * result + Objects.hashCode(this.meta); + result = 31 * result + Objects.hashCode(this.priority); + result = 31 * result + Objects.hashCode(this.template); + result = 31 * result + Objects.hashCode(this.version); + return result; } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + IndexTemplate other = (IndexTemplate) o; + return Objects.equals(this.allowAutoCreate, other.allowAutoCreate) + && Objects.equals(this.composedOf, other.composedOf) + && Objects.equals(this.dataStream, other.dataStream) + && this.indexPatterns.equals(other.indexPatterns) + && Objects.equals(this.meta, other.meta) + && Objects.equals(this.priority, other.priority) + && Objects.equals(this.template, other.template) + && Objects.equals(this.version, other.version); + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/indices/DataStream.java b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/IndexTemplateDataStreamConfiguration.java similarity index 55% rename from java-client/src/main/java/org/opensearch/client/opensearch/indices/DataStream.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/indices/IndexTemplateDataStreamConfiguration.java index 6feb358992..2ccf4f3b47 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/indices/DataStream.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/IndexTemplateDataStreamConfiguration.java @@ -30,10 +30,16 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch.indices; import jakarta.json.stream.JsonGenerator; +import java.util.Objects; import java.util.function.Function; +import javax.annotation.Generated; import javax.annotation.Nullable; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; @@ -44,10 +50,15 @@ import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; -// typedef: indices._types.DataStream +// typedef: indices.IndexTemplateDataStreamConfiguration @JsonpDeserializable -public class DataStream implements PlainJsonSerializable { +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class IndexTemplateDataStreamConfiguration implements PlainJsonSerializable { + + @Nullable + private final Boolean allowCustomRouting; + @Nullable private final Boolean hidden; @@ -56,19 +67,34 @@ public class DataStream implements PlainJsonSerializable { // --------------------------------------------------------------------------------------------- - private DataStream(Builder builder) { - + private IndexTemplateDataStreamConfiguration(Builder builder) { + this.allowCustomRouting = builder.allowCustomRouting; this.hidden = builder.hidden; this.timestampField = builder.timestampField; - } - public static DataStream of(Function> fn) { + public static IndexTemplateDataStreamConfiguration of( + Function> fn + ) { return fn.apply(new Builder()).build(); } /** + * If true, the data stream supports custom routing. + *

+ * API name: {@code allow_custom_routing} + *

+ */ + @Nullable + public final Boolean allowCustomRouting() { + return this.allowCustomRouting; + } + + /** + * If true, the data stream is hidden. + *

* API name: {@code hidden} + *

*/ @Nullable public final Boolean hidden() { @@ -86,6 +112,7 @@ public final DataStreamTimestampField timestampField() { /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -93,6 +120,10 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + if (this.allowCustomRouting != null) { + generator.writeKey("allow_custom_routing"); + generator.write(this.allowCustomRouting); + } if (this.hidden != null) { generator.writeKey("hidden"); @@ -103,24 +134,37 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeKey("timestamp_field"); this.timestampField.serialize(generator, mapper); } - } // --------------------------------------------------------------------------------------------- /** - * Builder for {@link DataStream}. + * Builder for {@link IndexTemplateDataStreamConfiguration}. */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + @Nullable + private Boolean allowCustomRouting; @Nullable private Boolean hidden; - @Nullable private DataStreamTimestampField timestampField; /** + * If true, the data stream supports custom routing. + *

+ * API name: {@code allow_custom_routing} + *

+ */ + public final Builder allowCustomRouting(@Nullable Boolean value) { + this.allowCustomRouting = value; + return this; + } + + /** + * If true, the data stream is hidden. + *

* API name: {@code hidden} + *

*/ public final Builder hidden(@Nullable Boolean value) { this.hidden = value; @@ -139,37 +183,55 @@ public final Builder timestampField(@Nullable DataStreamTimestampField value) { * API name: {@code timestamp_field} */ public final Builder timestampField(Function> fn) { - return this.timestampField(fn.apply(new DataStreamTimestampField.Builder()).build()); + return timestampField(fn.apply(new DataStreamTimestampField.Builder()).build()); } /** - * Builds a {@link DataStream}. + * Builds a {@link IndexTemplateDataStreamConfiguration}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ - public DataStream build() { + public IndexTemplateDataStreamConfiguration build() { _checkSingleUse(); - return new DataStream(this); + return new IndexTemplateDataStreamConfiguration(this); } } // --------------------------------------------------------------------------------------------- /** - * Json deserializer for {@link DataStream} + * Json deserializer for {@link IndexTemplateDataStreamConfiguration} */ - public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( Builder::new, - DataStream::setupDataStreamDeserializer + IndexTemplateDataStreamConfiguration::setupIndexTemplateDataStreamConfigurationDeserializer ); - protected static void setupDataStreamDeserializer(ObjectDeserializer op) { - + protected static void setupIndexTemplateDataStreamConfigurationDeserializer( + ObjectDeserializer op + ) { + op.add(Builder::allowCustomRouting, JsonpDeserializer.booleanDeserializer(), "allow_custom_routing"); op.add(Builder::hidden, JsonpDeserializer.booleanDeserializer(), "hidden"); op.add(Builder::timestampField, DataStreamTimestampField._DESERIALIZER, "timestamp_field"); + } + @Override + public int hashCode() { + int result = 17; + result = 31 * result + Objects.hashCode(this.allowCustomRouting); + result = 31 * result + Objects.hashCode(this.hidden); + result = 31 * result + Objects.hashCode(this.timestampField); + return result; } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + IndexTemplateDataStreamConfiguration other = (IndexTemplateDataStreamConfiguration) o; + return Objects.equals(this.allowCustomRouting, other.allowCustomRouting) + && Objects.equals(this.hidden, other.hidden) + && Objects.equals(this.timestampField, other.timestampField); + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/indices/get_index_template/IndexTemplateSummary.java b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/IndexTemplateSummary.java similarity index 63% rename from java-client/src/main/java/org/opensearch/client/opensearch/indices/get_index_template/IndexTemplateSummary.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/indices/IndexTemplateSummary.java index c6412b4d36..9e437f702a 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/indices/get_index_template/IndexTemplateSummary.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/IndexTemplateSummary.java @@ -30,13 +30,19 @@ * GitHub history for details. */ -package org.opensearch.client.opensearch.indices.get_index_template; +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + +package org.opensearch.client.opensearch.indices; import jakarta.json.stream.JsonGenerator; import java.util.Map; +import java.util.Objects; import java.util.function.Function; +import javax.annotation.Generated; +import javax.annotation.Nonnull; import javax.annotation.Nullable; -import org.opensearch.client.json.JsonData; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.JsonpMapper; @@ -44,39 +50,46 @@ import org.opensearch.client.json.ObjectDeserializer; import org.opensearch.client.json.PlainJsonSerializable; import org.opensearch.client.opensearch._types.mapping.TypeMapping; -import org.opensearch.client.opensearch.indices.Alias; import org.opensearch.client.util.ApiTypeHelper; import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; -// typedef: indices.get_index_template.IndexTemplateSummary +// typedef: indices.IndexTemplateSummary @JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") public class IndexTemplateSummary implements PlainJsonSerializable { + + @Nonnull private final Map aliases; @Nullable private final TypeMapping mappings; - private final Map settings; + @Nullable + private final IndexSettings settings; // --------------------------------------------------------------------------------------------- private IndexTemplateSummary(Builder builder) { - this.aliases = ApiTypeHelper.unmodifiable(builder.aliases); this.mappings = builder.mappings; - this.settings = ApiTypeHelper.unmodifiable(builder.settings); - + this.settings = builder.settings; } - public static IndexTemplateSummary of(Function> fn) { + public static IndexTemplateSummary of(Function> fn) { return fn.apply(new Builder()).build(); } /** + * Aliases to add. If the index template includes a data_stream object, these are data stream aliases. Otherwise, these are + * index aliases. Data stream aliases ignore the index_routing, routing, and search_routing + * options. + *

* API name: {@code aliases} + *

*/ + @Nonnull public final Map aliases() { return this.aliases; } @@ -92,13 +105,15 @@ public final TypeMapping mappings() { /** * API name: {@code settings} */ - public final Map settings() { + @Nullable + public final IndexSettings settings() { return this.settings; } /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -106,35 +121,25 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - if (ApiTypeHelper.isDefined(this.aliases)) { generator.writeKey("aliases"); generator.writeStartObject(); for (Map.Entry item0 : this.aliases.entrySet()) { generator.writeKey(item0.getKey()); item0.getValue().serialize(generator, mapper); - } generator.writeEnd(); - } + if (this.mappings != null) { generator.writeKey("mappings"); this.mappings.serialize(generator, mapper); - } - if (ApiTypeHelper.isDefined(this.settings)) { - generator.writeKey("settings"); - generator.writeStartObject(); - for (Map.Entry item0 : this.settings.entrySet()) { - generator.writeKey(item0.getKey()); - item0.getValue().serialize(generator, mapper); - - } - generator.writeEnd(); + if (this.settings != null) { + generator.writeKey("settings"); + this.settings.serialize(generator, mapper); } - } // --------------------------------------------------------------------------------------------- @@ -142,21 +147,25 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { /** * Builder for {@link IndexTemplateSummary}. */ - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { @Nullable private Map aliases; - @Nullable private TypeMapping mappings; - @Nullable - private Map settings; + private IndexSettings settings; /** + * Aliases to add. If the index template includes a data_stream object, these are data stream aliases. Otherwise, these + * are index aliases. Data stream aliases ignore the index_routing, routing, and + * search_routing options. + *

* API name: {@code aliases} + *

+ * *

- * Adds all entries of map to aliases. + * Adds all elements of map to aliases. + *

*/ public final Builder aliases(Map map) { this.aliases = _mapPutAll(this.aliases, map); @@ -164,9 +173,16 @@ public final Builder aliases(Map map) { } /** + * Aliases to add. If the index template includes a data_stream object, these are data stream aliases. Otherwise, these + * are index aliases. Data stream aliases ignore the index_routing, routing, and + * search_routing options. + *

* API name: {@code aliases} + *

+ * *

* Adds an entry to aliases. + *

*/ public final Builder aliases(String key, Alias value) { this.aliases = _mapPut(this.aliases, key, value); @@ -174,9 +190,16 @@ public final Builder aliases(String key, Alias value) { } /** + * Aliases to add. If the index template includes a data_stream object, these are data stream aliases. Otherwise, these + * are index aliases. Data stream aliases ignore the index_routing, routing, and + * search_routing options. + *

* API name: {@code aliases} + *

+ * *

- * Adds an entry to aliases using a builder lambda. + * Adds a value to aliases using a builder lambda. + *

*/ public final Builder aliases(String key, Function> fn) { return aliases(key, fn.apply(new Alias.Builder()).build()); @@ -194,34 +217,28 @@ public final Builder mappings(@Nullable TypeMapping value) { * API name: {@code mappings} */ public final Builder mappings(Function> fn) { - return this.mappings(fn.apply(new TypeMapping.Builder()).build()); + return mappings(fn.apply(new TypeMapping.Builder()).build()); } /** * API name: {@code settings} - *

- * Adds all entries of map to settings. */ - public final Builder settings(Map map) { - this.settings = _mapPutAll(this.settings, map); + public final Builder settings(@Nullable IndexSettings value) { + this.settings = value; return this; } /** * API name: {@code settings} - *

- * Adds an entry to settings. */ - public final Builder settings(String key, JsonData value) { - this.settings = _mapPut(this.settings, key, value); - return this; + public final Builder settings(Function> fn) { + return settings(fn.apply(new IndexSettings.Builder()).build()); } /** * Builds a {@link IndexTemplateSummary}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ public IndexTemplateSummary build() { _checkSingleUse(); @@ -241,11 +258,27 @@ public IndexTemplateSummary build() { ); protected static void setupIndexTemplateSummaryDeserializer(ObjectDeserializer op) { - op.add(Builder::aliases, JsonpDeserializer.stringMapDeserializer(Alias._DESERIALIZER), "aliases"); op.add(Builder::mappings, TypeMapping._DESERIALIZER, "mappings"); - op.add(Builder::settings, JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), "settings"); + op.add(Builder::settings, IndexSettings._DESERIALIZER, "settings"); + } + @Override + public int hashCode() { + int result = 17; + result = 31 * result + Objects.hashCode(this.aliases); + result = 31 * result + Objects.hashCode(this.mappings); + result = 31 * result + Objects.hashCode(this.settings); + return result; } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + IndexTemplateSummary other = (IndexTemplateSummary) o; + return Objects.equals(this.aliases, other.aliases) + && Objects.equals(this.mappings, other.mappings) + && Objects.equals(this.settings, other.settings); + } } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/indices/OpenSearchIndicesAsyncClientBase.java b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/OpenSearchIndicesAsyncClientBase.java index 7aef6e75e3..c8f5fdd7c0 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/indices/OpenSearchIndicesAsyncClientBase.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/OpenSearchIndicesAsyncClientBase.java @@ -97,6 +97,27 @@ public final CompletableFuture delete(Function deleteIndexTemplate(DeleteIndexTemplateRequest request) throws IOException, + OpenSearchException { + return this.transport.performRequestAsync(request, DeleteIndexTemplateRequest._ENDPOINT, this.transportOptions); + } + + /** + * Deletes an index template. + * + * @param fn a function that initializes a builder to create the {@link DeleteIndexTemplateRequest} + */ + public final CompletableFuture deleteIndexTemplate( + Function> fn + ) throws IOException, OpenSearchException { + return deleteIndexTemplate(fn.apply(new DeleteIndexTemplateRequest.Builder()).build()); + } + // ----- Endpoint: indices.exists /** @@ -116,6 +137,27 @@ public final CompletableFuture exists(Function existsIndexTemplate(ExistsIndexTemplateRequest request) throws IOException, + OpenSearchException { + return this.transport.performRequestAsync(request, ExistsIndexTemplateRequest._ENDPOINT, this.transportOptions); + } + + /** + * Returns information about whether a particular index template exists. + * + * @param fn a function that initializes a builder to create the {@link ExistsIndexTemplateRequest} + */ + public final CompletableFuture existsIndexTemplate( + Function> fn + ) throws IOException, OpenSearchException { + return existsIndexTemplate(fn.apply(new ExistsIndexTemplateRequest.Builder()).build()); + } + // ----- Endpoint: indices.get /** @@ -134,4 +176,74 @@ public final CompletableFuture get(Function getIndexTemplate(GetIndexTemplateRequest request) throws IOException, + OpenSearchException { + return this.transport.performRequestAsync(request, GetIndexTemplateRequest._ENDPOINT, this.transportOptions); + } + + /** + * Returns an index template. + * + * @param fn a function that initializes a builder to create the {@link GetIndexTemplateRequest} + */ + public final CompletableFuture getIndexTemplate( + Function> fn + ) throws IOException, OpenSearchException { + return getIndexTemplate(fn.apply(new GetIndexTemplateRequest.Builder()).build()); + } + + /** + * Returns an index template. + */ + public final CompletableFuture getIndexTemplate() throws IOException, OpenSearchException { + return getIndexTemplate(new GetIndexTemplateRequest.Builder().build()); + } + + // ----- Endpoint: indices.put_index_template + + /** + * Creates or updates an index template. + */ + public CompletableFuture putIndexTemplate(PutIndexTemplateRequest request) throws IOException, + OpenSearchException { + return this.transport.performRequestAsync(request, PutIndexTemplateRequest._ENDPOINT, this.transportOptions); + } + + /** + * Creates or updates an index template. + * + * @param fn a function that initializes a builder to create the {@link PutIndexTemplateRequest} + */ + public final CompletableFuture putIndexTemplate( + Function> fn + ) throws IOException, OpenSearchException { + return putIndexTemplate(fn.apply(new PutIndexTemplateRequest.Builder()).build()); + } + + // ----- Endpoint: indices.simulate_index_template + + /** + * Simulate matching the given index name against the index templates in the system. + */ + public CompletableFuture simulateIndexTemplate(SimulateIndexTemplateRequest request) throws IOException, + OpenSearchException { + return this.transport.performRequestAsync(request, SimulateIndexTemplateRequest._ENDPOINT, this.transportOptions); + } + + /** + * Simulate matching the given index name against the index templates in the system. + * + * @param fn a function that initializes a builder to create the {@link SimulateIndexTemplateRequest} + */ + public final CompletableFuture simulateIndexTemplate( + Function> fn + ) throws IOException, OpenSearchException { + return simulateIndexTemplate(fn.apply(new SimulateIndexTemplateRequest.Builder()).build()); + } } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/indices/OpenSearchIndicesClientBase.java b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/OpenSearchIndicesClientBase.java index ffd788a06f..6eecdb7d9b 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/indices/OpenSearchIndicesClientBase.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/OpenSearchIndicesClientBase.java @@ -96,6 +96,26 @@ public final DeleteIndexResponse delete(Function> fn + ) throws IOException, OpenSearchException { + return deleteIndexTemplate(fn.apply(new DeleteIndexTemplateRequest.Builder()).build()); + } + // ----- Endpoint: indices.exists /** @@ -115,6 +135,26 @@ public final BooleanResponse exists(Function> fn + ) throws IOException, OpenSearchException { + return existsIndexTemplate(fn.apply(new ExistsIndexTemplateRequest.Builder()).build()); + } + // ----- Endpoint: indices.get /** @@ -133,4 +173,72 @@ public final GetIndexResponse get(Function> fn + ) throws IOException, OpenSearchException { + return getIndexTemplate(fn.apply(new GetIndexTemplateRequest.Builder()).build()); + } + + /** + * Returns an index template. + */ + public final GetIndexTemplateResponse getIndexTemplate() throws IOException, OpenSearchException { + return getIndexTemplate(new GetIndexTemplateRequest.Builder().build()); + } + + // ----- Endpoint: indices.put_index_template + + /** + * Creates or updates an index template. + */ + public PutIndexTemplateResponse putIndexTemplate(PutIndexTemplateRequest request) throws IOException, OpenSearchException { + return this.transport.performRequest(request, PutIndexTemplateRequest._ENDPOINT, this.transportOptions); + } + + /** + * Creates or updates an index template. + * + * @param fn a function that initializes a builder to create the {@link PutIndexTemplateRequest} + */ + public final PutIndexTemplateResponse putIndexTemplate( + Function> fn + ) throws IOException, OpenSearchException { + return putIndexTemplate(fn.apply(new PutIndexTemplateRequest.Builder()).build()); + } + + // ----- Endpoint: indices.simulate_index_template + + /** + * Simulate matching the given index name against the index templates in the system. + */ + public SimulateIndexTemplateResponse simulateIndexTemplate(SimulateIndexTemplateRequest request) throws IOException, + OpenSearchException { + return this.transport.performRequest(request, SimulateIndexTemplateRequest._ENDPOINT, this.transportOptions); + } + + /** + * Simulate matching the given index name against the index templates in the system. + * + * @param fn a function that initializes a builder to create the {@link SimulateIndexTemplateRequest} + */ + public final SimulateIndexTemplateResponse simulateIndexTemplate( + Function> fn + ) throws IOException, OpenSearchException { + return simulateIndexTemplate(fn.apply(new SimulateIndexTemplateRequest.Builder()).build()); + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/indices/PutIndexTemplateRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/PutIndexTemplateRequest.java similarity index 56% rename from java-client/src/main/java/org/opensearch/client/opensearch/indices/PutIndexTemplateRequest.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/indices/PutIndexTemplateRequest.java index b67132db45..a407a4ab5a 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/indices/PutIndexTemplateRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/PutIndexTemplateRequest.java @@ -30,13 +30,20 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch.indices; import jakarta.json.stream.JsonGenerator; -import java.util.Collections; +import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.function.Function; +import javax.annotation.Generated; +import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.opensearch.client.json.JsonData; import org.opensearch.client.json.JsonpDeserializable; @@ -47,6 +54,7 @@ import org.opensearch.client.json.PlainJsonSerializable; import org.opensearch.client.opensearch._types.ErrorResponse; import org.opensearch.client.opensearch._types.RequestBase; +import org.opensearch.client.opensearch._types.Time; import org.opensearch.client.opensearch.indices.put_index_template.IndexTemplateMapping; import org.opensearch.client.transport.Endpoint; import org.opensearch.client.transport.endpoints.SimpleEndpoint; @@ -58,19 +66,37 @@ /** * Creates or updates an index template. - * */ @JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") public class PutIndexTemplateRequest extends RequestBase implements PlainJsonSerializable { - private final Map meta; + @Nullable + private final String cause; + + @Nullable + private final Time clusterManagerTimeout; + + @Nonnull private final List composedOf; @Nullable - private final DataStream dataStream; + private final Boolean create; + + @Nullable + private final IndexTemplateDataStreamConfiguration dataStream; + @Nonnull private final List indexPatterns; + @Deprecated + @Nullable + private final Time masterTimeout; + + @Nonnull + private final Map meta; + + @Nonnull private final String name; @Nullable @@ -85,62 +111,123 @@ public class PutIndexTemplateRequest extends RequestBase implements PlainJsonSer // --------------------------------------------------------------------------------------------- private PutIndexTemplateRequest(Builder builder) { - - this.meta = ApiTypeHelper.unmodifiable(builder.meta); + this.cause = builder.cause; + this.clusterManagerTimeout = builder.clusterManagerTimeout; this.composedOf = ApiTypeHelper.unmodifiable(builder.composedOf); + this.create = builder.create; this.dataStream = builder.dataStream; this.indexPatterns = ApiTypeHelper.unmodifiable(builder.indexPatterns); + this.masterTimeout = builder.masterTimeout; + this.meta = ApiTypeHelper.unmodifiable(builder.meta); this.name = ApiTypeHelper.requireNonNull(builder.name, this, "name"); this.priority = builder.priority; this.template = builder.template; this.version = builder.version; - } - public static PutIndexTemplateRequest of(Function> fn) { + public static PutIndexTemplateRequest of(Function> fn) { return fn.apply(new Builder()).build(); } /** - * API name: {@code _meta} + * User defined reason for creating/updating the index template. + *

+ * API name: {@code cause} + *

*/ - public final Map meta() { - return this.meta; + @Nullable + public final String cause() { + return this.cause; + } + + /** + * Operation timeout for connection to cluster-manager node. + *

+ * API name: {@code cluster_manager_timeout} + *

+ */ + @Nullable + public final Time clusterManagerTimeout() { + return this.clusterManagerTimeout; } /** + * An ordered list of component template names. Component templates are merged in the order specified, meaning that the last component + * template specified has the highest precedence. + *

* API name: {@code composed_of} + *

*/ + @Nonnull public final List composedOf() { return this.composedOf; } + /** + * If true, this request cannot replace or update existing index templates. + *

+ * API name: {@code create} + *

+ */ + @Nullable + public final Boolean create() { + return this.create; + } + /** * API name: {@code data_stream} */ @Nullable - public final DataStream dataStream() { + public final IndexTemplateDataStreamConfiguration dataStream() { return this.dataStream; } /** * API name: {@code index_patterns} */ + @Nonnull public final List indexPatterns() { return this.indexPatterns; } + /** + * Operation timeout for connection to master node. + *

+ * API name: {@code master_timeout} + *

+ */ + @Deprecated + @Nullable + public final Time masterTimeout() { + return this.masterTimeout; + } + + /** + * API name: {@code _meta} + */ + @Nonnull + public final Map meta() { + return this.meta; + } + /** * Required - Index or template name *

* API name: {@code name} + *

*/ + @Nonnull public final String name() { return this.name; } /** + * Priority to determine index template precedence when a new data stream or index is created. The index template with the highest + * priority is chosen. If no priority is specified the template is treated as though it is of priority 0 (lowest priority). This number + * is not automatically generated by OpenSearch. + *

* API name: {@code priority} + *

*/ @Nullable public final Integer priority() { @@ -166,6 +253,7 @@ public final Long version() { /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -173,115 +261,126 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - - if (ApiTypeHelper.isDefined(this.meta)) { - generator.writeKey("_meta"); - generator.writeStartObject(); - for (Map.Entry item0 : this.meta.entrySet()) { - generator.writeKey(item0.getKey()); - item0.getValue().serialize(generator, mapper); - - } - generator.writeEnd(); - - } if (ApiTypeHelper.isDefined(this.composedOf)) { generator.writeKey("composed_of"); generator.writeStartArray(); for (String item0 : this.composedOf) { generator.write(item0); - } generator.writeEnd(); - } + if (this.dataStream != null) { generator.writeKey("data_stream"); this.dataStream.serialize(generator, mapper); - } + if (ApiTypeHelper.isDefined(this.indexPatterns)) { generator.writeKey("index_patterns"); generator.writeStartArray(); for (String item0 : this.indexPatterns) { generator.write(item0); - } generator.writeEnd(); + } + if (ApiTypeHelper.isDefined(this.meta)) { + generator.writeKey("_meta"); + generator.writeStartObject(); + for (Map.Entry item0 : this.meta.entrySet()) { + generator.writeKey(item0.getKey()); + item0.getValue().serialize(generator, mapper); + } + generator.writeEnd(); } + if (this.priority != null) { generator.writeKey("priority"); generator.write(this.priority); - } + if (this.template != null) { generator.writeKey("template"); this.template.serialize(generator, mapper); - } + if (this.version != null) { generator.writeKey("version"); generator.write(this.version); - } - } - // --------------------------------------------------------------------------------------------- /** * Builder for {@link PutIndexTemplateRequest}. */ - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { @Nullable - private Map meta; - + private String cause; + @Nullable + private Time clusterManagerTimeout; @Nullable private List composedOf; - @Nullable - private DataStream dataStream; - + private Boolean create; + @Nullable + private IndexTemplateDataStreamConfiguration dataStream; @Nullable private List indexPatterns; - + @Nullable + private Time masterTimeout; + @Nullable + private Map meta; private String name; - @Nullable private Integer priority; - @Nullable private IndexTemplateMapping template; - @Nullable private Long version; /** - * API name: {@code _meta} + * User defined reason for creating/updating the index template. *

- * Adds all entries of map to meta. + * API name: {@code cause} + *

*/ - public final Builder meta(Map map) { - this.meta = _mapPutAll(this.meta, map); + public final Builder cause(@Nullable String value) { + this.cause = value; return this; } /** - * API name: {@code _meta} + * Operation timeout for connection to cluster-manager node. *

- * Adds an entry to meta. + * API name: {@code cluster_manager_timeout} + *

*/ - public final Builder meta(String key, JsonData value) { - this.meta = _mapPut(this.meta, key, value); + public final Builder clusterManagerTimeout(@Nullable Time value) { + this.clusterManagerTimeout = value; return this; } /** + * Operation timeout for connection to cluster-manager node. + *

+ * API name: {@code cluster_manager_timeout} + *

+ */ + public final Builder clusterManagerTimeout(Function> fn) { + return clusterManagerTimeout(fn.apply(new Time.Builder()).build()); + } + + /** + * An ordered list of component template names. Component templates are merged in the order specified, meaning that the last + * component template specified has the highest precedence. + *

* API name: {@code composed_of} + *

+ * *

* Adds all elements of list to composedOf. + *

*/ public final Builder composedOf(List list) { this.composedOf = _listAddAll(this.composedOf, list); @@ -289,19 +388,36 @@ public final Builder composedOf(List list) { } /** + * An ordered list of component template names. Component templates are merged in the order specified, meaning that the last + * component template specified has the highest precedence. + *

* API name: {@code composed_of} + *

+ * *

* Adds one or more values to composedOf. + *

*/ public final Builder composedOf(String value, String... values) { this.composedOf = _listAdd(this.composedOf, value, values); return this; } + /** + * If true, this request cannot replace or update existing index templates. + *

+ * API name: {@code create} + *

+ */ + public final Builder create(@Nullable Boolean value) { + this.create = value; + return this; + } + /** * API name: {@code data_stream} */ - public final Builder dataStream(@Nullable DataStream value) { + public final Builder dataStream(@Nullable IndexTemplateDataStreamConfiguration value) { this.dataStream = value; return this; } @@ -309,14 +425,18 @@ public final Builder dataStream(@Nullable DataStream value) { /** * API name: {@code data_stream} */ - public final Builder dataStream(Function> fn) { - return this.dataStream(fn.apply(new DataStream.Builder()).build()); + public final Builder dataStream( + Function> fn + ) { + return dataStream(fn.apply(new IndexTemplateDataStreamConfiguration.Builder()).build()); } /** * API name: {@code index_patterns} + * *

* Adds all elements of list to indexPatterns. + *

*/ public final Builder indexPatterns(List list) { this.indexPatterns = _listAddAll(this.indexPatterns, list); @@ -325,18 +445,68 @@ public final Builder indexPatterns(List list) { /** * API name: {@code index_patterns} + * *

* Adds one or more values to indexPatterns. + *

*/ public final Builder indexPatterns(String value, String... values) { this.indexPatterns = _listAdd(this.indexPatterns, value, values); return this; } + /** + * Operation timeout for connection to master node. + *

+ * API name: {@code master_timeout} + *

+ */ + @Deprecated + public final Builder masterTimeout(@Nullable Time value) { + this.masterTimeout = value; + return this; + } + + /** + * Operation timeout for connection to master node. + *

+ * API name: {@code master_timeout} + *

+ */ + @Deprecated + public final Builder masterTimeout(Function> fn) { + return masterTimeout(fn.apply(new Time.Builder()).build()); + } + + /** + * API name: {@code _meta} + * + *

+ * Adds all elements of map to meta. + *

+ */ + public final Builder meta(Map map) { + this.meta = _mapPutAll(this.meta, map); + return this; + } + + /** + * API name: {@code _meta} + * + *

+ * Adds an entry to meta. + *

+ */ + public final Builder meta(String key, JsonData value) { + this.meta = _mapPut(this.meta, key, value); + return this; + } + /** * Required - Index or template name *

* API name: {@code name} + *

*/ public final Builder name(String value) { this.name = value; @@ -344,7 +514,12 @@ public final Builder name(String value) { } /** + * Priority to determine index template precedence when a new data stream or index is created. The index template with the highest + * priority is chosen. If no priority is specified the template is treated as though it is of priority 0 (lowest priority). This + * number is not automatically generated by OpenSearch. + *

* API name: {@code priority} + *

*/ public final Builder priority(@Nullable Integer value) { this.priority = value; @@ -363,7 +538,7 @@ public final Builder template(@Nullable IndexTemplateMapping value) { * API name: {@code template} */ public final Builder template(Function> fn) { - return this.template(fn.apply(new IndexTemplateMapping.Builder()).build()); + return template(fn.apply(new IndexTemplateMapping.Builder()).build()); } /** @@ -377,8 +552,7 @@ public final Builder version(@Nullable Long value) { /** * Builds a {@link PutIndexTemplateRequest}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ public PutIndexTemplateRequest build() { _checkSingleUse(); @@ -398,16 +572,14 @@ public PutIndexTemplateRequest build() { ); protected static void setupPutIndexTemplateRequestDeserializer(ObjectDeserializer op) { - - op.add(Builder::meta, JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), "_meta"); op.add(Builder::composedOf, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "composed_of"); - op.add(Builder::dataStream, DataStream._DESERIALIZER, "data_stream"); + op.add(Builder::dataStream, IndexTemplateDataStreamConfiguration._DESERIALIZER, "data_stream"); op.add(Builder::indexPatterns, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "index_patterns"); + op.add(Builder::meta, JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), "_meta"); + op.add(Builder::name, JsonpDeserializer.stringDeserializer(), "name"); op.add(Builder::priority, JsonpDeserializer.integerDeserializer(), "priority"); op.add(Builder::template, IndexTemplateMapping._DESERIALIZER, "template"); op.add(Builder::version, JsonpDeserializer.longDeserializer(), "version"); - op.add(Builder::name, JsonpDeserializer.stringDeserializer(), "name"); - } // --------------------------------------------------------------------------------------------- @@ -416,39 +588,71 @@ protected static void setupPutIndexTemplateRequestDeserializer(ObjectDeserialize * Endpoint "{@code indices.put_index_template}". */ public static final Endpoint _ENDPOINT = new SimpleEndpoint<>( - // Request method - request -> { - return "PUT"; - - }, - + request -> "PUT", // Request path request -> { - final int _name = 1 << 0; - - int propsSet = 0; - - propsSet |= _name; - - if (propsSet == (_name)) { - StringBuilder buf = new StringBuilder(); - buf.append("/_index_template"); - buf.append("/"); - SimpleEndpoint.pathEncode(request.name, buf); - return buf.toString(); - } - throw SimpleEndpoint.noPathTemplateFound("path"); - + StringBuilder buf = new StringBuilder(); + buf.append("/_index_template/"); + SimpleEndpoint.pathEncode(request.name, buf); + return buf.toString(); }, - // Request parameters request -> { - return Collections.emptyMap(); - + Map params = new HashMap<>(); + if (request.cause != null) { + params.put("cause", request.cause); + } + if (request.clusterManagerTimeout != null) { + params.put("cluster_manager_timeout", request.clusterManagerTimeout._toJsonString()); + } + if (request.create != null) { + params.put("create", String.valueOf(request.create)); + } + if (request.masterTimeout != null) { + params.put("master_timeout", request.masterTimeout._toJsonString()); + } + return params; }, SimpleEndpoint.emptyMap(), true, PutIndexTemplateResponse._DESERIALIZER ); + + @Override + public int hashCode() { + int result = 17; + result = 31 * result + Objects.hashCode(this.cause); + result = 31 * result + Objects.hashCode(this.clusterManagerTimeout); + result = 31 * result + Objects.hashCode(this.composedOf); + result = 31 * result + Objects.hashCode(this.create); + result = 31 * result + Objects.hashCode(this.dataStream); + result = 31 * result + Objects.hashCode(this.indexPatterns); + result = 31 * result + Objects.hashCode(this.masterTimeout); + result = 31 * result + Objects.hashCode(this.meta); + result = 31 * result + this.name.hashCode(); + result = 31 * result + Objects.hashCode(this.priority); + result = 31 * result + Objects.hashCode(this.template); + result = 31 * result + Objects.hashCode(this.version); + return result; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + PutIndexTemplateRequest other = (PutIndexTemplateRequest) o; + return Objects.equals(this.cause, other.cause) + && Objects.equals(this.clusterManagerTimeout, other.clusterManagerTimeout) + && Objects.equals(this.composedOf, other.composedOf) + && Objects.equals(this.create, other.create) + && Objects.equals(this.dataStream, other.dataStream) + && Objects.equals(this.indexPatterns, other.indexPatterns) + && Objects.equals(this.masterTimeout, other.masterTimeout) + && Objects.equals(this.meta, other.meta) + && this.name.equals(other.name) + && Objects.equals(this.priority, other.priority) + && Objects.equals(this.template, other.template) + && Objects.equals(this.version, other.version); + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/indices/PutIndexTemplateResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/PutIndexTemplateResponse.java similarity index 77% rename from java-client/src/main/java/org/opensearch/client/opensearch/indices/PutIndexTemplateResponse.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/indices/PutIndexTemplateResponse.java index 8c979c1c9e..962abd1d8d 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/indices/PutIndexTemplateResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/PutIndexTemplateResponse.java @@ -30,9 +30,14 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch.indices; import java.util.function.Function; +import javax.annotation.Generated; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.ObjectBuilderDeserializer; @@ -43,15 +48,16 @@ // typedef: indices.put_index_template.Response @JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") public class PutIndexTemplateResponse extends AcknowledgedResponseBase { + // --------------------------------------------------------------------------------------------- private PutIndexTemplateResponse(Builder builder) { super(builder); - } - public static PutIndexTemplateResponse of(Function> fn) { + public static PutIndexTemplateResponse of(Function> fn) { return fn.apply(new Builder()).build(); } @@ -60,10 +66,10 @@ public static PutIndexTemplateResponse of(Function implements ObjectBuilder { + @Override protected Builder self() { return this; @@ -72,8 +78,7 @@ protected Builder self() { /** * Builds a {@link PutIndexTemplateResponse}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ public PutIndexTemplateResponse build() { _checkSingleUse(); @@ -93,8 +98,22 @@ public PutIndexTemplateResponse build() { ); protected static void setupPutIndexTemplateResponseDeserializer(ObjectDeserializer op) { - AcknowledgedResponseBase.setupAcknowledgedResponseBaseDeserializer(op); + setupAcknowledgedResponseBaseDeserializer(op); + } + @Override + public int hashCode() { + int result = super.hashCode(); + return result; } + @Override + public boolean equals(Object o) { + if (!super.equals(o)) { + return false; + } + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + return true; + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/indices/SimulateIndexTemplateRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/SimulateIndexTemplateRequest.java similarity index 65% rename from java-client/src/main/java/org/opensearch/client/opensearch/indices/SimulateIndexTemplateRequest.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/indices/SimulateIndexTemplateRequest.java index 31ac22dec3..432d06be65 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/indices/SimulateIndexTemplateRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/SimulateIndexTemplateRequest.java @@ -30,13 +30,20 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch.indices; import jakarta.json.stream.JsonGenerator; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.function.Function; +import javax.annotation.Generated; +import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.opensearch.client.json.JsonData; import org.opensearch.client.json.JsonpDeserializable; @@ -58,34 +65,41 @@ // typedef: indices.simulate_index_template.Request /** - * Simulate matching the given index name against the index templates in the - * system - * + * Simulate matching the given index name against the index templates in the system. */ @JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") public class SimulateIndexTemplateRequest extends RequestBase implements PlainJsonSerializable { - private final Map meta; @Nullable private final Boolean allowAutoCreate; + @Nullable + private final String cause; + + @Nullable + private final Time clusterManagerTimeout; + + @Nonnull private final List composedOf; @Nullable private final Boolean create; @Nullable - private final DataStream dataStream; + private final IndexTemplateDataStreamConfiguration dataStream; + @Nonnull private final List indexPatterns; @Deprecated @Nullable private final Time masterTimeout; - @Nullable - private final Time clusterManagerTimeout; + @Nonnull + private final Map meta; + @Nonnull private final String name; @Nullable @@ -100,56 +114,82 @@ public class SimulateIndexTemplateRequest extends RequestBase implements PlainJs // --------------------------------------------------------------------------------------------- private SimulateIndexTemplateRequest(Builder builder) { - - this.meta = ApiTypeHelper.unmodifiable(builder.meta); this.allowAutoCreate = builder.allowAutoCreate; + this.cause = builder.cause; + this.clusterManagerTimeout = builder.clusterManagerTimeout; this.composedOf = ApiTypeHelper.unmodifiable(builder.composedOf); this.create = builder.create; this.dataStream = builder.dataStream; this.indexPatterns = ApiTypeHelper.unmodifiable(builder.indexPatterns); this.masterTimeout = builder.masterTimeout; - this.clusterManagerTimeout = builder.clusterManagerTimeout; + this.meta = ApiTypeHelper.unmodifiable(builder.meta); this.name = ApiTypeHelper.requireNonNull(builder.name, this, "name"); this.priority = builder.priority; this.template = builder.template; this.version = builder.version; - } - public static SimulateIndexTemplateRequest of(Function> fn) { + public static SimulateIndexTemplateRequest of( + Function> fn + ) { return fn.apply(new Builder()).build(); } /** - * API name: {@code _meta} + * This setting overrides the value of the action.auto_create_index cluster setting. If set to true in a + * template, then indices can be automatically created using that template even if auto-creation of indices is disabled via + * actions.auto_create_index. If set to false, then indices or data streams matching the template must always + * be explicitly created, and may never be automatically created. + *

+ * API name: {@code allow_auto_create} + *

*/ - public final Map meta() { - return this.meta; + @Nullable + public final Boolean allowAutoCreate() { + return this.allowAutoCreate; } /** - * API name: {@code allow_auto_create} + * User defined reason for dry-run creating the new template for simulation purposes. + *

+ * API name: {@code cause} + *

*/ @Nullable - public final Boolean allowAutoCreate() { - return this.allowAutoCreate; + public final String cause() { + return this.cause; + } + + /** + * Operation timeout for connection to cluster-manager node. + *

+ * API name: {@code cluster_manager_timeout} + *

+ */ + @Nullable + public final Time clusterManagerTimeout() { + return this.clusterManagerTimeout; } /** + * An ordered list of component template names. Component templates are merged in the order specified, meaning that the last component + * template specified has the highest precedence. + *

* API name: {@code composed_of} + *

*/ + @Nonnull public final List composedOf() { return this.composedOf; } /** - * If true, the template passed in the body is only used if no - * existing templates match the same index patterns. If false, the - * simulation uses the template with the highest priority. Note that the - * template is not permanently added or updated in either case; it is only used - * for the simulation. + * If true, the template passed in the body is only used if no existing templates match the same index patterns. If + * false, the simulation uses the template with the highest priority. Note that the template is not permanently added or + * updated in either case; it is only used for the simulation. *

* API name: {@code create} + *

*/ @Nullable public final Boolean create() { @@ -160,22 +200,24 @@ public final Boolean create() { * API name: {@code data_stream} */ @Nullable - public final DataStream dataStream() { + public final IndexTemplateDataStreamConfiguration dataStream() { return this.dataStream; } /** * API name: {@code index_patterns} */ + @Nonnull public final List indexPatterns() { return this.indexPatterns; } /** - * Period to wait for a connection to the master node. If no response is - * received before the timeout expires, the request fails and returns an error. + * Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and + * returns an error. *

* API name: {@code master_timeout} + *

*/ @Deprecated @Nullable @@ -184,27 +226,31 @@ public final Time masterTimeout() { } /** - * Period to wait for a connection to the cluster-manager node. If no response is - * received before the timeout expires, the request fails and returns an error. - *

- * API name: {@code cluster_manager_timeout} + * API name: {@code _meta} */ - @Nullable - public final Time clusterManagerTimeout() { - return this.clusterManagerTimeout; + @Nonnull + public final Map meta() { + return this.meta; } /** * Required - Index or template name to simulate *

* API name: {@code name} + *

*/ + @Nonnull public final String name() { return this.name; } /** + * Priority to determine index template precedence when a new data stream or index is created. The index template with the highest + * priority is chosen. If no priority is specified the template is treated as though it is of priority 0 (lowest priority). This number + * is not automatically generated by OpenSearch. + *

* API name: {@code priority} + *

*/ @Nullable public final Integer priority() { @@ -230,6 +276,7 @@ public final Long version() { /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -237,141 +284,147 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - - if (ApiTypeHelper.isDefined(this.meta)) { - generator.writeKey("_meta"); - generator.writeStartObject(); - for (Map.Entry item0 : this.meta.entrySet()) { - generator.writeKey(item0.getKey()); - item0.getValue().serialize(generator, mapper); - - } - generator.writeEnd(); - - } if (this.allowAutoCreate != null) { generator.writeKey("allow_auto_create"); generator.write(this.allowAutoCreate); - } + if (ApiTypeHelper.isDefined(this.composedOf)) { generator.writeKey("composed_of"); generator.writeStartArray(); for (String item0 : this.composedOf) { generator.write(item0); - } generator.writeEnd(); - } + if (this.dataStream != null) { generator.writeKey("data_stream"); this.dataStream.serialize(generator, mapper); - } + if (ApiTypeHelper.isDefined(this.indexPatterns)) { generator.writeKey("index_patterns"); generator.writeStartArray(); for (String item0 : this.indexPatterns) { generator.write(item0); - } generator.writeEnd(); + } + if (ApiTypeHelper.isDefined(this.meta)) { + generator.writeKey("_meta"); + generator.writeStartObject(); + for (Map.Entry item0 : this.meta.entrySet()) { + generator.writeKey(item0.getKey()); + item0.getValue().serialize(generator, mapper); + } + generator.writeEnd(); } + if (this.priority != null) { generator.writeKey("priority"); generator.write(this.priority); - } + if (this.template != null) { generator.writeKey("template"); this.template.serialize(generator, mapper); - } + if (this.version != null) { generator.writeKey("version"); generator.write(this.version); - } - } - // --------------------------------------------------------------------------------------------- /** * Builder for {@link SimulateIndexTemplateRequest}. */ - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - @Nullable - private Map meta; - @Nullable private Boolean allowAutoCreate; - + @Nullable + private String cause; + @Nullable + private Time clusterManagerTimeout; @Nullable private List composedOf; - @Nullable private Boolean create; - @Nullable - private DataStream dataStream; - + private IndexTemplateDataStreamConfiguration dataStream; @Nullable private List indexPatterns; - - @Deprecated @Nullable private Time masterTimeout; - @Nullable - private Time clusterManagerTimeout; - + private Map meta; private String name; - @Nullable private Integer priority; - @Nullable private IndexTemplateMapping template; - @Nullable private Long version; /** - * API name: {@code _meta} + * This setting overrides the value of the action.auto_create_index cluster setting. If set to true in a + * template, then indices can be automatically created using that template even if auto-creation of indices is disabled via + * actions.auto_create_index. If set to false, then indices or data streams matching the template must + * always be explicitly created, and may never be automatically created. *

- * Adds all entries of map to meta. + * API name: {@code allow_auto_create} + *

*/ - public final Builder meta(Map map) { - this.meta = _mapPutAll(this.meta, map); + public final Builder allowAutoCreate(@Nullable Boolean value) { + this.allowAutoCreate = value; return this; } /** - * API name: {@code _meta} + * User defined reason for dry-run creating the new template for simulation purposes. *

- * Adds an entry to meta. + * API name: {@code cause} + *

*/ - public final Builder meta(String key, JsonData value) { - this.meta = _mapPut(this.meta, key, value); + public final Builder cause(@Nullable String value) { + this.cause = value; return this; } /** - * API name: {@code allow_auto_create} + * Operation timeout for connection to cluster-manager node. + *

+ * API name: {@code cluster_manager_timeout} + *

*/ - public final Builder allowAutoCreate(@Nullable Boolean value) { - this.allowAutoCreate = value; + public final Builder clusterManagerTimeout(@Nullable Time value) { + this.clusterManagerTimeout = value; return this; } /** + * Operation timeout for connection to cluster-manager node. + *

+ * API name: {@code cluster_manager_timeout} + *

+ */ + public final Builder clusterManagerTimeout(Function> fn) { + return clusterManagerTimeout(fn.apply(new Time.Builder()).build()); + } + + /** + * An ordered list of component template names. Component templates are merged in the order specified, meaning that the last + * component template specified has the highest precedence. + *

* API name: {@code composed_of} + *

+ * *

* Adds all elements of list to composedOf. + *

*/ public final Builder composedOf(List list) { this.composedOf = _listAddAll(this.composedOf, list); @@ -379,9 +432,15 @@ public final Builder composedOf(List list) { } /** + * An ordered list of component template names. Component templates are merged in the order specified, meaning that the last + * component template specified has the highest precedence. + *

* API name: {@code composed_of} + *

+ * *

* Adds one or more values to composedOf. + *

*/ public final Builder composedOf(String value, String... values) { this.composedOf = _listAdd(this.composedOf, value, values); @@ -389,13 +448,12 @@ public final Builder composedOf(String value, String... values) { } /** - * If true, the template passed in the body is only used if no - * existing templates match the same index patterns. If false, the - * simulation uses the template with the highest priority. Note that the - * template is not permanently added or updated in either case; it is only used - * for the simulation. + * If true, the template passed in the body is only used if no existing templates match the same index patterns. If + * false, the simulation uses the template with the highest priority. Note that the template is not permanently added + * or updated in either case; it is only used for the simulation. *

* API name: {@code create} + *

*/ public final Builder create(@Nullable Boolean value) { this.create = value; @@ -405,7 +463,7 @@ public final Builder create(@Nullable Boolean value) { /** * API name: {@code data_stream} */ - public final Builder dataStream(@Nullable DataStream value) { + public final Builder dataStream(@Nullable IndexTemplateDataStreamConfiguration value) { this.dataStream = value; return this; } @@ -413,14 +471,18 @@ public final Builder dataStream(@Nullable DataStream value) { /** * API name: {@code data_stream} */ - public final Builder dataStream(Function> fn) { - return this.dataStream(fn.apply(new DataStream.Builder()).build()); + public final Builder dataStream( + Function> fn + ) { + return dataStream(fn.apply(new IndexTemplateDataStreamConfiguration.Builder()).build()); } /** * API name: {@code index_patterns} + * *

* Adds all elements of list to indexPatterns. + *

*/ public final Builder indexPatterns(List list) { this.indexPatterns = _listAddAll(this.indexPatterns, list); @@ -429,8 +491,10 @@ public final Builder indexPatterns(List list) { /** * API name: {@code index_patterns} + * *

* Adds one or more values to indexPatterns. + *

*/ public final Builder indexPatterns(String value, String... values) { this.indexPatterns = _listAdd(this.indexPatterns, value, values); @@ -438,10 +502,11 @@ public final Builder indexPatterns(String value, String... values) { } /** - * Period to wait for a connection to the master node. If no response is - * received before the timeout expires, the request fails and returns an error. + * Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and + * returns an error. *

* API name: {@code master_timeout} + *

*/ @Deprecated public final Builder masterTimeout(@Nullable Time value) { @@ -450,41 +515,46 @@ public final Builder masterTimeout(@Nullable Time value) { } /** - * Period to wait for a connection to the master node. If no response is - * received before the timeout expires, the request fails and returns an error. + * Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and + * returns an error. *

* API name: {@code master_timeout} + *

*/ @Deprecated public final Builder masterTimeout(Function> fn) { - return this.masterTimeout(fn.apply(new Time.Builder()).build()); + return masterTimeout(fn.apply(new Time.Builder()).build()); } /** - * Period to wait for a connection to the cluster-manager node. If no response is - * received before the timeout expires, the request fails and returns an error. + * API name: {@code _meta} + * *

- * API name: {@code cluster_manager_timeout} + * Adds all elements of map to meta. + *

*/ - public final Builder clusterManagerTimeout(@Nullable Time value) { - this.clusterManagerTimeout = value; + public final Builder meta(Map map) { + this.meta = _mapPutAll(this.meta, map); return this; } /** - * Period to wait for a connection to the cluster-manager node. If no response is - * received before the timeout expires, the request fails and returns an error. + * API name: {@code _meta} + * *

- * API name: {@code cluster_manager_timeout} + * Adds an entry to meta. + *

*/ - public final Builder clusterManagerTimeout(Function> fn) { - return this.clusterManagerTimeout(fn.apply(new Time.Builder()).build()); + public final Builder meta(String key, JsonData value) { + this.meta = _mapPut(this.meta, key, value); + return this; } /** * Required - Index or template name to simulate *

* API name: {@code name} + *

*/ public final Builder name(String value) { this.name = value; @@ -492,7 +562,12 @@ public final Builder name(String value) { } /** + * Priority to determine index template precedence when a new data stream or index is created. The index template with the highest + * priority is chosen. If no priority is specified the template is treated as though it is of priority 0 (lowest priority). This + * number is not automatically generated by OpenSearch. + *

* API name: {@code priority} + *

*/ public final Builder priority(@Nullable Integer value) { this.priority = value; @@ -511,7 +586,7 @@ public final Builder template(@Nullable IndexTemplateMapping value) { * API name: {@code template} */ public final Builder template(Function> fn) { - return this.template(fn.apply(new IndexTemplateMapping.Builder()).build()); + return template(fn.apply(new IndexTemplateMapping.Builder()).build()); } /** @@ -525,8 +600,7 @@ public final Builder version(@Nullable Long value) { /** * Builds a {@link SimulateIndexTemplateRequest}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ public SimulateIndexTemplateRequest build() { _checkSingleUse(); @@ -546,16 +620,15 @@ public SimulateIndexTemplateRequest build() { ); protected static void setupSimulateIndexTemplateRequestDeserializer(ObjectDeserializer op) { - - op.add(Builder::meta, JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), "_meta"); op.add(Builder::allowAutoCreate, JsonpDeserializer.booleanDeserializer(), "allow_auto_create"); op.add(Builder::composedOf, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "composed_of"); - op.add(Builder::dataStream, DataStream._DESERIALIZER, "data_stream"); + op.add(Builder::dataStream, IndexTemplateDataStreamConfiguration._DESERIALIZER, "data_stream"); op.add(Builder::indexPatterns, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "index_patterns"); + op.add(Builder::meta, JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), "_meta"); + op.add(Builder::name, JsonpDeserializer.stringDeserializer(), "name"); op.add(Builder::priority, JsonpDeserializer.integerDeserializer(), "priority"); op.add(Builder::template, IndexTemplateMapping._DESERIALIZER, "template"); op.add(Builder::version, JsonpDeserializer.longDeserializer(), "version"); - } // --------------------------------------------------------------------------------------------- @@ -565,38 +638,20 @@ protected static void setupSimulateIndexTemplateRequestDeserializer(ObjectDeseri */ public static final Endpoint _ENDPOINT = new SimpleEndpoint<>( - // Request method - request -> { - return "POST"; - - }, - + request -> "POST", // Request path request -> { - final int _name = 1 << 0; - - int propsSet = 0; - - propsSet |= _name; - - if (propsSet == (_name)) { - StringBuilder buf = new StringBuilder(); - buf.append("/_index_template"); - buf.append("/_simulate_index"); - buf.append("/"); - SimpleEndpoint.pathEncode(request.name, buf); - return buf.toString(); - } - throw SimpleEndpoint.noPathTemplateFound("path"); - + StringBuilder buf = new StringBuilder(); + buf.append("/_index_template/_simulate_index/"); + SimpleEndpoint.pathEncode(request.name, buf); + return buf.toString(); }, - // Request parameters request -> { Map params = new HashMap<>(); - if (request.masterTimeout != null) { - params.put("master_timeout", request.masterTimeout._toJsonString()); + if (request.cause != null) { + params.put("cause", request.cause); } if (request.clusterManagerTimeout != null) { params.put("cluster_manager_timeout", request.clusterManagerTimeout._toJsonString()); @@ -604,11 +659,52 @@ protected static void setupSimulateIndexTemplateRequestDeserializer(ObjectDeseri if (request.create != null) { params.put("create", String.valueOf(request.create)); } + if (request.masterTimeout != null) { + params.put("master_timeout", request.masterTimeout._toJsonString()); + } return params; - }, SimpleEndpoint.emptyMap(), true, SimulateIndexTemplateResponse._DESERIALIZER ); + + @Override + public int hashCode() { + int result = 17; + result = 31 * result + Objects.hashCode(this.allowAutoCreate); + result = 31 * result + Objects.hashCode(this.cause); + result = 31 * result + Objects.hashCode(this.clusterManagerTimeout); + result = 31 * result + Objects.hashCode(this.composedOf); + result = 31 * result + Objects.hashCode(this.create); + result = 31 * result + Objects.hashCode(this.dataStream); + result = 31 * result + Objects.hashCode(this.indexPatterns); + result = 31 * result + Objects.hashCode(this.masterTimeout); + result = 31 * result + Objects.hashCode(this.meta); + result = 31 * result + this.name.hashCode(); + result = 31 * result + Objects.hashCode(this.priority); + result = 31 * result + Objects.hashCode(this.template); + result = 31 * result + Objects.hashCode(this.version); + return result; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + SimulateIndexTemplateRequest other = (SimulateIndexTemplateRequest) o; + return Objects.equals(this.allowAutoCreate, other.allowAutoCreate) + && Objects.equals(this.cause, other.cause) + && Objects.equals(this.clusterManagerTimeout, other.clusterManagerTimeout) + && Objects.equals(this.composedOf, other.composedOf) + && Objects.equals(this.create, other.create) + && Objects.equals(this.dataStream, other.dataStream) + && Objects.equals(this.indexPatterns, other.indexPatterns) + && Objects.equals(this.masterTimeout, other.masterTimeout) + && Objects.equals(this.meta, other.meta) + && this.name.equals(other.name) + && Objects.equals(this.priority, other.priority) + && Objects.equals(this.template, other.template) + && Objects.equals(this.version, other.version); + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/indices/SimulateIndexTemplateResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/SimulateIndexTemplateResponse.java similarity index 76% rename from java-client/src/main/java/org/opensearch/client/opensearch/indices/SimulateIndexTemplateResponse.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/indices/SimulateIndexTemplateResponse.java index 4bbb597ad1..0d058d36c9 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/indices/SimulateIndexTemplateResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/SimulateIndexTemplateResponse.java @@ -30,12 +30,18 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch.indices; +import javax.annotation.Generated; import org.opensearch.client.json.JsonpDeserializer; // typedef: indices.simulate_index_template.Response +@Generated("org.opensearch.client.codegen.CodeGenerator") public class SimulateIndexTemplateResponse { public SimulateIndexTemplateResponse() {} @@ -48,4 +54,16 @@ public SimulateIndexTemplateResponse() {} SimulateIndexTemplateResponse._INSTANCE ); + @Override + public int hashCode() { + int result = 17; + return result; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + return true; + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/indices/get_index_template/IndexTemplateItem.java b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/get_index_template/IndexTemplateItem.java similarity index 80% rename from java-client/src/main/java/org/opensearch/client/opensearch/indices/get_index_template/IndexTemplateItem.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/indices/get_index_template/IndexTemplateItem.java index f61d16e8ac..314d9355a1 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/indices/get_index_template/IndexTemplateItem.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/get_index_template/IndexTemplateItem.java @@ -30,16 +30,23 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch.indices.get_index_template; import jakarta.json.stream.JsonGenerator; import java.util.function.Function; +import javax.annotation.Generated; +import javax.annotation.Nonnull; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.JsonpMapper; import org.opensearch.client.json.ObjectBuilderDeserializer; import org.opensearch.client.json.ObjectDeserializer; import org.opensearch.client.json.PlainJsonSerializable; +import org.opensearch.client.opensearch.indices.IndexTemplate; import org.opensearch.client.util.ApiTypeHelper; import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; @@ -47,41 +54,46 @@ // typedef: indices.get_index_template.IndexTemplateItem @JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") public class IndexTemplateItem implements PlainJsonSerializable { - private final String name; + @Nonnull private final IndexTemplate indexTemplate; + @Nonnull + private final String name; + // --------------------------------------------------------------------------------------------- private IndexTemplateItem(Builder builder) { - - this.name = ApiTypeHelper.requireNonNull(builder.name, this, "name"); this.indexTemplate = ApiTypeHelper.requireNonNull(builder.indexTemplate, this, "indexTemplate"); - + this.name = ApiTypeHelper.requireNonNull(builder.name, this, "name"); } - public static IndexTemplateItem of(Function> fn) { + public static IndexTemplateItem of(Function> fn) { return fn.apply(new Builder()).build(); } /** - * Required - API name: {@code name} + * Required - API name: {@code index_template} */ - public final String name() { - return this.name; + @Nonnull + public final IndexTemplate indexTemplate() { + return this.indexTemplate; } /** - * Required - API name: {@code index_template} + * Required - API name: {@code name} */ - public final IndexTemplate indexTemplate() { - return this.indexTemplate; + @Nonnull + public final String name() { + return this.name; } /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -89,13 +101,11 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - - generator.writeKey("name"); - generator.write(this.name); - generator.writeKey("index_template"); this.indexTemplate.serialize(generator, mapper); + generator.writeKey("name"); + generator.write(this.name); } // --------------------------------------------------------------------------------------------- @@ -103,19 +113,9 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { /** * Builder for {@link IndexTemplateItem}. */ - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - private String name; - private IndexTemplate indexTemplate; - - /** - * Required - API name: {@code name} - */ - public final Builder name(String value) { - this.name = value; - return this; - } + private String name; /** * Required - API name: {@code index_template} @@ -129,14 +129,21 @@ public final Builder indexTemplate(IndexTemplate value) { * Required - API name: {@code index_template} */ public final Builder indexTemplate(Function> fn) { - return this.indexTemplate(fn.apply(new IndexTemplate.Builder()).build()); + return indexTemplate(fn.apply(new IndexTemplate.Builder()).build()); + } + + /** + * Required - API name: {@code name} + */ + public final Builder name(String value) { + this.name = value; + return this; } /** * Builds a {@link IndexTemplateItem}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ public IndexTemplateItem build() { _checkSingleUse(); @@ -156,10 +163,23 @@ public IndexTemplateItem build() { ); protected static void setupIndexTemplateItemDeserializer(ObjectDeserializer op) { - - op.add(Builder::name, JsonpDeserializer.stringDeserializer(), "name"); op.add(Builder::indexTemplate, IndexTemplate._DESERIALIZER, "index_template"); + op.add(Builder::name, JsonpDeserializer.stringDeserializer(), "name"); + } + @Override + public int hashCode() { + int result = 17; + result = 31 * result + this.indexTemplate.hashCode(); + result = 31 * result + this.name.hashCode(); + return result; } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + IndexTemplateItem other = (IndexTemplateItem) o; + return this.indexTemplate.equals(other.indexTemplate) && this.name.equals(other.name); + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/indices/put_index_template/IndexTemplateMapping.java b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/put_index_template/IndexTemplateMapping.java similarity index 71% rename from java-client/src/main/java/org/opensearch/client/opensearch/indices/put_index_template/IndexTemplateMapping.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/indices/put_index_template/IndexTemplateMapping.java index 638b5e8afa..20aab19f36 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/indices/put_index_template/IndexTemplateMapping.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/indices/put_index_template/IndexTemplateMapping.java @@ -30,11 +30,18 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch.indices.put_index_template; import jakarta.json.stream.JsonGenerator; import java.util.Map; +import java.util.Objects; import java.util.function.Function; +import javax.annotation.Generated; +import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; @@ -53,7 +60,10 @@ // typedef: indices.put_index_template.IndexTemplateMapping @JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") public class IndexTemplateMapping implements PlainJsonSerializable { + + @Nonnull private final Map aliases; @Nullable @@ -65,20 +75,24 @@ public class IndexTemplateMapping implements PlainJsonSerializable { // --------------------------------------------------------------------------------------------- private IndexTemplateMapping(Builder builder) { - this.aliases = ApiTypeHelper.unmodifiable(builder.aliases); this.mappings = builder.mappings; this.settings = builder.settings; - } - public static IndexTemplateMapping of(Function> fn) { + public static IndexTemplateMapping of(Function> fn) { return fn.apply(new Builder()).build(); } /** + * Aliases to add. If the index template includes a data_stream object, these are data stream aliases. Otherwise, these are + * index aliases. Data stream aliases ignore the index_routing, routing, and search_routing + * options. + *

* API name: {@code aliases} + *

*/ + @Nonnull public final Map aliases() { return this.aliases; } @@ -102,6 +116,7 @@ public final IndexSettings settings() { /** * Serialize this object to JSON. */ + @Override public void serialize(JsonGenerator generator, JsonpMapper mapper) { generator.writeStartObject(); serializeInternal(generator, mapper); @@ -109,29 +124,25 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - if (ApiTypeHelper.isDefined(this.aliases)) { generator.writeKey("aliases"); generator.writeStartObject(); for (Map.Entry item0 : this.aliases.entrySet()) { generator.writeKey(item0.getKey()); item0.getValue().serialize(generator, mapper); - } generator.writeEnd(); - } + if (this.mappings != null) { generator.writeKey("mappings"); this.mappings.serialize(generator, mapper); - } + if (this.settings != null) { generator.writeKey("settings"); this.settings.serialize(generator, mapper); - } - } // --------------------------------------------------------------------------------------------- @@ -139,21 +150,30 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { /** * Builder for {@link IndexTemplateMapping}. */ - public static class Builder extends ObjectBuilderBase implements ObjectBuilder, PlainDeserializable { + @Override + public Builder self() { + return this; + } + @Nullable private Map aliases; - @Nullable private TypeMapping mappings; - @Nullable private IndexSettings settings; /** + * Aliases to add. If the index template includes a data_stream object, these are data stream aliases. Otherwise, these + * are index aliases. Data stream aliases ignore the index_routing, routing, and + * search_routing options. + *

* API name: {@code aliases} + *

+ * *

- * Adds all entries of map to aliases. + * Adds all elements of map to aliases. + *

*/ public final Builder aliases(Map map) { this.aliases = _mapPutAll(this.aliases, map); @@ -161,9 +181,16 @@ public final Builder aliases(Map map) { } /** + * Aliases to add. If the index template includes a data_stream object, these are data stream aliases. Otherwise, these + * are index aliases. Data stream aliases ignore the index_routing, routing, and + * search_routing options. + *

* API name: {@code aliases} + *

+ * *

* Adds an entry to aliases. + *

*/ public final Builder aliases(String key, Alias value) { this.aliases = _mapPut(this.aliases, key, value); @@ -171,9 +198,16 @@ public final Builder aliases(String key, Alias value) { } /** + * Aliases to add. If the index template includes a data_stream object, these are data stream aliases. Otherwise, these + * are index aliases. Data stream aliases ignore the index_routing, routing, and + * search_routing options. + *

* API name: {@code aliases} + *

+ * *

- * Adds an entry to aliases using a builder lambda. + * Adds a value to aliases using a builder lambda. + *

*/ public final Builder aliases(String key, Function> fn) { return aliases(key, fn.apply(new Alias.Builder()).build()); @@ -191,7 +225,7 @@ public final Builder mappings(@Nullable TypeMapping value) { * API name: {@code mappings} */ public final Builder mappings(Function> fn) { - return this.mappings(fn.apply(new TypeMapping.Builder()).build()); + return mappings(fn.apply(new TypeMapping.Builder()).build()); } /** @@ -206,25 +240,19 @@ public final Builder settings(@Nullable IndexSettings value) { * API name: {@code settings} */ public final Builder settings(Function> fn) { - return this.settings(fn.apply(new IndexSettings.Builder()).build()); + return settings(fn.apply(new IndexSettings.Builder()).build()); } /** * Builds a {@link IndexTemplateMapping}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ public IndexTemplateMapping build() { _checkSingleUse(); return new IndexTemplateMapping(this); } - - @Override - public Builder self() { - return this; - } } // --------------------------------------------------------------------------------------------- @@ -238,11 +266,27 @@ public Builder self() { ); protected static void setupIndexTemplateMappingDeserializer(ObjectDeserializer op) { - op.add(Builder::aliases, JsonpDeserializer.stringMapDeserializer(Alias._DESERIALIZER), "aliases"); op.add(Builder::mappings, TypeMapping._DESERIALIZER, "mappings"); op.add(Builder::settings, IndexSettings._DESERIALIZER, "settings"); + } + @Override + public int hashCode() { + int result = 17; + result = 31 * result + Objects.hashCode(this.aliases); + result = 31 * result + Objects.hashCode(this.mappings); + result = 31 * result + Objects.hashCode(this.settings); + return result; } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + IndexTemplateMapping other = (IndexTemplateMapping) o; + return Objects.equals(this.aliases, other.aliases) + && Objects.equals(this.mappings, other.mappings) + && Objects.equals(this.settings, other.settings); + } } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/CloneSnapshotRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/CloneSnapshotRequest.java index e4ffc8d46a..01a0d9ab0b 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/CloneSnapshotRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/snapshot/CloneSnapshotRequest.java @@ -304,6 +304,9 @@ public CloneSnapshotRequest build() { protected static void setupCloneSnapshotRequestDeserializer(ObjectDeserializer op) { op.add(Builder::indices, JsonpDeserializer.stringDeserializer(), "indices"); + op.add(Builder::repository, JsonpDeserializer.stringDeserializer(), "repository"); + op.add(Builder::snapshot, JsonpDeserializer.stringDeserializer(), "snapshot"); + op.add(Builder::targetSnapshot, JsonpDeserializer.stringDeserializer(), "target_snapshot"); } // --------------------------------------------------------------------------------------------- diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/indices/DeleteIndexTemplateRequest.java b/java-client/src/main/java/org/opensearch/client/opensearch/indices/DeleteIndexTemplateRequest.java deleted file mode 100644 index f8599d2069..0000000000 --- a/java-client/src/main/java/org/opensearch/client/opensearch/indices/DeleteIndexTemplateRequest.java +++ /dev/null @@ -1,149 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. 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. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.client.opensearch.indices; - -import java.util.Collections; -import java.util.function.Function; -import org.opensearch.client.opensearch._types.ErrorResponse; -import org.opensearch.client.opensearch._types.RequestBase; -import org.opensearch.client.transport.Endpoint; -import org.opensearch.client.transport.endpoints.SimpleEndpoint; -import org.opensearch.client.util.ApiTypeHelper; -import org.opensearch.client.util.ObjectBuilder; -import org.opensearch.client.util.ObjectBuilderBase; - -// typedef: indices.delete_index_template.Request - -/** - * Deletes an index template. - * - */ - -public class DeleteIndexTemplateRequest extends RequestBase { - private final String name; - - // --------------------------------------------------------------------------------------------- - - private DeleteIndexTemplateRequest(Builder builder) { - - this.name = ApiTypeHelper.requireNonNull(builder.name, this, "name"); - - } - - public static DeleteIndexTemplateRequest of(Function> fn) { - return fn.apply(new Builder()).build(); - } - - /** - * Required - The name of the template - *

- * API name: {@code name} - */ - public final String name() { - return this.name; - } - - // --------------------------------------------------------------------------------------------- - - /** - * Builder for {@link DeleteIndexTemplateRequest}. - */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - private String name; - - /** - * Required - The name of the template - *

- * API name: {@code name} - */ - public final Builder name(String value) { - this.name = value; - return this; - } - - /** - * Builds a {@link DeleteIndexTemplateRequest}. - * - * @throws NullPointerException - * if some of the required fields are null. - */ - public DeleteIndexTemplateRequest build() { - _checkSingleUse(); - - return new DeleteIndexTemplateRequest(this); - } - } - - // --------------------------------------------------------------------------------------------- - - /** - * Endpoint "{@code indices.delete_index_template}". - */ - public static final Endpoint _ENDPOINT = new SimpleEndpoint<>( - - // Request method - request -> { - return "DELETE"; - - }, - - // Request path - request -> { - final int _name = 1 << 0; - - int propsSet = 0; - - propsSet |= _name; - - if (propsSet == (_name)) { - StringBuilder buf = new StringBuilder(); - buf.append("/_index_template"); - buf.append("/"); - SimpleEndpoint.pathEncode(request.name, buf); - return buf.toString(); - } - throw SimpleEndpoint.noPathTemplateFound("path"); - - }, - - // Request parameters - request -> { - return Collections.emptyMap(); - - }, - SimpleEndpoint.emptyMap(), - false, - DeleteIndexTemplateResponse._DESERIALIZER - ); -} diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/indices/ExistsIndexTemplateResponse.java b/java-client/src/main/java/org/opensearch/client/opensearch/indices/ExistsIndexTemplateResponse.java deleted file mode 100644 index 951a32012f..0000000000 --- a/java-client/src/main/java/org/opensearch/client/opensearch/indices/ExistsIndexTemplateResponse.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. 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. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.client.opensearch.indices; - -import org.opensearch.client.json.JsonpDeserializer; - -// typedef: indices.exists_index_template.Response - -public class ExistsIndexTemplateResponse { - public ExistsIndexTemplateResponse() {} - - /** - * Singleton instance for {@link ExistsIndexTemplateResponse}. - */ - public static final ExistsIndexTemplateResponse _INSTANCE = new ExistsIndexTemplateResponse(); - - public static final JsonpDeserializer _DESERIALIZER = JsonpDeserializer.fixedValue( - ExistsIndexTemplateResponse._INSTANCE - ); - -} diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/indices/OpenSearchIndicesAsyncClient.java b/java-client/src/main/java/org/opensearch/client/opensearch/indices/OpenSearchIndicesAsyncClient.java index f90140a6a5..a400064f26 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/indices/OpenSearchIndicesAsyncClient.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/indices/OpenSearchIndicesAsyncClient.java @@ -343,40 +343,6 @@ public final CompletableFuture deleteAlias( return deleteAlias(fn.apply(new DeleteAliasRequest.Builder()).build()); } - // ----- Endpoint: indices.delete_index_template - - /** - * Deletes an index template. - * - * - */ - - public CompletableFuture deleteIndexTemplate(DeleteIndexTemplateRequest request) throws IOException, - OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = (JsonEndpoint< - DeleteIndexTemplateRequest, - DeleteIndexTemplateResponse, - ErrorResponse>) DeleteIndexTemplateRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Deletes an index template. - * - * @param fn - * a function that initializes a builder to create the - * {@link DeleteIndexTemplateRequest} - * - */ - - public final CompletableFuture deleteIndexTemplate( - Function> fn - ) throws IOException, OpenSearchException { - return deleteIndexTemplate(fn.apply(new DeleteIndexTemplateRequest.Builder()).build()); - } - // ----- Endpoint: indices.delete_template /** @@ -474,40 +440,6 @@ public final CompletableFuture existsAlias(Function existsIndexTemplate(ExistsIndexTemplateRequest request) throws IOException, - OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = (JsonEndpoint< - ExistsIndexTemplateRequest, - BooleanResponse, - ErrorResponse>) ExistsIndexTemplateRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Returns information about whether a particular index template exists. - * - * @param fn - * a function that initializes a builder to create the - * {@link ExistsIndexTemplateRequest} - * - */ - - public final CompletableFuture existsIndexTemplate( - Function> fn - ) throws IOException, OpenSearchException { - return existsIndexTemplate(fn.apply(new ExistsIndexTemplateRequest.Builder()).build()); - } - // ----- Endpoint: indices.exists_template /** @@ -752,54 +684,6 @@ public final CompletableFuture getFieldMapping( return getFieldMapping(fn.apply(new GetFieldMappingRequest.Builder()).build()); } - // ----- Endpoint: indices.get_index_template - - /** - * Returns an index template. - * - * - */ - - public CompletableFuture getIndexTemplate(GetIndexTemplateRequest request) throws IOException, - OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = (JsonEndpoint< - GetIndexTemplateRequest, - GetIndexTemplateResponse, - ErrorResponse>) GetIndexTemplateRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Returns an index template. - * - * @param fn - * a function that initializes a builder to create the - * {@link GetIndexTemplateRequest} - * - */ - - public final CompletableFuture getIndexTemplate( - Function> fn - ) throws IOException, OpenSearchException { - return getIndexTemplate(fn.apply(new GetIndexTemplateRequest.Builder()).build()); - } - - /** - * Returns an index template. - * - * - */ - - public CompletableFuture getIndexTemplate() throws IOException, OpenSearchException { - return this.transport.performRequestAsync( - new GetIndexTemplateRequest.Builder().build(), - GetIndexTemplateRequest._ENDPOINT, - this.transportOptions - ); - } - // ----- Endpoint: indices.get_mapping /** @@ -1051,40 +935,6 @@ public final CompletableFuture putAlias(Function putIndexTemplate(PutIndexTemplateRequest request) throws IOException, - OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = (JsonEndpoint< - PutIndexTemplateRequest, - PutIndexTemplateResponse, - ErrorResponse>) PutIndexTemplateRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Creates or updates an index template. - * - * @param fn - * a function that initializes a builder to create the - * {@link PutIndexTemplateRequest} - * - */ - - public final CompletableFuture putIndexTemplate( - Function> fn - ) throws IOException, OpenSearchException { - return putIndexTemplate(fn.apply(new PutIndexTemplateRequest.Builder()).build()); - } - // ----- Endpoint: indices.put_mapping /** @@ -1470,42 +1320,6 @@ public final CompletableFuture shrink(Function simulateIndexTemplate(SimulateIndexTemplateRequest request) throws IOException, - OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = (JsonEndpoint< - SimulateIndexTemplateRequest, - SimulateIndexTemplateResponse, - ErrorResponse>) SimulateIndexTemplateRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Simulate matching the given index name against the index templates in the - * system - * - * @param fn - * a function that initializes a builder to create the - * {@link SimulateIndexTemplateRequest} - * - */ - - public final CompletableFuture simulateIndexTemplate( - Function> fn - ) throws IOException, OpenSearchException { - return simulateIndexTemplate(fn.apply(new SimulateIndexTemplateRequest.Builder()).build()); - } - // ----- Endpoint: indices.simulate_template /** diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/indices/OpenSearchIndicesClient.java b/java-client/src/main/java/org/opensearch/client/opensearch/indices/OpenSearchIndicesClient.java index 85a108f1fb..3c779e855c 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/indices/OpenSearchIndicesClient.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/indices/OpenSearchIndicesClient.java @@ -327,39 +327,6 @@ public final DeleteAliasResponse deleteAlias(Function endpoint = (JsonEndpoint< - DeleteIndexTemplateRequest, - DeleteIndexTemplateResponse, - ErrorResponse>) DeleteIndexTemplateRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Deletes an index template. - * - * @param fn - * a function that initializes a builder to create the - * {@link DeleteIndexTemplateRequest} - * - */ - - public final DeleteIndexTemplateResponse deleteIndexTemplate( - Function> fn - ) throws IOException, OpenSearchException { - return deleteIndexTemplate(fn.apply(new DeleteIndexTemplateRequest.Builder()).build()); - } - // ----- Endpoint: indices.delete_template /** @@ -456,39 +423,6 @@ public final BooleanResponse existsAlias(Function endpoint = (JsonEndpoint< - ExistsIndexTemplateRequest, - BooleanResponse, - ErrorResponse>) ExistsIndexTemplateRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Returns information about whether a particular index template exists. - * - * @param fn - * a function that initializes a builder to create the - * {@link ExistsIndexTemplateRequest} - * - */ - - public final BooleanResponse existsIndexTemplate( - Function> fn - ) throws IOException, OpenSearchException { - return existsIndexTemplate(fn.apply(new ExistsIndexTemplateRequest.Builder()).build()); - } - // ----- Endpoint: indices.exists_template /** @@ -725,53 +659,6 @@ public final GetFieldMappingResponse getFieldMapping(Function endpoint = (JsonEndpoint< - GetIndexTemplateRequest, - GetIndexTemplateResponse, - ErrorResponse>) GetIndexTemplateRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Returns an index template. - * - * @param fn - * a function that initializes a builder to create the - * {@link GetIndexTemplateRequest} - * - */ - - public final GetIndexTemplateResponse getIndexTemplate( - Function> fn - ) throws IOException, OpenSearchException { - return getIndexTemplate(fn.apply(new GetIndexTemplateRequest.Builder()).build()); - } - - /** - * Returns an index template. - * - * - */ - - public GetIndexTemplateResponse getIndexTemplate() throws IOException, OpenSearchException { - return this.transport.performRequest( - new GetIndexTemplateRequest.Builder().build(), - GetIndexTemplateRequest._ENDPOINT, - this.transportOptions - ); - } - // ----- Endpoint: indices.get_mapping /** @@ -1008,39 +895,6 @@ public final PutAliasResponse putAlias(Function endpoint = (JsonEndpoint< - PutIndexTemplateRequest, - PutIndexTemplateResponse, - ErrorResponse>) PutIndexTemplateRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Creates or updates an index template. - * - * @param fn - * a function that initializes a builder to create the - * {@link PutIndexTemplateRequest} - * - */ - - public final PutIndexTemplateResponse putIndexTemplate( - Function> fn - ) throws IOException, OpenSearchException { - return putIndexTemplate(fn.apply(new PutIndexTemplateRequest.Builder()).build()); - } - // ----- Endpoint: indices.put_mapping /** @@ -1418,42 +1272,6 @@ public final ShrinkResponse shrink(Function endpoint = (JsonEndpoint< - SimulateIndexTemplateRequest, - SimulateIndexTemplateResponse, - ErrorResponse>) SimulateIndexTemplateRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Simulate matching the given index name against the index templates in the - * system - * - * @param fn - * a function that initializes a builder to create the - * {@link SimulateIndexTemplateRequest} - * - */ - - public final SimulateIndexTemplateResponse simulateIndexTemplate( - Function> fn - ) throws IOException, OpenSearchException { - return simulateIndexTemplate(fn.apply(new SimulateIndexTemplateRequest.Builder()).build()); - } - // ----- Endpoint: indices.simulate_template /** diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/indices/SimulateTemplateRequest.java b/java-client/src/main/java/org/opensearch/client/opensearch/indices/SimulateTemplateRequest.java index 49ce178988..68e3b23fce 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/indices/SimulateTemplateRequest.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/indices/SimulateTemplateRequest.java @@ -44,7 +44,6 @@ import org.opensearch.client.opensearch._types.ErrorResponse; import org.opensearch.client.opensearch._types.RequestBase; import org.opensearch.client.opensearch._types.Time; -import org.opensearch.client.opensearch.indices.get_index_template.IndexTemplate; import org.opensearch.client.transport.Endpoint; import org.opensearch.client.transport.endpoints.SimpleEndpoint; import org.opensearch.client.util.ApiTypeHelper; diff --git a/java-client/src/test/java/org/opensearch/client/transport/util/FunnellingHttpsProxy.java b/java-client/src/test/java/org/opensearch/client/transport/util/FunnellingHttpsProxy.java index 19b62a7eb6..eef2416487 100644 --- a/java-client/src/test/java/org/opensearch/client/transport/util/FunnellingHttpsProxy.java +++ b/java-client/src/test/java/org/opensearch/client/transport/util/FunnellingHttpsProxy.java @@ -28,7 +28,7 @@ import org.apache.hc.core5.http.impl.EnglishReasonPhraseCatalog; public class FunnellingHttpsProxy implements Closeable { - private static final int SO_TIMEOUT = 5000; + private static final int SO_TIMEOUT = 10000; @Nonnull private final ServerSocket serverSocket; diff --git a/java-client/src/test/java11/org/opensearch/client/opensearch/integTest/AbstractIndicesClientIT.java b/java-client/src/test/java11/org/opensearch/client/opensearch/integTest/AbstractIndicesClientIT.java index 11d7de218f..09747c666c 100644 --- a/java-client/src/test/java11/org/opensearch/client/opensearch/integTest/AbstractIndicesClientIT.java +++ b/java-client/src/test/java11/org/opensearch/client/opensearch/integTest/AbstractIndicesClientIT.java @@ -22,7 +22,6 @@ import org.opensearch.client.opensearch.indices.CreateDataStreamResponse; import org.opensearch.client.opensearch.indices.CreateIndexRequest; import org.opensearch.client.opensearch.indices.CreateIndexResponse; -import org.opensearch.client.opensearch.indices.DataStream; import org.opensearch.client.opensearch.indices.DataStreamsStatsResponse; import org.opensearch.client.opensearch.indices.DeleteDataStreamResponse; import org.opensearch.client.opensearch.indices.GetAliasRequest; @@ -127,7 +126,7 @@ public void testDataStream() throws IOException { PutIndexTemplateResponse putIndexTemplateResponse = javaClient().indices() .putIndexTemplate( b -> b.name(dataStreamIndexTemplateName) - .dataStream(new DataStream.Builder().timestampField(bd -> bd.name(timestampFieldName)).build()) + .dataStream(ds -> ds.timestampField(bd -> bd.name(timestampFieldName))) .indexPatterns(namePattern) ); assertTrue(putIndexTemplateResponse.acknowledged()); diff --git a/java-codegen/opensearch-openapi.yaml b/java-codegen/opensearch-openapi.yaml index 8dd8aab304..3d39385521 100644 --- a/java-codegen/opensearch-openapi.yaml +++ b/java-codegen/opensearch-openapi.yaml @@ -10210,8 +10210,8 @@ paths: requestBody: $ref: '#/components/requestBodies/create' responses: - '200': - $ref: '#/components/responses/create___200' + '201': + $ref: '#/components/responses/create___201' put: operationId: create.1 x-operation-group: create @@ -10240,8 +10240,8 @@ paths: requestBody: $ref: '#/components/requestBodies/create' responses: - '200': - $ref: '#/components/responses/create___200' + '201': + $ref: '#/components/responses/create___201' /{index}/_delete_by_query: post: operationId: delete_by_query.0 @@ -10415,6 +10415,8 @@ paths: responses: '200': $ref: '#/components/responses/exists___200' + '404': + $ref: '#/components/responses/exists___404' post: operationId: index.1 x-operation-group: index @@ -28037,7 +28039,7 @@ components: type: integer format: int64 description: '' - create___200: + create___201: content: application/json: schema: @@ -28137,6 +28139,10 @@ components: content: application/json: {} description: '' + exists___404: + content: + application/json: {} + description: '' explain___200: content: application/json: @@ -39275,6 +39281,12 @@ components: $ref: '#/components/schemas/_common.analysis___IcuCollationStrength' variable_top: type: string + country: + type: string + language: + type: string + variant: + type: string required: - type _common.mapping___IndexField: diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/CodeGenerator.java b/java-codegen/src/main/java/org/opensearch/client/codegen/CodeGenerator.java index 7a79aecbe6..0236f7bdd2 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/CodeGenerator.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/CodeGenerator.java @@ -43,7 +43,20 @@ public class CodeGenerator { private static final OperationGroupMatcher OPERATION_MATCHER = or( and(namespace(""), named("info")), namespace("dangling_indices"), - and(namespace("indices"), named("create", "delete", "exists", "get")), + and( + namespace("indices"), + named( + "create", + "delete", + "delete_index_template", + "exists", + "exists_index_template", + "get", + "get_index_template", + "put_index_template", + "simulate_index_template" + ) + ), and(namespace("ml"), not(named("search_models"))), // TODO: search_models is complex and ideally should re-use the search structures and(namespace("snapshot"), named("cleanup_repository", "clone", "verify_repository")), and(namespace("tasks")) diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/ObjectShape.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/ObjectShape.java index 3cbabe8754..12fab62b95 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/ObjectShape.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/ObjectShape.java @@ -72,10 +72,18 @@ public void setShortcutProperty(String shortcutProperty) { this.shortcutProperty = shortcutProperty; } + public Collection getFieldsToSerialize() { + return getBodyFields(); + } + public boolean hasFieldsToSerialize() { return !bodyFields.isEmpty() || additionalPropertiesField != null; } + public Collection getFieldsToDeserialize() { + return getBodyFields(); + } + public Collection getReferencingDiscriminatedUnions() { return getIncomingReference(ReferenceKind.UnionVariant).stream() .map(s -> (TaggedUnionShape) s) @@ -119,7 +127,11 @@ public Collection getAnnotations() { } public boolean shouldImplementPlainDeserializable() { - return Set.of("SourceField", "TypeMapping").contains(getClassName()); + return Set.of("IndexTemplateMapping", "SourceField", "TypeMapping").contains(getClassName()); + } + + public boolean canBeSingleton() { + return bodyFields.isEmpty() && additionalPropertiesField == null && !extendsOtherShape(); } public static class ReferencingDiscriminatedUnion { diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/RequestShape.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/RequestShape.java index df8ffabe6f..0877974e78 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/RequestShape.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/RequestShape.java @@ -93,10 +93,18 @@ public Type getResponseType() { : Types.Client.Transport.Endpoints.BooleanResponse; } + @Override public boolean canBeSingleton() { return !hasRequestBody() && !hasQueryParams() && hasSinglePath() && !getFirstPath().hasParams(); } + @Override + public Collection getFieldsToDeserialize() { + var fields = new TreeMap<>(bodyFields); + fields.putAll(pathParams); + return fields.values(); + } + public boolean hasRequestBody() { return !getBodyFields().isEmpty(); } diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape.mustache index 25bf01d350..c5955b768c 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape.mustache @@ -1,4 +1,15 @@ {{>Partials/ClassDeclaration}} { +{{#canBeSingleton}} + public {{className}}() {} + + /** + * Singleton instance for {@link {{className}}}. + */ + public static final {{className}} _INSTANCE = new {{className}}(); + + public static final {{TYPES.Client.Json.JsonpDeserializer}}<{{className}}> _DESERIALIZER = {{TYPES.Client.Json.JsonpDeserializer}}.fixedValue({{className}}._INSTANCE); +{{/canBeSingleton}} +{{^canBeSingleton}} {{>ObjectShape/Fields}} // --------------------------------------------------------------------------------------------- @@ -28,6 +39,7 @@ // --------------------------------------------------------------------------------------------- {{>ObjectShape/Deserialize}} +{{/canBeSingleton}} {{>ObjectShape/HashCode}} diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Deserialize.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Deserialize.mustache index 4d37bb6a2f..6d3e14591b 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Deserialize.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Deserialize.mustache @@ -14,9 +14,9 @@ {{#extendsOtherShape}} setup{{extendsType.name}}Deserializer(op{{#extendsType.typeParams}}, {{>Type/deserializer}}{{/extendsType.typeParams}}); {{/extendsOtherShape}} - {{#bodyFields}} + {{#fieldsToDeserialize}} op.add({{#extendedByOtherShape}}Abstract{{/extendedByOtherShape}}Builder::{{name}}, {{#type}}{{>Type/deserializer}}{{/type}}, {{#quoted}}{{wireName}}{{/quoted}}{{#aliases}}, {{#quoted}}{{.}}{{/quoted}}{{/aliases}}); - {{/bodyFields}} + {{/fieldsToDeserialize}} {{#additionalPropertiesField}} op.setUnknownFieldHandler((builder, name, parser, mapper) -> { if (builder.{{name}} == null) { diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Serialize.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Serialize.mustache index 130c94bcec..36f3b13dcd 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Serialize.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Serialize.mustache @@ -20,7 +20,7 @@ {{#additionalPropertiesField}} {{#type.directSerializer}}this.{{name}}{{/type.directSerializer}} {{/additionalPropertiesField}} -{{#bodyFields}} +{{#fieldsToSerialize}} {{^required}} if ({{#type.isDefined}}this.{{name}}{{/type.isDefined}}) { {{/required}} @@ -32,5 +32,5 @@ {{^-last}} {{/-last}} -{{/bodyFields}} +{{/fieldsToSerialize}} } \ No newline at end of file diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/RequestShape.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/RequestShape.mustache index f73e867c2f..4acc648e79 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/RequestShape.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/RequestShape.mustache @@ -1,13 +1,13 @@ {{>Partials/ClassDeclaration}} { - {{#canBeSingleton}} +{{#canBeSingleton}} public {{className}}() {} /** * Singleton instance for {@link {{className}}}. */ public static final {{className}} _INSTANCE = new {{className}}(); - {{/canBeSingleton}} - {{^canBeSingleton}} +{{/canBeSingleton}} +{{^canBeSingleton}} {{>ObjectShape/Fields}} // --------------------------------------------------------------------------------------------- @@ -16,19 +16,21 @@ {{>ObjectShape/Getters}} - {{#hasRequestBody}} +{{#hasRequestBody}} {{>ObjectShape/Serialize}} - {{/hasRequestBody}} +{{/hasRequestBody}} // --------------------------------------------------------------------------------------------- {{>ObjectShape/Builder}} - {{#hasRequestBody}} +{{#hasRequestBody}} // --------------------------------------------------------------------------------------------- - {{>ObjectShape/Deserialize}}{{/hasRequestBody}} - {{/canBeSingleton}} + {{>ObjectShape/Deserialize}} + +{{/hasRequestBody}} +{{/canBeSingleton}} // --------------------------------------------------------------------------------------------- diff --git a/samples/src/main/java/org/opensearch/client/samples/DataStreamBasics.java b/samples/src/main/java/org/opensearch/client/samples/DataStreamBasics.java index 762e94c6bf..ac7a1cdd08 100644 --- a/samples/src/main/java/org/opensearch/client/samples/DataStreamBasics.java +++ b/samples/src/main/java/org/opensearch/client/samples/DataStreamBasics.java @@ -11,7 +11,6 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.opensearch.client.opensearch.indices.CreateDataStreamRequest; -import org.opensearch.client.opensearch.indices.DataStream; import org.opensearch.client.opensearch.indices.DataStreamsStatsRequest; import org.opensearch.client.opensearch.indices.DataStreamsStatsResponse; import org.opensearch.client.opensearch.indices.DeleteDataStreamRequest; @@ -40,7 +39,7 @@ public static void main(String[] args) { // Create an index template which configures data stream PutIndexTemplateRequest putIndexTemplateRequest = new PutIndexTemplateRequest.Builder().name(dataStreamIndexTemplateName) .indexPatterns(namePattern) - .dataStream(new DataStream.Builder().timestampField(t -> t.name(timestampFieldName)).build()) + .dataStream(ds -> ds.timestampField(t -> t.name(timestampFieldName))) .build(); client.indices().putIndexTemplate(putIndexTemplateRequest);